diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 54f6dcd2..9926e5f5 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1521,7 +1521,7 @@ class CompilerBase extends \PhpAot\Core\Translator protected function parsePostOp($expr, string $op): string { if ($this->isVarExpr($expr->var)) { - return $this->parseIdentifier($expr->var) . '++'; + return $this->parseIdentifier($expr->var) . str_repeat($op, 2); } elseif ($this->isPropertyFetch($expr->var)) { $obj = $this->parseIdentifier($expr->var->var); $prop = $this->identifierToStr($expr->var->name); @@ -1539,7 +1539,7 @@ class CompilerBase extends \PhpAot\Core\Translator $this->afterStmtLines[] = 'php::setStaticProperty(' . $class . ', ' . $prop . ', ' . $tmpVar . ' ' . $op . ' 1);'; return $tmpVar; } - abort($expr, "Post-increment operator is not supported for non-variable expressions"); + $this->parsePostOp($expr, "Post-increment operator is not supported for non-variable expressions"); } protected function parsePostDec($expr): string diff --git a/tests/aot/postincdec.phpt b/tests/aot/postincdec.phpt new file mode 100644 index 00000000..a7f3a5af --- /dev/null +++ b/tests/aot/postincdec.phpt @@ -0,0 +1,15 @@ +--TEST-- +postinc/dec +--FILE-- + +--EXPECT-- +int(3) +int(4)