| Conditions | 4 |
| Paths | 8 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4.074 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | 2 | public function compile($stmt, Context $context) |
|
| 21 | { |
||
| 22 | 2 | $context->getExpressionCompiler()->compile($stmt->expr); |
|
| 23 | |||
| 24 | 2 | if ($stmt->keyVar) { |
|
| 25 | $context->getExpressionCompiler()->declareVariable($stmt->keyVar, null, CompiledExpression::MIXED); |
||
|
|
|||
| 26 | } |
||
| 27 | |||
| 28 | 2 | if ($stmt->valueVar) { |
|
| 29 | 2 | $context->getExpressionCompiler()->declareVariable($stmt->valueVar, null, CompiledExpression::MIXED); |
|
| 30 | 2 | } |
|
| 31 | |||
| 32 | 2 | foreach ($stmt->stmts as $statement) { |
|
| 33 | 2 | \PHPSA\nodeVisitorFactory($statement, $context); |
|
| 34 | 2 | } |
|
| 35 | 2 | } |
|
| 36 | } |
||
| 37 |
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.