From 848c763c0dfa63ea33a4207074377fa56c23cec6 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Sun, 19 Jul 2026 11:09:22 +0800 Subject: [PATCH] test(compiler): cover expression variable names --- phpunit/code/variable-variable-function-call.php | 12 ++++++++++++ phpunit/src/VariableVariableTest.php | 5 +++++ src/CompilerBase.php | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 phpunit/code/variable-variable-function-call.php diff --git a/phpunit/code/variable-variable-function-call.php b/phpunit/code/variable-variable-function-call.php new file mode 100644 index 00000000..26fd0ef1 --- /dev/null +++ b/phpunit/code/variable-variable-function-call.php @@ -0,0 +1,12 @@ +exec('The `$$` syntax is not supported', 'variable-variable-arraydim.php'); } + + public function testVariableVariableWithFunctionCallThrowsUnsupportedError(): void + { + $this->exec('The `$$` syntax is not supported', 'variable-variable-function-call.php'); + } } diff --git a/src/CompilerBase.php b/src/CompilerBase.php index 6381503d..eff7eab5 100644 --- a/src/CompilerBase.php +++ b/src/CompilerBase.php @@ -1273,7 +1273,7 @@ class CompilerBase implements PropertyAccessContext protected function parseVariable(Variable $expr): string { - if (is_object($expr->name)) { + if (!is_string($expr->name)) { $this->fatalError($expr, 'The `$$` syntax is not supported'); } if ($this->isSuperGlobal($expr->name)) {