refactor(php): 移除调试代码并优化类定义获取逻辑

- 移除了 hasNativeClass 方法中的调试打印堆栈跟踪代码
- 将直接访问类定义数组改为使用 getClassDef 方法获取类定义
- 提高了代码的可维护性和性能表现
pull/1/head
韩天峰 6 months ago
parent a54985897f
commit 081c9fcc82
  1. 3
      src/Php/CompilerBase.php
  2. 2
      src/Php/Translator.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);
}

@ -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);

Loading…
Cancel
Save