fix(php): 修复预处理器中的依赖关系处理逻辑

- 在符号依赖检查中添加文件过滤条件,避免将当前文件添加到依赖列表中
- 移除对函数节点类型的冗余检查,简化符号声明文件映射逻辑
- 确保所有符号声明都能正确记录到对应文件中,提高依赖解析准确性
pull/1/head
韩天峰 5 months ago
parent f6a3e5b4b3
commit 7681f6dc26
  1. 10
      src/Php/Preprocessor.php

@ -26,11 +26,15 @@ class Preprocessor extends CompilerBase
$deps = [];
foreach ($symbols as $symbol) {
if (isset($this->symbolDeclInFile[$symbol])) {
$deps[] = $this->symbolDeclInFile[$symbol];
$depFile = $this->symbolDeclInFile[$symbol];
if ($depFile !== $file) {
$deps[] = $depFile;
}
}
}
$sorter->add($file, array_unique($deps));
}
$sortedFiles = $sorter->sort();
foreach ($list as $file) {
@ -171,9 +175,7 @@ class Preprocessor extends CompilerBase
if ($this->stubFile) {
$this->nativeFunctions[$name] = $this->parseFunctionDecl($v);
} else {
if ($v instanceof Node\Stmt\Function_) {
$this->symbolDeclInFile[strtolower($name)] = $this->file;
}
$this->symbolDeclInFile[strtolower($name)] = $this->file;
}
}

Loading…
Cancel
Save