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 |
Recurse.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_map, is_array;
11 use s9e\RegexpBuilder\Runner;
12
13 /**
14 * Enables passes to be run recursively into alternations to replace a(?:x0|x1|y0|y1) with a[xy][01]
15 */
16 class Recurse extends AbstractPass
17 {
18 /**
19 * @var Runner
20 */
21 protected $runner;
22
23 /**
24 * @param Runner $runner
25 */
26 public function __construct(Runner $runner)
27 {
28 $this->runner = $runner;
29 }
30
31 /**
32 * {@inheritdoc}
33 */
34 protected function runPass(array $strings): array
35 {
36 return array_map([$this, 'recurseString'], $strings);
37 }
38
39 /**
40 * Recurse into given string and run all passes on each element
41 *
42 * @param array $string
43 * @return array
44 */
45 protected function recurseString(array $string): array
46 {
47 $isOptional = $this->isOptional;
48 foreach ($string as $k => $element)
49 {
50 if (is_array($element))
51 {
52 $string[$k] = $this->runner->run($element);
53 }
54 }
55 $this->isOptional = $isOptional;
56
57 return $string;
58 }
59 }