1 | <?php |
||
23 | class RulesBuilder |
||
24 | { |
||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | private $rules; |
||
29 | |||
30 | /** |
||
31 | * @var RuleResolver |
||
32 | */ |
||
33 | private $resolver; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $parsed = []; |
||
39 | |||
40 | /** |
||
41 | * @var \SplStack |
||
42 | */ |
||
43 | private $stack; |
||
44 | |||
45 | /** |
||
46 | * @var Readable|null |
||
47 | */ |
||
48 | private $file; |
||
49 | |||
50 | /** |
||
51 | * @var array |
||
52 | */ |
||
53 | private $mappings = []; |
||
54 | |||
55 | /** |
||
56 | * @var int |
||
57 | */ |
||
58 | private $lastRuleId = 0; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | private $text = ''; |
||
64 | |||
65 | /** |
||
66 | * RulesBuilder constructor. |
||
67 | * @param RuleResolver $resolver |
||
68 | */ |
||
69 | public function __construct(RuleResolver $resolver) |
||
75 | |||
76 | /** |
||
77 | * @return array |
||
78 | */ |
||
79 | public function build(): array |
||
105 | |||
106 | /** |
||
107 | * @param string $rule |
||
108 | * @return bool |
||
109 | */ |
||
110 | private function isCompleted(string $rule): bool |
||
114 | |||
115 | /** |
||
116 | * @param Builder $builder |
||
117 | * @return RulesBuilder |
||
118 | */ |
||
119 | private function add(Builder $builder): RulesBuilder |
||
126 | |||
127 | /** |
||
128 | * @param string $rule |
||
129 | * @return ConcatenationBuilder |
||
130 | */ |
||
131 | private function root(string $rule): ConcatenationBuilder |
||
135 | |||
136 | /** |
||
137 | * @param string $rule |
||
138 | * @return int |
||
139 | */ |
||
140 | private function getId(string $rule = null): int |
||
152 | |||
153 | /** |
||
154 | * @param string $rule |
||
155 | * @return bool |
||
156 | */ |
||
157 | private function isKept(string $rule): bool |
||
161 | |||
162 | /** |
||
163 | * @param TokenInterface $token |
||
164 | * @param SlicedIterator $tokens |
||
165 | * @return int |
||
166 | */ |
||
167 | private function reduce(TokenInterface $token, SlicedIterator $tokens): int |
||
183 | |||
184 | /** |
||
185 | * @param TokenInterface $token |
||
186 | * @param bool $keep |
||
187 | * @return int |
||
188 | */ |
||
189 | private function reduceToken(TokenInterface $token, bool $keep): int |
||
199 | |||
200 | private function reduceConcat(SlicedIterator $iterator) |
||
204 | |||
205 | /** |
||
206 | * @return RulesBuilder |
||
207 | */ |
||
208 | private function complete(): RulesBuilder |
||
225 | |||
226 | /** |
||
227 | * @return Builder |
||
228 | */ |
||
229 | private function current(): Builder |
||
233 | } |
||
234 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.