Conditions | 6 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public function leaveNode(Node $node) |
||
15 | { |
||
16 | if (!$node instanceof Coalesce) { |
||
17 | return; |
||
18 | } |
||
19 | switch(true) |
||
20 | { |
||
21 | case $node->left instanceof Node\Expr\FuncCall: |
||
22 | case $node->left instanceof Node\Expr\MethodCall: |
||
23 | case $node->left instanceof Node\Expr\StaticCall: |
||
24 | $notEmptyCall = new Node\Expr\BooleanNot(new Node\Expr\FuncCall(new Node\Name('empty'), [$node->left])); |
||
|
|||
25 | return new Node\Expr\Ternary($notEmptyCall, $node->left, $node->right); |
||
26 | case $node->left instanceof Node\Expr\BinaryOp: |
||
27 | $issetCall = new Node\Expr\FuncCall(new Node\Name('isset'), [$node->left->right]); |
||
28 | $node->left->right = new Node\Expr\Ternary($issetCall, $node->left->right, $node->right); |
||
29 | return $node->left; |
||
30 | default: |
||
31 | $issetCall = new Node\Expr\FuncCall(new Node\Name('isset'), [$node->left]); |
||
32 | return new Node\Expr\Ternary($issetCall, $node->left, $node->right); |
||
33 | } |
||
34 | } |
||
35 | } |
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: