| Conditions | 3 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 63 | public function __map($callback):array { |
||
| 64 | |||
| 65 | if(!is_callable($callback)){ |
||
| 66 | throw new TraitException('invalid callback'); |
||
|
|
|||
| 67 | } |
||
| 68 | |||
| 69 | $return = []; |
||
| 70 | |||
| 71 | foreach($this->array as $index => $element){ |
||
| 72 | $return[$index] = call_user_func_array($callback, [$element, $index]); |
||
| 73 | } |
||
| 74 | |||
| 75 | return $return; |
||
| 76 | } |
||
| 91 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: