These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * This file is part of Railt package. |
||
4 | * |
||
5 | * For the full copyright and license information, please view the LICENSE |
||
6 | * file that was distributed with this source code. |
||
7 | */ |
||
8 | declare(strict_types=1); |
||
9 | |||
10 | namespace Railt\SDL\Frontend\Builder\Definition; |
||
11 | |||
12 | use Railt\Parser\Ast\RuleInterface; |
||
13 | use Railt\SDL\Frontend\Builder\BaseBuilder; |
||
14 | use Railt\SDL\Frontend\Context\ContextInterface; |
||
15 | use Railt\SDL\Frontend\Deferred\Deferred; |
||
16 | use Railt\SDL\Frontend\Deferred\DeferredInterface; |
||
17 | use Railt\SDL\Frontend\Deferred\NamedDeferred; |
||
18 | use Railt\SDL\IR\SymbolTable\Value; |
||
19 | use Railt\SDL\IR\SymbolTable\VarSymbolInterface; |
||
20 | use Railt\SDL\IR\Type; |
||
21 | use Railt\SDL\IR\Type\TypeNameInterface; |
||
22 | |||
23 | /** |
||
24 | * Class SchemaDefinitionBuilder |
||
25 | */ |
||
26 | class SchemaDefinitionBuilder extends BaseBuilder |
||
27 | { |
||
28 | /** |
||
29 | * @param RuleInterface $rule |
||
30 | * @return bool |
||
31 | */ |
||
32 | public function match(RuleInterface $rule): bool |
||
33 | { |
||
34 | return $rule->getName() === 'SchemaDefinition'; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param ContextInterface $ctx |
||
39 | * @param RuleInterface $rule |
||
40 | * @return \Generator|mixed |
||
41 | */ |
||
42 | public function reduce(ContextInterface $ctx, RuleInterface $rule) |
||
43 | { |
||
44 | /** @var TypeNameInterface|null $name */ |
||
45 | $name = yield $rule->first('> #TypeName'); |
||
46 | |||
47 | yield $this->deferred($ctx, yield $rule->first('> #TypeName')) |
||
48 | ->then(function (ContextInterface $context) use ($name, $rule) { |
||
49 | return $this->then($context, $rule, $name); |
||
50 | }); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @param ContextInterface $ctx |
||
55 | * @param RuleInterface $rule |
||
56 | * @param null|TypeNameInterface $name |
||
57 | */ |
||
58 | private function then(ContextInterface $ctx, RuleInterface $rule, ?TypeNameInterface $name): void |
||
59 | { |
||
60 | /** @var VarSymbolInterface $a */ |
||
61 | // $a = yield 'a'; |
||
62 | |||
63 | // dd($a->set(new Value(24, Type::int()))); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param ContextInterface $context |
||
68 | * @param null|TypeNameInterface $name |
||
69 | * @return DeferredInterface |
||
70 | */ |
||
71 | private function deferred(ContextInterface $context, ?TypeNameInterface $name): DeferredInterface |
||
72 | { |
||
73 | return $name ? new NamedDeferred($name, $context) : new Deferred($context); |
||
0 ignored issues
–
show
|
|||
74 | } |
||
75 | } |
||
76 |
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: