Final Keyword
The final keyword prevents child classes from overriding a method or a constant by prefixing the definition with final.
The final keyword cannot be used with the private keyword: a private method is not visible in the child classes, and can’t also be redefined.
<?php
final class Elephpant {
final const HABITAT = 1;
final function method() { }
}
?>
See Also
- Final Classes: Open for Extension, Closed for Inheritance
- How to Mock Final Classes in PHPUnit
- Why (nearly) every PHP class you write should be abstract or final
- When to declare classes final