| Conditions | 4 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4.0961 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 1 | public function pass(Expr\StaticCall $expr, Context $context) |
|
| 25 | { |
||
| 26 | 1 | $classObject = $context->scope->getPointer()->getObject(); |
|
| 27 | 1 | if (!$classObject instanceof ClassDefinition || !$classObject->isFinal()) { |
|
| 28 | return false; |
||
| 29 | } |
||
| 30 | |||
| 31 | 1 | if ($expr->class->getFirst() !== 'static') { |
|
|
|
|||
| 32 | return false; |
||
| 33 | } |
||
| 34 | |||
| 35 | 1 | $context->notice( |
|
| 36 | 1 | 'error.final-static-usage', |
|
| 37 | 1 | 'Don\'t use static:: in final class', |
|
| 38 | $expr |
||
| 39 | 1 | ); |
|
| 40 | |||
| 41 | 1 | return true; |
|
| 42 | } |
||
| 43 | |||
| 65 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: