fix(php): 修复类方法和常量查找的无限循环问题

- 将类方法查找中的条件循环改为无限循环以正确处理继承链
- 将类常量查找中的条件循环改为无限循环以正确处理继承链
- 确保在继承链结束时能够正确返回 false 而不是陷入无限循环
pull/1/head
韩天峰 5 months ago
parent e508b6de4f
commit 057e25712d
  1. 4
      src/Php/CompilerBase.php

@ -1665,7 +1665,7 @@ class CompilerBase extends \PhpAot\Core\Translator
$classDef = $this->getClass($class);
$methodDef = null;
// 递归查找,若子类中未定义方法,则尝试查找父类是否存在此方法
while ($classDef) {
while (true) {
if (!$classDef->hasMethod($method)) {
if (!$classDef->extends) {
return false;
@ -1711,7 +1711,7 @@ class CompilerBase extends \PhpAot\Core\Translator
$classDef = $this->getClass($class);
$constDef = null;
// 递归查找,若子类中未定义方法,则尝试查找父类是否存在此方法
while ($classDef) {
while (true) {
if (!$classDef->hasConstant($const)) {
if (!$classDef->extends) {
return false;

Loading…
Cancel
Save