diff --git a/.gitignore b/.gitignore index 00a267f1..5e9baa6c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,6 @@ /vendor /tmp /projects/wordpress +/projects/workerman /.php-cs-fixer.cache *.o \ No newline at end of file diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 0fcd122d..d64ac06c 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3189,6 +3189,10 @@ class CompilerBase extends \PhpAot\Core\Translator protected function parseMethodCall(Node\Expr\MethodCall $expr): string { + if ($this->isVarExpr($expr->var)) { + $this->errorUndefinedVariable($expr->var); + } + $object = $this->convertToObject($expr->var); if ($this->isTypedObject($object)) { $class = $this->getObjectType($object); @@ -3451,10 +3455,10 @@ class CompilerBase extends \PhpAot\Core\Translator return $code; } - protected function parseCatch(mixed $catch, string $exVar): string + protected function parseCatch(Node\Stmt\Catch_ $catch, string $exVar): string { $types = $catch->types; - $var = $this->parseIdentifier($catch->var); + $var = $catch->var ? $this->parseIdentifier($catch->var) : $this->genTmpVarName(); if (!$this->hasVar($var)) { $this->addLocalVar($var, self::TYPE_OBJECT); } diff --git a/tests/aot/try-catch-2.phpt b/tests/aot/try-catch-2.phpt new file mode 100644 index 00000000..d42365d4 --- /dev/null +++ b/tests/aot/try-catch-2.phpt @@ -0,0 +1,14 @@ +--TEST-- +try catch 2 +--FILE-- + +--EXPECT-- +Caught exception