(PHP 8 >= 8.3.0)
<?php
class Base {
protected function foo(): void {}
}
final class Extended extends Base {
#[\Override]
protected function boo(): void {}
}
?>
PHP 8.3 中以上示例的输出类似于
Fatal error: Extended::boo() has #[\Override] attribute, but no matching parent method exists