1 | <?php |
||
9 | final class RegExp |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $pattern; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $modifiers; |
||
20 | |||
21 | /** |
||
22 | * @var bool |
||
23 | */ |
||
24 | private $global = false; |
||
25 | |||
26 | public function __construct(string $pattern, string $modifiers = '') |
||
32 | |||
33 | public function isGlobal(): bool |
||
37 | |||
38 | public function __toString(): string |
||
42 | |||
43 | private function wrapInDelimiters(string $pattern): string |
||
50 | |||
51 | /** |
||
52 | * Checks if pattern has valid delimiter |
||
53 | * |
||
54 | * @param string $pattern |
||
55 | * @return bool |
||
56 | * @see https://secure.php.net/manual/en/regexp.reference.delimiters.php |
||
57 | */ |
||
58 | private function hasDelimiters(string $pattern): bool |
||
73 | |||
74 | private static function isValidDelimiter(string $char): bool |
||
78 | |||
79 | /** |
||
80 | * Creates RegExp instance based on passed regular expression. |
||
81 | * |
||
82 | * @param string $regexp |
||
83 | * @return RegExp |
||
84 | * @example |
||
85 | * RegExp::fromString('/foo/gi'); // -> new RegExp('/foo/', 'gi'); |
||
86 | */ |
||
87 | public static function fromString(string $regexp): RegExp |
||
101 | |||
102 | /** |
||
103 | * @param string|RegExp $regexp |
||
104 | * @return RegExp |
||
105 | */ |
||
106 | public static function of($regexp): RegExp |
||
115 | |||
116 | /** |
||
117 | * @param string $test |
||
118 | * @return string[] |
||
119 | */ |
||
120 | public function matchAll(string $test): array |
||
133 | |||
134 | public function test(string $string): bool |
||
138 | } |
||
139 |
Late static binding only has effect in subclasses. A
final
class cannot be extended anymore so late static binding cannot occurr. Consider replacingstatic::
withself::
.To learn more about late static binding, please refer to the PHP core documentation.