1 | <?php |
||
34 | class Builder |
||
35 | { |
||
36 | /** |
||
37 | * @var string[]|Builder\BuilderInterface[] |
||
38 | */ |
||
39 | private const DEFAULT_BUILDER_DEFINITIONS = [ |
||
40 | // |
||
41 | // Instruction builders. |
||
42 | // Provides variadic result. |
||
43 | // |
||
44 | Builder\Instruction\ImportBuilder::class, |
||
45 | Builder\Instruction\NamespaceBuilder::class, |
||
46 | Builder\Instruction\VariableBuilder::class, |
||
47 | Builder\Instruction\VariableReassigmentBuilder::class, |
||
48 | |||
49 | // |
||
50 | // Definition builders. |
||
51 | // Provides deferred builders. |
||
52 | // |
||
53 | Builder\Definition\ObjectDefinitionBuilder::class, |
||
54 | Builder\Definition\SchemaDefinitionBuilder::class, |
||
55 | |||
56 | // |
||
57 | // Value builders. |
||
58 | // Provides: \Railt\SDL\IR\SymbolTable\ValueInterface |
||
59 | // |
||
60 | Builder\Value\NullValueBuilder::class, |
||
61 | Builder\Value\VariableValueBuilder::class, |
||
62 | Builder\Value\TypeInvocationBuilder::class, |
||
63 | Builder\Value\ConstantValueBuilder::class, |
||
64 | Builder\Value\BooleanValueBuilder::class, |
||
65 | Builder\Value\NumberValueBuilder::class, |
||
66 | Builder\Value\StringValueBuilder::class, |
||
67 | |||
68 | // |
||
69 | // Common builders. |
||
70 | // Provides: |
||
71 | // - TypeNameBuilder: Railt\SDL\IR\Type\TypeNameInterface |
||
72 | // - ConstantNameBuilder: Railt\SDL\IR\Type\TypeNameInterface |
||
73 | // - TypeDefinitionBuilder: Railt\SDL\Frontend\Definition\DefinitionInterface |
||
74 | // |
||
75 | Builder\Common\TypeNameBuilder::class, |
||
76 | Builder\Common\ConstantNameBuilder::class, |
||
77 | Builder\Common\TypeDefinitionBuilder::class, |
||
78 | ]; |
||
79 | |||
80 | /** |
||
81 | * @var array|Builder\BuilderInterface[] |
||
82 | */ |
||
83 | private $builders; |
||
84 | |||
85 | /** |
||
86 | * @var DeferredStorage |
||
87 | */ |
||
88 | private $deferred; |
||
89 | |||
90 | /** |
||
91 | * @var SymbolTableInterface |
||
92 | */ |
||
93 | private $table; |
||
94 | |||
95 | /** |
||
96 | * @var Parser |
||
97 | */ |
||
98 | private $parser; |
||
99 | |||
100 | /** |
||
101 | * @var Process |
||
102 | */ |
||
103 | private $process; |
||
104 | |||
105 | /** |
||
106 | * @var TypesStorage |
||
107 | */ |
||
108 | private $types; |
||
109 | |||
110 | /** |
||
111 | * Builder constructor. |
||
112 | * @param StrategyInterface $naming |
||
113 | */ |
||
114 | public function __construct(StrategyInterface $naming) |
||
126 | |||
127 | /** |
||
128 | * @param Factory $interceptors |
||
129 | * @return Process |
||
130 | */ |
||
131 | private function bootProcess(Factory $interceptors): Process |
||
135 | |||
136 | /** |
||
137 | * @param DeferredStorage $deferred |
||
138 | * @param TypesStorage $types |
||
139 | * @return Factory |
||
140 | */ |
||
141 | private function bootInterceptors(DeferredStorage $deferred, TypesStorage $types): Factory |
||
156 | |||
157 | /** |
||
158 | * @param ContextInterface $ctx |
||
159 | * @param RuleInterface $rule |
||
160 | * @return array |
||
161 | */ |
||
162 | public function buildNode(ContextInterface $ctx, RuleInterface $rule): array |
||
168 | |||
169 | /** |
||
170 | * @param ContextInterface $context |
||
171 | * @param RuleInterface $ast |
||
172 | * @return mixed|\Traversable |
||
173 | * @throws \Railt\Io\Exception\ExternalFileException |
||
174 | */ |
||
175 | private function runBuilder(ContextInterface $context, RuleInterface $ast) |
||
179 | |||
180 | /** |
||
181 | * @param ContextInterface $context |
||
182 | * @param RuleInterface $ast |
||
183 | * @return BuilderInterface |
||
184 | */ |
||
185 | private function getBuilder(ContextInterface $context, RuleInterface $ast): BuilderInterface |
||
196 | |||
197 | /** |
||
198 | * @return array |
||
199 | */ |
||
200 | private function bootBuilders(): array |
||
210 | |||
211 | /** |
||
212 | * @param Readable $readable |
||
213 | * @return array[]|iterable |
||
214 | * @throws SyntaxException |
||
215 | * @throws \Railt\Io\Exception\ExternalFileException |
||
216 | */ |
||
217 | public function buildFile(Readable $readable): iterable |
||
223 | |||
224 | /** |
||
225 | * Parse the file using top-down parser and |
||
226 | * return the Abstract Syntax Tree. |
||
227 | * |
||
228 | * @param Readable $file |
||
229 | * @return RuleInterface |
||
230 | * @throws SyntaxException |
||
231 | */ |
||
232 | public function parse(Readable $file): RuleInterface |
||
243 | |||
244 | /** |
||
245 | * @param Readable $readable |
||
246 | * @param iterable|RuleInterface[] $rules |
||
247 | * @return iterable|array[] |
||
248 | * @throws \Railt\Io\Exception\ExternalFileException |
||
249 | */ |
||
250 | public function buildAst(Readable $readable, iterable $rules): iterable |
||
260 | |||
261 | /** |
||
262 | * @param ContextInterface $context |
||
263 | * @param iterable|RuleInterface[] $rules |
||
264 | * @return ContextInterface |
||
265 | */ |
||
266 | private function run(ContextInterface $context, iterable $rules): ContextInterface |
||
274 | |||
275 | /** |
||
276 | * @param ContextInterface $context |
||
277 | * @return ContextInterface |
||
278 | */ |
||
279 | private function deferred(ContextInterface $context): ContextInterface |
||
291 | } |
||
292 |
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: