| Conditions | 6 |
| Paths | 6 |
| Total Lines | 33 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 11.0618 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 11 | protected function compile($expr, Context $context) |
|
| 27 | { |
||
| 28 | 11 | if ($expr->var instanceof \PHPParser\Node\Expr\Variable) { |
|
| 29 | 11 | $variableName = (string)$expr->var->name; |
|
| 30 | 11 | $variable = $context->getSymbol($variableName); |
|
| 31 | 11 | if ($variable) { |
|
| 32 | 11 | $variable->incUse(); |
|
| 33 | |||
| 34 | 11 | switch ($variable->getType()) { |
|
| 35 | 11 | case CompiledExpression::INTEGER: |
|
| 36 | 11 | case CompiledExpression::DOUBLE: |
|
| 37 | 11 | case CompiledExpression::NUMBER: |
|
| 38 | 11 | $variable->inc(); |
|
| 39 | 11 | return CompiledExpression::fromZvalValue($variable->getValue()); |
|
| 40 | } |
||
| 41 | |||
| 42 | $context->notice( |
||
| 43 | 'language_error', |
||
| 44 | 'You are trying to use post increment operator on variable $' . $variableName . |
||
| 45 | ' with type: ' . $variable->getTypeName(), |
||
| 46 | $expr |
||
| 47 | ); |
||
| 48 | } else { |
||
| 49 | $context->notice( |
||
| 50 | 'language_error', |
||
| 51 | 'You are trying to use post increment operator on undefined variable: ' . $variableName, |
||
| 52 | $expr |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | return new CompiledExpression(); |
||
| 58 | } |
||
| 59 | } |
||
| 60 |