| Conditions | 4 |
| Paths | 8 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4.343 |
| 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( |
||
| 26 | $stmt->keyVar, |
||
|
|
|||
| 27 | null, |
||
| 28 | CompiledExpression::UNKNOWN |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | |||
| 32 | 2 | if ($stmt->valueVar) { |
|
| 33 | 2 | $context->getExpressionCompiler()->declareVariable( |
|
| 34 | 2 | $stmt->valueVar, |
|
| 35 | 2 | null, |
|
| 36 | CompiledExpression::UNKNOWN |
||
| 37 | 2 | ); |
|
| 38 | 2 | } |
|
| 39 | |||
| 40 | 2 | foreach ($stmt->stmts as $statement) { |
|
| 41 | 2 | \PHPSA\nodeVisitorFactory($statement, $context); |
|
| 42 | 2 | } |
|
| 43 | 2 | } |
|
| 44 | } |
||
| 45 |
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.