1 | <?php |
||
16 | trait ValueParserPart { |
||
17 | |||
18 | private $constMap = [ |
||
19 | 'false' => false, |
||
20 | 'true' => true |
||
21 | ]; |
||
22 | |||
23 | 10 | private function parseValue(ValueInterface $obj, Node $node) { |
|
24 | 10 | $value = $node instanceof Const_ ? $node->value : $node->default; |
|
1 ignored issue
–
show
|
|||
25 | 10 | if ($value !== null) { |
|
26 | 7 | if ($this->isPrimitive($value)) { |
|
27 | 7 | $obj->setValue($this->getPrimitiveValue($value)); |
|
28 | 7 | } else { |
|
29 | 4 | $obj->setExpression($this->getExpression($value)); |
|
30 | } |
||
31 | 7 | } |
|
32 | 10 | } |
|
33 | |||
34 | 7 | private function isPrimitive(Node $node) { |
|
35 | return $node instanceof String_ |
||
36 | 7 | || $node instanceof LNumber |
|
37 | 6 | || $node instanceof DNumber |
|
38 | 6 | || $this->isBool($node) |
|
39 | 7 | || $this->isNull($node); |
|
40 | } |
||
41 | |||
42 | 7 | private function getPrimitiveValue(Node $node) { |
|
53 | |||
54 | 7 | private function isBool(Node $node) { |
|
64 | |||
65 | 7 | private function isNull(Node $node) { |
|
71 | |||
72 | /** |
||
73 | * Returns the value from a node |
||
74 | * |
||
75 | * @param Node $node |
||
76 | * @return mixed |
||
77 | */ |
||
78 | 6 | private function getExpression(Node $node) { |
|
101 | } |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: