1 | <?php |
||
32 | class Builder |
||
33 | { |
||
34 | /** |
||
35 | * @var string[]|Builder\BuilderInterface[] |
||
36 | */ |
||
37 | private const DEFAULT_BUILDER_DEFINITIONS = [ |
||
38 | // |
||
39 | // Instruction builders. |
||
40 | // Provides variadic result. |
||
41 | // |
||
42 | Builder\Instruction\ImportBuilder::class, |
||
43 | Builder\Instruction\NamespaceBuilder::class, |
||
44 | Builder\Instruction\VariableBuilder::class, |
||
45 | Builder\Instruction\VariableReassigmentBuilder::class, |
||
46 | |||
47 | // |
||
48 | // Definition builders. |
||
49 | // Provides deferred builders. |
||
50 | // |
||
51 | Builder\Definition\ObjectDefinitionBuilder::class, |
||
52 | Builder\Definition\SchemaDefinitionBuilder::class, |
||
53 | |||
54 | // |
||
55 | // Value builders. |
||
56 | // Provides: \Railt\SDL\IR\SymbolTable\ValueInterface |
||
57 | // |
||
58 | Builder\Value\ScalarValueBuilder::class, |
||
59 | Builder\Value\VariableValueBuilder::class, |
||
60 | Builder\Value\TypeInvocationBuilder::class, |
||
61 | Builder\Value\ConstantValueBuilder::class, |
||
62 | Builder\Value\BooleanValueBuilder::class, |
||
63 | |||
64 | // |
||
65 | // Common builders. |
||
66 | // Provides: |
||
67 | // - TypeNameBuilder: Railt\SDL\IR\Type\TypeNameInterface |
||
68 | // - ConstantNameBuilder: Railt\SDL\IR\Type\TypeNameInterface |
||
69 | // - TypeDefinitionBuilder: Railt\SDL\Frontend\Definition\DefinitionInterface |
||
70 | // |
||
71 | Builder\Common\TypeNameBuilder::class, |
||
72 | Builder\Common\ConstantNameBuilder::class, |
||
73 | Builder\Common\TypeDefinitionBuilder::class, |
||
74 | ]; |
||
75 | |||
76 | /** |
||
77 | * @var array|Builder\BuilderInterface[] |
||
78 | */ |
||
79 | private $builders = []; |
||
80 | |||
81 | /** |
||
82 | * @var Storage |
||
83 | */ |
||
84 | private $store; |
||
85 | |||
86 | /** |
||
87 | * @var SymbolTableInterface |
||
88 | */ |
||
89 | private $table; |
||
90 | |||
91 | /** |
||
92 | * @var Parser |
||
93 | */ |
||
94 | private $parser; |
||
95 | |||
96 | /** |
||
97 | * Builder constructor. |
||
98 | */ |
||
99 | public function __construct() |
||
107 | |||
108 | /** |
||
109 | * @return void |
||
110 | */ |
||
111 | private function bootDefaults(): void |
||
117 | |||
118 | /** |
||
119 | * @param Readable $readable |
||
120 | * @return array[]|iterable |
||
121 | * @throws SyntaxException |
||
122 | * @throws \Railt\Io\Exception\ExternalFileException |
||
123 | */ |
||
124 | public function buildFile(Readable $readable): iterable |
||
130 | |||
131 | /** |
||
132 | * Parse the file using top-down parser and |
||
133 | * return the Abstract Syntax Tree. |
||
134 | * |
||
135 | * @param Readable $file |
||
136 | * @return RuleInterface |
||
137 | * @throws SyntaxException |
||
138 | */ |
||
139 | public function parse(Readable $file): RuleInterface |
||
150 | |||
151 | /** |
||
152 | * @param Readable $readable |
||
153 | * @param iterable $ast |
||
154 | * @return iterable|array[] |
||
155 | * @throws \Railt\Io\Exception\ExternalFileException |
||
156 | */ |
||
157 | public function buildAst(Readable $readable, iterable $ast): iterable |
||
169 | |||
170 | /** |
||
171 | * @param ContextInterface $context |
||
172 | * @param RuleInterface $ast |
||
173 | * @return array|iterable<int,ContextInterface|mixed> |
||
174 | * @throws \Railt\Io\Exception\ExternalFileException |
||
175 | */ |
||
176 | public function buildNode(ContextInterface $context, RuleInterface $ast): array |
||
190 | |||
191 | /** |
||
192 | * @param ContextInterface $context |
||
193 | * @param RuleInterface $ast |
||
194 | * @return mixed|\Traversable|void |
||
195 | * @throws \Railt\Io\Exception\ExternalFileException |
||
196 | */ |
||
197 | private function resolve(ContextInterface $context, RuleInterface $ast) |
||
208 | |||
209 | /** |
||
210 | * @param ContextInterface $ctx |
||
211 | * @param \Generator $process |
||
212 | * @param int $offset |
||
213 | * @return array|iterable<int, ContextInterface|mixed> |
||
214 | */ |
||
215 | private function coroutine(ContextInterface $ctx, \Generator $process, int $offset = 0): array |
||
263 | |||
264 | /** |
||
265 | * @param ContextInterface $context |
||
266 | * @return \Generator |
||
267 | * @throws CompilerException |
||
268 | */ |
||
269 | private function after(ContextInterface $context): \Generator |
||
283 | } |
||
284 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: