| Conditions | 3 |
| Paths | 3 |
| Total Lines | 10 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function isAllowed($parameter = NULL): bool { |
||
| 18 | 1 | if(!is_callable($parameter)) { |
|
| 19 | 1 | throw new \InvalidArgumentException("Method " . static::class . "::isAllowed expects callback as parameter."); |
|
| 20 | } |
||
| 21 | 1 | $result = call_user_func($parameter); |
|
| 22 | 1 | if(!is_bool($result)) { |
|
| 23 | 1 | throw new \UnexpectedValueException("The callback for method " . static::class . "::isAllowed has to return boolean, " . gettype($result) . " returned."); |
|
| 24 | } |
||
| 25 | 1 | return $result; |
|
| 26 | } |
||
| 27 | } |
||
| 28 | ?> |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.