| Conditions | 5 |
| Paths | 12 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5.2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | 1 | public function compile($stmt, Context $context) |
|
| 21 | { |
||
| 22 | 1 | $context->getExpressionCompiler()->compile($stmt->expr); |
|
| 23 | |||
| 24 | 1 | if ($stmt->keyVar) { |
|
| 25 | $context->getExpressionCompiler()->declareVariable($stmt->keyVar); |
||
|
|
|||
| 26 | } |
||
| 27 | |||
| 28 | 1 | if ($stmt->valueVar) { |
|
| 29 | 1 | $context->getExpressionCompiler()->declareVariable($stmt->valueVar); |
|
| 30 | 1 | } |
|
| 31 | |||
| 32 | 1 | if (count($stmt->stmts) > 0) { |
|
| 33 | 1 | foreach ($stmt->stmts as $statement) { |
|
| 34 | 1 | \PHPSA\nodeVisitorFactory($statement, $context); |
|
| 35 | 1 | } |
|
| 36 | 1 | } else { |
|
| 37 | return $context->notice('not-implemented-body', 'Missing body', $stmt); |
||
| 38 | } |
||
| 39 | 1 | } |
|
| 40 | } |
||
| 41 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.