From 4a5fe8dd6cf4091947472fe9247c971af7991576 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 7 Apr 2026 18:34:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8D=E6=8A=BD?= =?UTF-8?q?=E8=B1=A1=E6=9E=84=E9=80=A0=E5=87=BD=E6=95=B0=E4=B8=AD=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E5=B1=9E=E6=80=A7=E7=9A=84=E5=A3=B0=E6=98=8E=E6=A3=80?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加了对抽象构造函数中提升属性的验证逻辑 - 在方法重写检查后增加了专门的构造函数处理 - 防止在抽象构造函数中声明提升属性导致的错误 - 实现了参数提升属性的检测和错误报告机制 --- src/Php/Preprocessor.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Php/Preprocessor.php b/src/Php/Preprocessor.php index 27a3b38f..71443254 100644 --- a/src/Php/Preprocessor.php +++ b/src/Php/Preprocessor.php @@ -274,6 +274,13 @@ class Preprocessor extends CompilerBase if (!($class->flags & Modifiers::ABSTRACT)) { $this->fatalError($v, "Class {$this->class} cannot override non-abstract method {$v->name}"); } + if ($this->method === '__construct') { + foreach ($v->params as $param) { + if ($param->isPromoted()) { + $this->fatalError($v, "Cannot declare promoted property in an abstract constructor"); + } + } + } } $fullClassName = $this->getFullClassName();