1 | <?php declare(strict_types=1); |
||
25 | class ExtractorDefinitionBuilder implements ExtractorDefinitionBuilderInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $type_regexp = '/ |
||
31 | ^( |
||
32 | (?<name> |
||
33 | [-_\w]* |
||
34 | ) |
||
35 | (?: |
||
36 | \s* |
||
37 | \( |
||
38 | \s* |
||
39 | (?<param> |
||
40 | (?-3)* |
||
41 | | |
||
42 | [\w\\\\]+ |
||
43 | ) |
||
44 | \s* |
||
45 | \) |
||
46 | )? |
||
47 | (?: |
||
48 | \s* |
||
49 | \| |
||
50 | \s* |
||
51 | (?<alt>(?-4)) |
||
52 | )? |
||
53 | (?: |
||
54 | \s* |
||
55 | (?<arr>\[\s*\]) |
||
56 | \s* |
||
57 | )? |
||
58 | ) |
||
59 | $ |
||
60 | /xi'; |
||
61 | |||
62 | protected $type_regexp2 = '/ |
||
63 | ^ |
||
64 | (?:((\w+\b(?:\(.*\))?(?:\s*\[\s*\])?)(?:\s*\|\s*(?-1))*)) |
||
65 | | |
||
66 | (?:\(\s*(?-2)\s*\)(?:\s*\[\s*\])?) |
||
67 | | |
||
68 | (\[\s*\]) |
||
69 | $ |
||
70 | /xi'; |
||
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | 8 | public function build(string $definition): ExtractorDefinitionInterface |
|
89 | |||
90 | /** |
||
91 | * @param string $name |
||
92 | * @param null|string $param |
||
93 | * @param null|string $alt_definitions |
||
94 | * |
||
95 | * @return ExtractorDefinitionInterface |
||
96 | * @throws ExtractorDefinitionBuilderException |
||
97 | */ |
||
98 | 6 | protected function buildExtractor(string $name, ?string $param, ?string $alt_definitions, bool $is_arr): ExtractorDefinitionInterface |
|
123 | |||
124 | /** |
||
125 | * @param PlainExtractorDefinitionInterface $definition |
||
126 | * @param string $alt_definitions |
||
127 | * |
||
128 | * @return VariableExtractorDefinition |
||
129 | * @throws ExtractorDefinitionBuilderException |
||
130 | */ |
||
131 | 2 | protected function buildVariableDefinition(PlainExtractorDefinitionInterface $definition, string $alt_definitions): VariableExtractorDefinition |
|
150 | |||
151 | } |
||
152 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: