PHP 8.5.0 Alpha 2 available for testing

Voting

: max(six, nine)?
(Example: nine)

The Note You're Voting On

Anonymous
14 years ago
The behaviour of FINAL is not as serious as you may think. A little explample:
<?php
class A {
final private function
method(){}
}

class
B extends A {
private function
method(){}
}
?>

Normally you would expect some of the following will happen:
- An error that final and private keyword cannot be used together
- No error as the private visibility says, that a method/var/etc. is only visible within the same class

But what happens is PHP is a little curios: "Cannot override final method A::method()"

So its possible to deny method names in subclasses! Don't know if this is a good behavior, but maybe its useful for your purpose.

<< Back to user notes page

To Top