From 583536a24e303fc5e4135ae2dec30175b8da76f1 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 16 Apr 2026 14:26:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8D=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=99=A8=E4=B8=AD=E7=9A=84=E6=9D=A1=E4=BB=B6=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正了 isClassConstFetch 条件判断的位置,确保正确的执行流程 - 补全了 DynamicCall 异常捕获后的代码块结构 - 修复了静态方法调用检查中的条件表达式逻辑 - 统一了 Translator 中的 elseif 语法使用规范 --- src/Php/CompilerBase.php | 8 +++++--- src/Php/Translator.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index a5e4a125..491a89f5 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1500,7 +1500,8 @@ class CompilerBase extends \PhpAot\Core\Translator $argClass = $expr->args[1]->value; if ($this->isScalarString($argClass)) { return $this->getNamespacedClassName($this->parseIdentifier($argClass)); - } elseif ($this->isClassConstFetch($argClass)) { + } + if ($this->isClassConstFetch($argClass)) { if ($this->isNameExpr($argClass->class) and $this->isIdExpr($argClass->name) and $this->parseIdentifier($argClass->name) === 'class') { return $this->getNamespacedClassName($this->parseIdentifier($argClass->class)); } @@ -1516,7 +1517,8 @@ class CompilerBase extends \PhpAot\Core\Translator if ($nativeFunc) { return $this->getFunction($nativeFunc)->returnClass; } - } catch (DynamicCall) {} + } catch (DynamicCall) { + } } if ($this->isStaticCall($expr) and $this->isNameExpr($expr->class) and $this->isNamedMethod($expr->name)) { $class = $this->parseIdentifier($expr->class); @@ -4045,7 +4047,7 @@ class CompilerBase extends \PhpAot\Core\Translator $fn = 'php::concat({' . $this->identifierToStr($expr->class) . ', "::", ' . $this->identifierToStr($expr->name) . '})'; } $placeHolder = $fn; - } elseif ($class === 'static') { + } elseif ($this->isNameExpr($expr->class) and $class === 'static') { $methodPtr = $this->identifierToStr($expr->name, literal: true); $fn = Symbol::getCalledCe() . ', php::getMethod(' . Symbol::getCalledCe() . ', ' . $methodPtr . ')'; $this->context->beforeStmtLines[] = '// Static Method Call: static::' . $this->parseIdentifier($expr->name) . '()'; diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 4c9e2a50..794ad162 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -591,7 +591,7 @@ class Translator extends Preprocessor } } elseif (is_float($value)) { return $value; - } else if (is_bool($value)) { + } elseif (is_bool($value)) { return $value ? 1 : 0; } elseif (is_string($value)) { return $this->genCharPtr($value);