From b0a6898ca8891440f64ac2c656b09cc6c45b9086 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 7 Apr 2026 15:49:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(aot):=20=E4=BF=AE=E5=A4=8D=E7=A9=BA?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=B5=8B=E5=80=BC=E8=BF=90=E7=AE=97=E7=AC=A6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E5=92=8C=E7=B1=BB=E5=90=8D?= =?UTF-8?q?=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 - 更新测试用例 004.phpt 中的变量初始化顺序以匹配预期行为 - 修改 CompilerBase.php 中的类名解析逻辑,使用 getFullClassName() 替代直接访问 $this->class - 确保 self 引用时获取完整的类名信息 --- src/Php/CompilerBase.php | 2 +- tests/aot/coalesce/004.phpt | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 538c00b3..4f5ec4dd 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -4014,7 +4014,7 @@ class CompilerBase extends \PhpAot\Core\Translator $class = $this->parseIdentifier($expr->class); $propertyName = $this->parseIdentifier($expr->name); if ($class === 'self') { - $class = $this->class; + $class = $this->getFullClassName(); } elseif ($class === 'parent') { if (!$this->classDef->extends) { $this->fatalError($expr, 'Cannot access parent:: when current class does not extend any class'); diff --git a/tests/aot/coalesce/004.phpt b/tests/aot/coalesce/004.phpt index 2cbe1b1c..67c790bf 100644 --- a/tests/aot/coalesce/004.phpt +++ b/tests/aot/coalesce/004.phpt @@ -3,16 +3,19 @@ Test ?? operator --FILE--