ID: 43277 Updated by: [EMAIL PROTECTED] Reported By: krister dot karlstrom at arcada dot fi -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Linux/Slackware PHP Version: 5.2.5 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php PHP is class based OOP, not prototype based. Hence in your example there are two conflicting methods. Previous Comments: ------------------------------------------------------------------------ [2007-11-13 12:19:46] krister dot karlstrom at arcada dot fi Description: ------------ I found this "weird" mix-up of the behaviour of interfaces and abstract classes. I think that you should be able to always implement an interface, regardless of how and where some of the implemented methods where declared or defined. The only thing that should matter is that the declared class defines all the methods that the interface requires. The error message from PHP says that it can't inherit the method Test::foo() - an implementation of an interface has nothing to do with inheritance in classes in the OO-model. It shouldn't even try to "inherit" the methods of the interface, just check that the defined class implements all of the required methods. Reproduce code: --------------- <?php interface Test { public function foo(); } abstract class Bar { public abstract function foo(); } class FooBar extends Bar implements Test { public function foo() { echo "Hello!"; } } ?> Expected result: ---------------- I expect this to raise no error, because the class FooBar nicely defines and implements the method foo(), as the interface Test defines. Actual result: -------------- [error] PHP Fatal error: Can't inherit abstract function Test::foo() (previously declared abstract in Bar) in /var/www/asta.arcada.fi/beta/foobar.php on line 13 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43277&edit=1