note 74058 added to language.oop5.final
| From: | penartur at yandex dot ru | Date: | Thu, 22 Mar 2007 09:39:07 +0000 |
| Subject: | note 74058 added to language.oop5.final | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124703@lists.php.net to get a copy of this message | ||
Note that you cannot ovverride final methods even if they are defined as private in parent class.
Thus, the following example:
<?php
class parentClass {
final private function someMethod() { }
}
class childClass extends parentClass {
private function someMethod() { }
}
?>
dies with error "Fatal error: Cannot override final method parentClass::someMethod() in ***.php
on line 7"
Such behaviour looks slight unexpected because in child class we cannot know, which private methods
exists in a parent class and vice versa.
So, remember that if you defined a private static method, you cannot place method with the same name
in child class.
----
Server IP: 195.222.164.18
Probable Submitter: 213.134.196.50
----
Manual Page -- http://www.php.net/manual/en/language.oop5.final.php
Edit -- https://master.php.net/note/edit/74058
Del: integrated -- https://master.php.net/note/delete/74058/integrated
Del: useless -- https://master.php.net/note/delete/74058/useless
Del: bad code -- https://master.php.net/note/delete/74058/bad+code
Del: spam -- https://master.php.net/note/delete/74058/spam
Del: non-english -- https://master.php.net/note/delete/74058/non-english
Del: in docs -- https://master.php.net/note/delete/74058/in+docs
Del: other reasons-- https://master.php.net/note/delete/74058
Reject -- https://master.php.net/note/reject/74058
Search -- https://master.php.net/manage/user-notes.php