Override Attribute
This is a native PHP attribute, which tells the engine that a method must be overriding the same method in a parent.
The overridden method may be in the parent, or any subsequent parent; it may also be defined in a trait, as a concrete definition or an alias.
The error is only reported at execution time. The same error message is used if the class has no parent, at linting time.
This attribute may be added to any method.
<?php
class Elephpant {
function trumpet() {}
}
class Calf {
#[Override]
function trumpet() {}
#[Override]
function forage() {}
// This raise an error, as forage() has no definition in the parent.
}
?>