1 | <?php |
||
32 | class Frontend implements LoggerAwareInterface |
||
33 | { |
||
34 | use LoggerAwareTrait; |
||
35 | |||
36 | /** |
||
37 | * @var Parser |
||
38 | */ |
||
39 | private $parser; |
||
40 | |||
41 | /** |
||
42 | * Frontend constructor. |
||
43 | */ |
||
44 | public function __construct() |
||
48 | |||
49 | /** |
||
50 | * @param Readable $file |
||
51 | * @return iterable|OpcodeInterface[] |
||
52 | * @throws SyntaxException |
||
53 | */ |
||
54 | public function load(Readable $file): iterable |
||
60 | |||
61 | /** |
||
62 | * @param Readable $file |
||
63 | * @param Context $context |
||
64 | * @return Collection|OpcodeInterface[] |
||
65 | * @throws SyntaxException |
||
66 | */ |
||
67 | private function collect(Readable $file, Context $context): Collection |
||
101 | |||
102 | /** |
||
103 | * @param mixed $value |
||
104 | * @return void |
||
105 | */ |
||
106 | private function log($value): void |
||
114 | |||
115 | /** |
||
116 | * A method for recursively traversing all rules of an Abstract |
||
117 | * Syntax Tree to obtain all the opcodes that the tree provides. |
||
118 | * |
||
119 | * @param NodeInterface|RuleInterface $node |
||
120 | * @param Context $context |
||
121 | * @return iterable|OpcodeInterface[]|\Generator |
||
122 | */ |
||
123 | private function bypass(NodeInterface $node, Context $context): \Generator |
||
162 | |||
163 | /** |
||
164 | * Method for unpacking the list of opcodes from the rule. |
||
165 | * |
||
166 | * @param RuleInterface $key |
||
167 | * @param \Generator $iterator |
||
168 | * @return \Generator|OpcodeInterface[] |
||
169 | */ |
||
170 | private function extract(RuleInterface $key, \Generator $iterator): \Generator |
||
185 | |||
186 | /** |
||
187 | * Make sure that the key is a valid AST rule that contains |
||
188 | * a link to the position inside the file. |
||
189 | * |
||
190 | * @param \Generator $current |
||
191 | * @param RuleInterface $parent |
||
192 | * @return RuleInterface |
||
193 | */ |
||
194 | private function extractKey(\Generator $current, RuleInterface $parent): RuleInterface |
||
200 | |||
201 | /** |
||
202 | * Parse the file using top-down parser and |
||
203 | * return the Abstract Syntax Tree. |
||
204 | * |
||
205 | * @param Readable $file |
||
206 | * @return RuleInterface |
||
207 | * @throws SyntaxException |
||
208 | */ |
||
209 | private function parse(Readable $file): RuleInterface |
||
220 | |||
221 | /** |
||
222 | * @param LoggerInterface $logger |
||
223 | * @return Frontend |
||
224 | */ |
||
225 | public function setLogger(LoggerInterface $logger): self |
||
231 | } |
||
232 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.