Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8149 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94969 invoked by uid 1010); 26 Feb 2004 06:50:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 94912 invoked from network); 26 Feb 2004 06:50:00 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 26 Feb 2004 06:50:00 -0000 Received: (qmail 9522 invoked from network); 26 Feb 2004 06:49:58 -0000 Received: from guardian.zend.office (HELO andi-laptop.zend.com) (10.1.1.4) by int.zend.com with SMTP; 26 Feb 2004 06:49:58 -0000 Message-ID: <5.1.0.14.2.20040226084812.037bdf28@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Thu, 26 Feb 2004 08:49:55 +0200 To: Timm Friebe ,internals@lists.php.net In-Reply-To: <1077748616.685.16.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] Declaration of Bar::__construct() must be compatible with that of Foo::__construct() From: andi@zend.com (Andi Gutmans) References: <1077748616.685.16.camel@localhost> At 23:36 25/02/2004 +0100, Timm Friebe wrote: >thekid@friebes:~/devel/php/tests > cat inheritance.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? 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. Andi