| 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 |
||
| 17 | 1 | public function pass(Expr\StaticCall $expr, Context $context) |
|
| 18 | { |
||
| 19 | 1 | $classObject = $context->scope->getPointer()->getObject(); |
|
| 20 | 1 | if (!$classObject instanceof ClassDefinition || !$classObject->isFinal()) { |
|
| 21 | return false; |
||
| 22 | } |
||
| 23 | |||
| 24 | 1 | if ($expr->class->getFirst() !== 'static') { |
|
|
|
|||
| 25 | return false; |
||
| 26 | } |
||
| 27 | |||
| 28 | 1 | $context->notice( |
|
| 29 | 1 | 'error.final-static-usage', |
|
| 30 | 1 | 'Don\'t use static:: in final class', |
|
| 31 | $expr |
||
| 32 | 1 | ); |
|
| 33 | |||
| 34 | 1 | return true; |
|
| 35 | } |
||
| 36 | |||
| 47 |
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: