| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 24 | public function pass($stmt, Context $context) |
||
| 25 | { |
||
| 26 | $condition = $stmt->cond; |
||
| 27 | |||
| 28 | if ($stmt instanceof For_ && count($stmt->cond) > 0) { // For is the only one that has an array as condition |
||
| 29 | $condition = $condition[0]; |
||
| 30 | } |
||
| 31 | |||
| 32 | $expression = $context->getExpressionCompiler()->compile($condition); |
||
| 33 | |||
| 34 | if ($expression->hasValue()) { // @todo implement isStatic() method to see if expression changes or not |
||
| 35 | $context->notice( |
||
| 36 | 'fixed_condition', |
||
| 37 | 'The condition will always result in the same boolean value', |
||
| 38 | $stmt |
||
| 39 | ); |
||
| 40 | |||
| 41 | return true; |
||
| 42 | } |
||
| 43 | |||
| 44 | return false; |
||
| 45 | } |
||
| 46 | |||
| 62 |