1 | <?php |
||
28 | class Builder |
||
29 | { |
||
30 | /** |
||
31 | * @var string[]|Builder\BuilderInterface[] |
||
32 | */ |
||
33 | private const DEFAULT_BUILDER_DEFINITIONS = [ |
||
34 | Builder\Instruction\ImportBuilder::class, |
||
35 | Builder\Instruction\NamespaceBuilder::class, |
||
36 | Builder\Instruction\VariableBuilder::class, |
||
37 | Builder\Instruction\VariableReassigmentBuilder::class, |
||
38 | |||
39 | // |
||
40 | Builder\DefinitionBuilder::class, |
||
41 | |||
42 | // Values |
||
43 | Builder\Value\ScalarValueBuilder::class, |
||
44 | Builder\Value\VariableValueBuilder::class, |
||
45 | Builder\Value\TypeInvocationBuilder::class, |
||
46 | Builder\Value\ConstantValueBuilder::class, |
||
47 | Builder\Value\BooleanValueBuilder::class, |
||
48 | |||
49 | // |
||
50 | Builder\Common\TypeNameBuilder::class, |
||
51 | Builder\TypeDefinitionBuilder::class, |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * @var array|Builder\BuilderInterface[] |
||
56 | */ |
||
57 | private $builders = []; |
||
58 | |||
59 | /** |
||
60 | * @var Frontend |
||
61 | */ |
||
62 | private $frontend; |
||
63 | |||
64 | /** |
||
65 | * @var SymbolTableInterface |
||
66 | */ |
||
67 | private $table; |
||
68 | |||
69 | /** |
||
70 | * Builder constructor. |
||
71 | * @param Frontend $frontend |
||
72 | * @param SymbolTable $table |
||
73 | */ |
||
74 | public function __construct(Frontend $frontend, SymbolTable $table) |
||
80 | |||
81 | /** |
||
82 | * @return void |
||
83 | */ |
||
84 | private function bootDefaults(): void |
||
90 | |||
91 | /** |
||
92 | * @param Readable $readable |
||
93 | * @return \Traversable |
||
94 | * @throws \Railt\Io\Exception\ExternalFileException |
||
95 | * @throws \Railt\SDL\Exception\SyntaxException |
||
96 | */ |
||
97 | public function load(Readable $readable): iterable |
||
101 | |||
102 | /** |
||
103 | * @param Readable $file |
||
104 | * @param iterable $ast |
||
105 | * @return iterable |
||
106 | * @throws \Railt\Io\Exception\ExternalFileException |
||
107 | */ |
||
108 | public function build(Readable $file, iterable $ast): iterable |
||
127 | |||
128 | /** |
||
129 | * @param mixed $result |
||
130 | * @return bool |
||
131 | */ |
||
132 | private function filter($result): bool |
||
136 | |||
137 | /** |
||
138 | * @param ContextInterface $context |
||
139 | * @param RuleInterface $ast |
||
140 | * @return array|iterable<int,ContextInterface|mixed> |
||
141 | * @throws \Railt\Io\Exception\ExternalFileException |
||
142 | */ |
||
143 | private function reduce(ContextInterface $context, RuleInterface $ast): array |
||
157 | |||
158 | /** |
||
159 | * @param ContextInterface $context |
||
160 | * @param RuleInterface $ast |
||
161 | * @return mixed|\Traversable|void |
||
162 | * @throws \Railt\Io\Exception\ExternalFileException |
||
163 | */ |
||
164 | private function resolve(ContextInterface $context, RuleInterface $ast) |
||
175 | |||
176 | /** |
||
177 | * @param ContextInterface $ctx |
||
178 | * @param \Generator $process |
||
179 | * @return array|iterable<int, ContextInterface|mixed> |
||
180 | */ |
||
181 | private function run(ContextInterface $ctx, \Generator $process): array |
||
213 | } |
||
214 |
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.