Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

MergeSuffix.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 1.69 KiB


 01  <?php declare(strict_types=1);
 02   
 03  /**
 04  * @package   s9e\RegexpBuilder
 05  * @copyright Copyright (c) 2016-2022 The s9e authors
 06  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
 07  */
 08  namespace s9e\RegexpBuilder\Passes;
 09   
 10  use const false, true;
 11  use function array_filter, array_pop, array_unshift, count, end;
 12   
 13  /**
 14  * Replaces (?:aax|bbx) with (?:aa|bb)x
 15  */
 16  class MergeSuffix extends AbstractPass
 17  {
 18      /**
 19      * {@inheritdoc}
 20      */
 21      protected function canRun(array $strings): bool
 22      {
 23          return (count($strings) > 1 && $this->hasMatchingSuffix($strings));
 24      }
 25   
 26      /**
 27      * {@inheritdoc}
 28      */
 29      protected function runPass(array $strings): array
 30      {
 31          $newString = [];
 32          while ($this->hasMatchingSuffix($strings))
 33          {
 34              array_unshift($newString, end($strings[0]));
 35              $strings = $this->pop($strings);
 36          }
 37          array_unshift($newString, $strings);
 38   
 39          return [$newString];
 40      }
 41   
 42      /**
 43      * Test whether all given strings have the same last element
 44      *
 45      * @param  array[] $strings
 46      * @return bool
 47      */
 48      protected function hasMatchingSuffix(array $strings): bool
 49      {
 50          $suffix = end($strings[1]);
 51          foreach ($strings as $string)
 52          {
 53              if (end($string) !== $suffix)
 54              {
 55                  return false;
 56              }
 57          }
 58   
 59          return ($suffix !== false);
 60      }
 61   
 62      /**
 63      * Remove the last element of every string
 64      *
 65      * @param  array[] $strings Original strings
 66      * @return array[]          Processed strings
 67      */
 68      protected function pop(array $strings): array
 69      {
 70          $cnt = count($strings);
 71          $i   = $cnt;
 72          while (--$i >= 0)
 73          {
 74              array_pop($strings[$i]);
 75          }
 76   
 77          // Remove empty elements then prepend one back at the start of the array if applicable
 78          $strings = array_filter($strings);
 79          if (count($strings) < $cnt)
 80          {
 81              array_unshift($strings, []);
 82          }
 83   
 84          return $strings;
 85      }
 86  }