| Conditions | 5 |
| Paths | 7 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function leaveNode(Node $node) |
||
| 15 | { |
||
| 16 | if (!$node instanceof Param) { |
||
| 17 | return; |
||
| 18 | } |
||
| 19 | |||
| 20 | if ($node->type instanceof Node\NullableType) { |
||
| 21 | $node->type = $node->type->type; |
||
| 22 | if (!$node->default) { |
||
| 23 | $node->default = new Node\Expr\ConstFetch( |
||
| 24 | new Node\Name('null') |
||
| 25 | ); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($this->isScalar($node->type)) { |
||
|
|
|||
| 30 | $node->type = null; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 44 |
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.