diff --git a/docs/UNSUPPORTED_SYNTAX.md b/docs/UNSUPPORTED_SYNTAX.md index 4de5df5e..85b7d1c5 100644 --- a/docs/UNSUPPORTED_SYNTAX.md +++ b/docs/UNSUPPORTED_SYNTAX.md @@ -2261,6 +2261,110 @@ function main() { --- +### 13. 类继承的编译期严格检查 + +**状态**: 行为差异 +**PHP 版本**: 所有版本 +**描述**: AOT 编译器在编译期对类继承关系进行比标准 PHP 更严格的检查。以下三种情况在标准 PHP 中是运行时错误,但在 AOT 中会在编译期直接报告致命错误。 + +#### 13.1 禁止实例化抽象类 + +在标准 PHP 中,`new AbstractClass()` 是运行时错误;AOT 在编译期检测到此类实例化时立即报错。 + +```php +exec('Cannot call abstract method `AbsBase::show()`', 'parent-abstract-method.php'); } + + public function testNewAbstractClass() + { + $this->exec('abstract class `AbstractBase` cannot be instantiated', 'abstract-class-new.php'); + } + + public function testOverridePrivateMethod() + { + $this->exec('Cannot override private method `Base::doWork()`', 'override-private-method.php'); + } }