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
class x {
final const X = 1;
final function method() { }
}
?>
See also Final Classes: Open for Extension, Closed for Inheritance
Related : Overwrite, Private Visibility, Abstract Class, Abstract Keyword, Static Constant, Final Class Constants, Fluent Interface, Object, Protected Visibility, Public Visibility
Added in PHP 7.0