From afc4ef87f8543fe87490a1756b485a1bddfd525b Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 13 Mar 2026 18:00:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(php):=20=E6=B7=BB=E5=8A=A0=E5=AF=B9=20self?= =?UTF-8?q?=20=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 CompilerBase.php 中添加了对 self 类型的处理逻辑 - 将 self 类型的对象添加到对象映射中 - 添加了静态类属性读写测试用例 - 测试验证了 self 类型在静态上下文中的正确行为 --- src/Php/CompilerBase.php | 3 +++ tests/aot/static_prop_write_2.phpt | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/aot/static_prop_write_2.phpt diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index c97b7ef2..aa87c1fd 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1744,6 +1744,9 @@ class CompilerBase extends \PhpAot\Core\Translator // no break case 'mixed': return self::TYPE_VAR; + case 'self': + $this->objects[$var] = $this->classDef->getNamespacedName(false); + return self::TYPE_OBJECT; case 'resource': $this->fatalError($param, 'Cannot use `resource` as a parameter type.'); // no break diff --git a/tests/aot/static_prop_write_2.phpt b/tests/aot/static_prop_write_2.phpt new file mode 100644 index 00000000..68fcf70b --- /dev/null +++ b/tests/aot/static_prop_write_2.phpt @@ -0,0 +1,21 @@ +--TEST-- +Static Class Property Read/Write Test +--FILE-- + +--EXPECT-- +string(6) "Select" \ No newline at end of file