| Conditions | 6 |
| Paths | 5 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6.2373 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 3 | public function pass(Expr\StaticCall $expr, Context $context) |
|
| 25 | { |
||
| 26 | 3 | if (!$context->scope) { |
|
| 27 | return false; |
||
| 28 | } |
||
| 29 | |||
| 30 | 3 | $scopePointer = $context->scope->getPointer(); |
|
| 31 | 3 | if (!$scopePointer) { |
|
| 32 | return false; |
||
| 33 | } |
||
| 34 | |||
| 35 | 3 | $classObject = $scopePointer->getObject(); |
|
| 36 | 3 | if (!$classObject instanceof ClassDefinition || !$classObject->isFinal()) { |
|
| 37 | 2 | return false; |
|
| 38 | } |
||
| 39 | |||
| 40 | 1 | if ($expr->class->getFirst() !== 'static') { |
|
|
|
|||
| 41 | return false; |
||
| 42 | } |
||
| 43 | |||
| 44 | 1 | $context->notice( |
|
| 45 | 1 | 'error.final-static-usage', |
|
| 46 | 1 | 'Don\'t use static:: in final class', |
|
| 47 | $expr |
||
| 48 | 1 | ); |
|
| 49 | |||
| 50 | 1 | return true; |
|
| 51 | } |
||
| 52 | |||
| 74 |
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: