Re: Declaration of Bar::__construct() must be compatible with that of Foo::__construct()

From: Date: Thu, 26 Feb 2004 07:56:35 +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-8156@lists.php.net to get a copy of this message
Timm Friebe wrote:
thekid@friebes:~/devel/php/tests > cat inheritance.php <?php class Foo {
    function __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? If that error still occurs if you explicitely call the parent's __construct (from the derived __construct), that's a bug IMO.
It's totally understandable to get such an error message in the case the parent constructor gets called implicitely, but for an explicit call there should neither be a warning or an error . Cheers, Michael

« previous php.internals (#8156) next »