Overriding
Overriding is an OOP concept where a child class provides its own implementation of a method that already exists in a parent class.
Child classes may override constant values, properties and methods.
When overriding, visibility cannot be reduced. A protected method or constant may become public, but not private.
The #[Override] attribute is a helper tool to ensure that a child method overrides a parent method. It is the complement of the abstract keyword.
Incompatible overriding is not always detected at linting time: this happens when the overriding definition is parsed before the overridden definition.
<?php
class Elephpant {
function trumpet() {}
}
class Calf {
function trumpet() {}
}
?>