From c8e6f2ecc40e28ec730a3af64dc62850e457eb5a Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 5 Jun 2026 14:41:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=B8=BA=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=BB=A5=E8=A7=A3=E5=86=B3=E5=8A=A8=E6=80=81=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 findNativeMethod 调用周围添加 try-catch 块 - 捕获 DynamicCall 异常以处理内部类继承的方法 - 添加注释说明无法静态解析类型的情况 - 保持原有逻辑在非异常情况下的正常执行流程 --- src/Php/CompilerBase.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 125a3916..253c179a 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -2094,10 +2094,14 @@ class CompilerBase extends \PhpAot\Core\Translator } if ($this->isVarExpr($expr->var)) { $object = $this->parseIdentifier($expr->var); - $nativeFunc = $this->findNativeMethod($expr, $object, $method); - if ($nativeFunc) { - $funcDef = $this->getFunction($nativeFunc); - return $funcDef->returnType; + try { + $nativeFunc = $this->findNativeMethod($expr, $object, $method); + if ($nativeFunc) { + $funcDef = $this->getFunction($nativeFunc); + return $funcDef->returnType; + } + } catch (DynamicCall) { + // Method inherited from internal class, can't resolve type statically } if ($this->isTypedObject($object)) { return $this->detectMethodCallReturnType($this->getObjectType($object), $method);