[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php declare(strict_types=1); 2 3 /** 4 * @package s9e\RegexpBuilder 5 * @copyright Copyright (c) 2016-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\RegexpBuilder\Passes; 9 10 use function array_map, array_merge, count, is_array; 11 12 /** 13 * Replaces alternations that only contain one string to allow other passes to replace 14 * (?:a0?x|bx) with (?:a0?|b)x 15 */ 16 class PromoteSingleStrings extends AbstractPass 17 { 18 /** 19 * {@inheritdoc} 20 */ 21 protected function runPass(array $strings): array 22 { 23 return array_map([$this, 'promoteSingleStrings'], $strings); 24 } 25 26 /** 27 * Promote single strings found inside given string 28 * 29 * @param array $string Original string 30 * @return array Modified string 31 */ 32 protected function promoteSingleStrings(array $string): array 33 { 34 $newString = []; 35 foreach ($string as $element) 36 { 37 if (is_array($element) && count($element) === 1) 38 { 39 $newString = array_merge($newString, $element[0]); 40 } 41 else 42 { 43 $newString[] = $element; 44 } 45 } 46 47 return $newString; 48 } 49 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |