1.2.462. Final Private Methods¶
PHP’s private methods cannot be overwritten, as they are dedicated to the current class. That way, the
finalkeyword is useless.
PHP 8.0 warns when it finds such a method.
<?php
class foo {
// Final and private both prevent child classes to overwrite the method
final private function bar() {}
// Final and protected (or public) keep this method available, but not overwritable
final protected function bar() {}
}
?>
See also Final Keyword.
1.2.462.2. Connex PHP features¶
1.2.462.2.1. Suggestions¶
Remove the final keyword
Relax visibility
1.2.462.2.2. Specs¶
Short name |
Classes/FinalPrivate |
Rulesets |
|
Exakat since |
2.2.0 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |