diff --git a/examples/error/undef-var.php b/examples/error/undef-var.php new file mode 100644 index 00000000..89a4c731 --- /dev/null +++ b/examples/error/undef-var.php @@ -0,0 +1,5 @@ +useFunctions[$funcName])) { - return $this->useFunctions[$funcName]; + return $this->useFunctions[$funcName] . '\\' . $funcName; } return $funcName; } @@ -4679,7 +4679,8 @@ class CompilerBase extends \PhpAot\Core\Translator $code = ''; foreach ($v2->uses as $use) { $id = $this->parseIdentifier($use->name); - if ($use->type === Node\Stmt\Use_::TYPE_FUNCTION) { + $type = $use->type !== Node\Stmt\Use_::TYPE_UNKNOWN ? $use->type : $v2->type; + if ($type === Node\Stmt\Use_::TYPE_FUNCTION) { $lastIndex = strrpos($id, '\\'); $fn = substr($id, $lastIndex + 1); $ns = substr($id, 0, $lastIndex); diff --git a/src/polyfills.php b/src/polyfills.php index b6bc0556..5b72e83b 100644 --- a/src/polyfills.php +++ b/src/polyfills.php @@ -43,3 +43,8 @@ function &refval(&$var) { return $var; } + +function any(mixed $var): mixed +{ + return $var; +} \ No newline at end of file diff --git a/tests/aot/namespace/use-func.phpt b/tests/aot/namespace/use-func.phpt new file mode 100644 index 00000000..0bd2d322 --- /dev/null +++ b/tests/aot/namespace/use-func.phpt @@ -0,0 +1,20 @@ +--TEST-- +use function +--FILE-- + +--EXPECT-- +string(11) "App\Foo\bar" \ No newline at end of file