From 2ad8df01daa77c428df53f8858203b66eb30e511 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 31 Mar 2026 18:11:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84=E5=B9=B6=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复了AstNodeType.php中的命名空间引用问题 - 将parseTrait方法从Translator.php末尾移至中间位置 - 添加了ref 002测试用例验证数组引用行为 - 统一了代码风格和导入语句格式 --- src/Php/AstNodeType.php | 2 +- src/Php/Translator.php | 10 +++++----- tests/aot/ref/002.phpt | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 tests/aot/ref/002.phpt diff --git a/src/Php/AstNodeType.php b/src/Php/AstNodeType.php index e27b5140..46f9b2a1 100644 --- a/src/Php/AstNodeType.php +++ b/src/Php/AstNodeType.php @@ -145,6 +145,6 @@ trait AstNodeType protected function isNull(NodeAbstract $expr): bool { - return $expr instanceof Node\Expr\ConstFetch && $expr->name->toString() === 'null'; + return $expr instanceof Expr\ConstFetch && $expr->name->toString() === 'null'; } } diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 9a37973b..da4b0bed 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -1247,6 +1247,11 @@ class Translator extends Preprocessor return $code; } + protected function parseTrait(Node\Stmt\Trait_ $trait) + { + throw new Unsupported('Unsupported Trait '); + } + private function getRegisterClassFunctionArgDef(ClassDef|InterfaceDef $classDef): string { $depsCeList = $this->getRegisterClassFunctionCeList($classDef); @@ -1367,9 +1372,4 @@ class Translator extends Preprocessor return $code; } - - protected function parseTrait(Node\Stmt\Trait_ $trait) - { - throw new Unsupported('Unsupported Trait '); - } } diff --git a/tests/aot/ref/002.phpt b/tests/aot/ref/002.phpt new file mode 100644 index 00000000..94da74bb --- /dev/null +++ b/tests/aot/ref/002.phpt @@ -0,0 +1,23 @@ +--TEST-- +ref 002 +--FILE-- + +--EXPECT-- +array(4) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(5) +} \ No newline at end of file