note 74058 modified in language.oop5.final by felipe

From: Date: Fri, 22 Aug 2008 02:43:47 +0000
Subject: note 74058 modified in language.oop5.final by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143731@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 final method, you cannot place method with the same name in child class. --was-- 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. http://php.net/manual/en/language.oop5.final.php

« previous php.notes (#143731) next »