protected function compile($expr, Context $context)
{
if ($expr->var instanceof \PHPParser\Node\Expr\Variable) {
$variableName = $expr->var->name;
if ($variableName instanceof Name) {
$variableName = $variableName->parts[0];
}
$variable = $context->getSymbol($variableName);
if ($variable) {
$variable->incUse();
switch ($variable->getType()) {
case CompiledExpression::INTEGER:
case CompiledExpression::DOUBLE:
case CompiledExpression::NUMBER:
$variable->inc();
return CompiledExpression::fromZvalValue($variable->getValue());
}
$context->notice('language_error', 'You are trying to use post increment operator on variable $' . $variableName . ' with type: ' . $variable->getTypeName(), $expr);
} else {
$context->notice('language_error', 'You are trying to use post increment operator on undefined variable: ' . $variableName, $expr);
}
}
return new CompiledExpression();
}