Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
GroupSingleCharacters.php
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 function array_diff_key, array_filter, array_unshift, array_values, count;
11
12 /**
13 * Replaces (?:aa|b|cc|d) with (?:[bd]|aa|cc)
14 * Enables other passes to replace (?:[xy]|a[xy]) with a?[xy]
15 */
16 class GroupSingleCharacters extends AbstractPass
17 {
18 /**
19 * {@inheritdoc}
20 */
21 protected function runPass(array $strings): array
22 {
23 $singles = $this->getSingleCharStrings($strings);
24 $cnt = count($singles);
25 if ($cnt > 1 && $cnt < count($strings))
26 {
27 // Remove the singles from the input, then prepend them as a new string
28 $strings = array_diff_key($strings, $singles);
29 array_unshift($strings, [array_values($singles)]);
30 }
31
32 return $strings;
33 }
34
35 /**
36 * Return an array of every single-char string in given list of strings
37 *
38 * @param array[] $strings
39 * @return array[]
40 */
41 protected function getSingleCharStrings(array $strings): array
42 {
43 return array_filter($strings, [$this, 'isSingleCharString']);
44 }
45 }