Re: Declaration of Bar::__construct() must be compatible with that of Foo::__construct()
| From: | Andi Gutmans | Date: | Thu, 26 Feb 2004 06:49:55 +0000 |
| Subject: | Re: Declaration of Bar::__construct() must be compatible with that of Foo::__construct() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8149@lists.php.net to get a copy of this message | ||
At 23:36 25/02/2004 +0100, Timm Friebe wrote:
thekid@friebes:~/devel/php/tests > cat inheritance.php <?php class Foo {Guys, You are breaking the isA relationship. We fixed this so that from now on, people will not make such mistakes anymore (I think it's the right way to go, so that we don't leave broken functionality around). You can enable compatibility mode to make this work or specify a default value (as you saw) for $bar so that you are keeping the interface of the base class. Andifunction __construct($foo) { }} class Bar extends Foo {function __construct($foo, $bar) { // Add = NULL after $bar to make it work }} ?> thekid@friebes:~/devel/php/tests > php-dev inheritance.php Fatal error: Declaration of Bar::__construct() must be compatible with that of Foo::__construct() in /usr/home/thekid/devel/php/tests/inheritance.php on line 10 Is this really necessary?