From 081c9fcc825d9f1f53e9321001ef3040a14fec74 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Sat, 28 Feb 2026 19:28:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E7=A7=BB=E9=99=A4=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E4=BB=A3=E7=A0=81=E5=B9=B6=E4=BC=98=E5=8C=96=E7=B1=BB?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了 hasNativeClass 方法中的调试打印堆栈跟踪代码 - 将直接访问类定义数组改为使用 getClassDef 方法获取类定义 - 提高了代码的可维护性和性能表现 --- src/Php/CompilerBase.php | 3 --- src/Php/Translator.php | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 2bd65923..dac0b2b7 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1455,9 +1455,6 @@ class CompilerBase extends \PhpAot\Core\Translator */ protected function hasNativeClass(string $name): bool { - if (!str_starts_with($name, 'Test')) { - debug_print_backtrace(); - } return array_key_exists($this->escapeClass($name), $this->classes); } diff --git a/src/Php/Translator.php b/src/Php/Translator.php index edebf6a8..9f8463c0 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -692,7 +692,7 @@ class Translator extends Preprocessor $fullName = $this->getNamespacedClassName($this->class); if ($this->hasNativeClass($fullName)) { - $this->classDef = $this->classes[$fullName]; + $this->classDef = $this->getClassDef($fullName); } else { $this->classDef = new ClassDef($this->class, $flags, $this->namespace); $this->addClass($fullName, $this->classDef);