fix(php): 修复抽象构造函数中提升属性的声明检查

- 添加了对抽象构造函数中提升属性的验证逻辑
- 在方法重写检查后增加了专门的构造函数处理
- 防止在抽象构造函数中声明提升属性导致的错误
- 实现了参数提升属性的检测和错误报告机制
pull/1/head
韩天峰 5 months ago
parent 28de6c86a4
commit 4a5fe8dd6c
  1. 7
      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();

Loading…
Cancel
Save