From e1fd716e03ec71a7830b5424fa6ed409dbe49b80 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 7 Apr 2026 12:26:58 +0800 Subject: [PATCH] =?UTF-8?q?test(compiler):=20=E6=B7=BB=E5=8A=A0=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=20bug=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=85=A8=E5=B1=80=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E8=A7=A3=E6=9E=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 bug #24499 测试用例,验证公共属性被误处理为私有属性的问题 - 添加 bug #24652 测试用例,修复 array_flip 函数的 broken 问题 - 添加 bug #24908 测试用例,解决超全局变量在 __destruct 中无法使用的问题 - 添加 bug #55754 测试用例,修复 ZEND_SEND_PREFER_REF 参数的引用传递问题 - 修复 CompilerBase.php 中全局变量解析逻辑,确保变量名正确转义 --- src/Php/CompilerBase.php | 2 +- tests/core/lang/bug24499.phpt | 27 +++++++++++++++++++++++++++ tests/core/lang/bug24652.phpt | 31 +++++++++++++++++++++++++++++++ tests/core/lang/bug24908.phpt | 20 ++++++++++++++++++++ tests/core/lang/bug55754.phpt | 14 ++++++++++++++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 tests/core/lang/bug24499.phpt create mode 100644 tests/core/lang/bug24652.phpt create mode 100644 tests/core/lang/bug24908.phpt create mode 100644 tests/core/lang/bug55754.phpt diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index d0ec6159..2aa627e1 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3151,7 +3151,7 @@ class CompilerBase extends \PhpAot\Core\Translator protected function parseGlobal(Node\Stmt\Global_ $v): string { foreach ($v->vars as $v) { - $name = $this->escapeVarName($v->name); + $name = $this->escapeVarName($this->parseVariable($v)); if (!$this->hasGlobalVar($name)) { $this->addGlobalVar($name, self::TYPE_VAR); } diff --git a/tests/core/lang/bug24499.phpt b/tests/core/lang/bug24499.phpt new file mode 100644 index 00000000..128b062a --- /dev/null +++ b/tests/core/lang/bug24499.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #24499 (bogus handling of a public property as a private one) +--FILE-- +id = "bar"; + } +} + +function main() { + $id = new Id(); + $obj = new stdClass; + $obj->foo = "bar"; + $id->tester($obj); + print_r($obj); +} +?> +--EXPECT-- +stdClass Object +( + [foo] => bar + [id] => bar +) diff --git a/tests/core/lang/bug24652.phpt b/tests/core/lang/bug24652.phpt new file mode 100644 index 00000000..3bcea0e1 --- /dev/null +++ b/tests/core/lang/bug24652.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #24652 (broken array_flip()) +--FILE-- + 0); + var_dump($f); + var_dump(array_key_exists(7, $f)); + var_dump(array_key_exists('7', $f)); + + print "----------\n"; + /* This doesn't */ + $f = array_flip(array('7')); + var_dump($f); + var_dump(array_key_exists(7, $f)); + var_dump(array_key_exists('7', $f)); +?> +--EXPECT-- +array(1) { + [7]=> + int(0) +} +bool(true) +bool(true) +---------- +array(1) { + [7]=> + int(0) +} +bool(true) +bool(true) diff --git a/tests/core/lang/bug24908.phpt b/tests/core/lang/bug24908.phpt new file mode 100644 index 00000000..41ee775e --- /dev/null +++ b/tests/core/lang/bug24908.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #24908 (super-globals cannot be used in __destruct()) +--INI-- +variables_order=GPS +--FILE-- + +--EXPECT-- +OK diff --git a/tests/core/lang/bug55754.phpt b/tests/core/lang/bug55754.phpt new file mode 100644 index 00000000..c58ec917 --- /dev/null +++ b/tests/core/lang/bug55754.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #55754 (Only variables should be passed by reference for ZEND_SEND_PREFER_REF params) +--FILE-- + "a")); +current(array(0 => "a")); +current($arr); + +echo "DONE"; + +?> +--EXPECT-- +DONE