note 80956 modified in language.oop5.abstract by felipe

From: Date: Mon, 24 Mar 2008 23:20:07 +0000
Subject: note 80956 modified in language.oop5.abstract by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137525@lists.php.net to get a copy of this message
I think there is actually an issue in your object model. Indeed, the following code does not work : <?php interface Foo { public function myFoo(); } abstract class Bar implements Foo { public abstract function myFoo(); public abstract function myBar(); public function myBar2() { echo "myBar2"; } } class myImplementation extends Bar { public function myFoo() { echo "Foo"; } public function myBar() { echo "Bar"; } } ?> Your only chance to make it work is to remove the declaration of abstract method "myFoo" into abstract class "Bar". From my point of view, it is quite strange (PHP seems to consider interface as "special" abstract class (which is not completly wrong)) but it works like that. Took me some time to understand this ;) --was-- I think there is actually an issue in your object model. Indeed, the following code does not work : [PHP] <? interface Foo { public function myFoo(); } abstract class Bar implements Foo { public abstract function myFoo(); public abstract function myBar(); public function myBar2() { echo "myBar2"; } } class myImplementation extends Bar { public function myFoo() { echo "Foo"; } public function myBar() { echo "Bar"; } } ?> [/PHP] Your only chance to make it work is to remove the declaration of abstract method "myFoo" into abstract class "Bar". From my point of view, it is quite strange (PHP seems to consider interface as "special" abstract class (which is not completly wrong)) but it works like that. Took me some time to understand this ;) http://php.net/manual/en/language.oop5.abstract.php

« previous php.notes (#137525) next »