Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55507 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68865 invoked from network); 19 Sep 2011 00:24:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2011 00:24:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.42 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.218.42 mail-yi0-f42.google.com Received: from [209.85.218.42] ([209.85.218.42:64905] helo=mail-yi0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/15-28880-4DB867E4 for ; Sun, 18 Sep 2011 20:24:53 -0400 Received: by yib12 with SMTP id 12so4249825yib.29 for ; Sun, 18 Sep 2011 17:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=JBCmqCPgMh0+q6ybFEHixNw+z2DWqt3lWAoYuaBzWkE=; b=PaYP1+sQPegWQj5CBvPkjcLVxKfFwUgFueYyykA98JqLcyFj8E5IzPq9gEKD+L+XlT F0QHYIOsEvfhqpi7DkPScdMeUghCg4vu0cpVfn87WDGVTuVXa6v0b4gkfqSbaeQd/nlY bSHMxSioJQSSLb0Joh8mmfKo0peGo+WvxF67U= MIME-Version: 1.0 Received: by 10.146.192.28 with SMTP id p28mr1593407yaf.35.1316391889181; Sun, 18 Sep 2011 17:24:49 -0700 (PDT) Received: by 10.147.41.10 with HTTP; Sun, 18 Sep 2011 17:24:49 -0700 (PDT) In-Reply-To: <4E7685DE.6010805@sugarcrm.com> References: <4E74E5A0.2030006@sugarcrm.com> <4E76320F.6010904@sugarcrm.com> <4E764137.9080507@sugarcrm.com> <4E7685DE.6010805@sugarcrm.com> Date: Mon, 19 Sep 2011 02:24:49 +0200 Message-ID: To: Stas Malyshev Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] __constructor parameter limitations. From: pierre.php@gmail.com (Pierre Joye) On Mon, Sep 19, 2011 at 1:59 AM, Stas Malyshev wro= te: > foo() is compatible with foo($a, $b) - since anywhere you can call functi= on > declared as foo($a, $b) you can also successfully call one declared as > foo(), it'd just ignore extra parameters - =A0but it is not allowed (I ga= ve an > example). It was bad when it was a useless E_STRICT, it is much worse whe= n > it's a fatal error. It is not compatible as the two new parameters are not optional. foo($a=3Dnull, $b=3D2) would be compatible. The only difference is that (if we don't fail with the signature checks) warnings will be raised for the missing arguments. But basically the problem is actually the incompatible signature. Take this code: class foo{ function __construct(){} } class bar extends foo{ function__construct($a, $b){} } if (is_a('bar', 'foo')) { $a =3D new bar(); // warnings and maybe unexpected results due to the lack of arguments } to me (and to the OO concepts), they should fail at compile time to avoid any kind of confusions or bad consequences/usage. But I can understand that a fatal error could be seen as too extreme. >> Are you saying that extending a class and making the constructor >> incompatible with the extended class is a good thing to allow and to >> do? If yes then I'd to strongly disagree with this idea as it allows > > I never said anything about constructor being "incompatible" with extende= d > class and it being good thing. I am saying rejecting compatible but not > matching signatures - and I gave example of foo() vs foo($a, $b) - makes = no > sense. And not even with E_STRICT - it's a fatal error now! Given that your example is not compatible, it is then fine to reject them. >> And finally, the reason why abstract differs from the other areas is >> that they are newer. It was decided not to break BC for the other >> cases where we should have done the same. While Marcus wanted to do it >> everywhere, with the same good reasons. > > I guess "all abstracts do that" is better than "abstracts except for ctor= s > do that" but only marginally as both behaviors make little sense to me. > Being restricted to abstracts limits the BC impact (as people could just > remove the abstract keyword and thus avoid trouble relatively easily) but= in > both cases it doesn't look too good. Where is the BC impact with abstract? It was always like that. It happens to affect some newly written codes now but the behaviors is not new. > I'm not sure if we should keep the new BC-breaking error in 5.4 for > consistency sake (I'd felt much easier if we had discussed that before - = or > we did and I just forgot?), but I seriously think we need to rework it in > 5.5 and make all compatible signatures work without complaining. Which BC break fix? afair there is one bug fix Gustavo made which creates bad side effects (about parent not being called or something like that). Etienne was planning to work on that to find a better solution. I don't have the bug # at hand but either Etienne or Gustavo could explain it better, Cheers, --=20 Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org