1 | <?php |
||
22 | class ScalarValueBuilder extends BaseBuilder |
||
23 | { |
||
24 | /** |
||
25 | * @var string[] |
||
26 | */ |
||
27 | private const SCALARS = [ |
||
28 | 'NumberValue', |
||
29 | 'StringValue', |
||
30 | 'NullValue', |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * @param RuleInterface $rule |
||
35 | * @return bool |
||
36 | */ |
||
37 | public function match(RuleInterface $rule): bool |
||
41 | |||
42 | /** |
||
43 | * @param ContextInterface $ctx |
||
44 | * @param RuleInterface|AstValueInterface $rule |
||
45 | * @return mixed|Value |
||
46 | */ |
||
47 | public function reduce(ContextInterface $ctx, RuleInterface $rule) |
||
63 | } |
||
64 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.