Conditions | 5 |
Paths | 5 |
Total Lines | 10 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | function isActive($route, $className = 'active'): string |
||
15 | { |
||
16 | if (is_array($route)) { |
||
17 | return in_array(Route::currentRouteName(), $route) ? $className : ''; |
||
18 | } |
||
19 | if (Route::currentRouteName() == $route) { |
||
20 | return $className; |
||
21 | } |
||
22 | if (strpos(URL::current(), $route)) { |
||
23 | return $className; |
||
24 | } |
||
27 |
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: