From 7eeb416f6a05790d70eda1a558c6561fcf1a6759 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Sat, 27 Jun 2026 10:02:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E4=BC=98=E5=8C=96=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=99=A8=E6=96=B9=E6=B3=95=E8=B0=83=E7=94=A8=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 简化方法指针获取条件判断 - 使用内部类检查替代抽象方法和重写方法检查 - 移除不必要的方法标志位检测 - 重构动态调用测试用例 --- src/Php/CompilerBase.php | 7 +--- .../aot/dynamic_call/return-base-object.phpt | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 tests/aot/dynamic_call/return-base-object.phpt diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index c5884a2d..f9ac543a 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -4700,12 +4700,7 @@ class CompilerBase extends \PhpAot\Core\Translator $funcName = ''; } - $methodIsAbstract = $class && $funcName && $this->hasClass($class) - && ($this->getMethodFlags($class, $funcName) & Modifiers::ABSTRACT); - $methodIsOverridden = $class && $funcName && $this->isOverrideMethod( - $this->getOverrideMethodName($class, $funcName) - ); - if ($class and $funcName and !$magicMethod and !$methodIsAbstract and !$methodIsOverridden) { + if ($class && $funcName && !$magicMethod && $this->isInternalClass($class)) { $methodPtr = $this->getMethodPtr($class, $funcName); } else { $methodPtr = $method; diff --git a/tests/aot/dynamic_call/return-base-object.phpt b/tests/aot/dynamic_call/return-base-object.phpt new file mode 100644 index 00000000..8a30d34c --- /dev/null +++ b/tests/aot/dynamic_call/return-base-object.phpt @@ -0,0 +1,33 @@ +--TEST-- +call overridden method through parent parameter type +--FILE-- +run() . "\n"; +} +?> +--EXPECT-- +result: impl