Re: Declaration of Bar::__construct() must be compatible with that of Foo::__construct()
| From: | Andi Gutmans | Date: | Thu, 26 Feb 2004 06:51:44 +0000 |
| Subject: | Re: Declaration of Bar::__construct() must be compatible with that of Foo::__construct() | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8150@lists.php.net to get a copy of this message | ||
At 23:52 25/02/2004 +0100, Timm Friebe wrote:
On Wed, 2004-02-25 at 23:44, Marcus Boerger wrote: Hello Timm, i had the same expirience today too. And also for me it makes not much sense. The constructor shouldn't check inheritance rules. Neither should other methods follow this. What if I want to add a non-default parameter to an overriden method?Uhmmm if you do that then Bar isA Foo will not be correct.
<?php class Foo {Sure it is. Regular inheritance has to follow the same isA rules as interfaces. Inheritance is exactly the same thing except that it also has code and private/protected methods/members whereas interfaces don't. Andifunction connect($server) { }} class Bar extends Foo {function connect($server, $port) { }} ?> I see where the problem comes from: zend_do_perform_implementation_check() is called from do_inherit_method_check() (both in zend_compile.c) which in turn is called for inheritance *and* for interfaces. The behaviour is fully desirable when implementing interfaces but not for regular inheritance.