1 | <?php |
||
23 | abstract class BaseRules implements ProvideRules |
||
24 | { |
||
25 | /** |
||
26 | * @var array|Symbol[] |
||
27 | */ |
||
28 | private $rules = []; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | private $mappings = []; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $delegates = []; |
||
39 | |||
40 | /** |
||
41 | * @var array|Readable[] |
||
42 | */ |
||
43 | private $files = []; |
||
44 | |||
45 | /** |
||
46 | * @param Symbol $symbol |
||
47 | */ |
||
48 | protected function add(Symbol $symbol): void |
||
59 | |||
60 | /** |
||
61 | * @param string $rule |
||
62 | * @param string $delegate |
||
63 | * @throws GrammarException |
||
64 | */ |
||
65 | protected function addDelegate(string $rule, string $delegate): void |
||
79 | |||
80 | /** |
||
81 | * @param string $rule |
||
82 | * @param Readable $grammar |
||
83 | */ |
||
84 | protected function addFile(string $rule, Readable $grammar): void |
||
88 | |||
89 | /** |
||
90 | * @return array |
||
91 | */ |
||
92 | public function all(): array |
||
96 | |||
97 | /** |
||
98 | * @param string $rule |
||
99 | * @return bool |
||
100 | */ |
||
101 | public function hasDelegate(string $rule): bool |
||
105 | |||
106 | /** |
||
107 | * @param string $rule |
||
108 | * @return string |
||
109 | */ |
||
110 | public function getDelegate(string $rule): string |
||
114 | |||
115 | /** |
||
116 | * @param string $rule |
||
117 | * @return Readable |
||
118 | */ |
||
119 | public function getFile(string $rule): Readable |
||
123 | } |
||
124 |
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: