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