Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55535 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50680 invoked from network); 19 Sep 2011 09:51:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2011 09:51:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:56274] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/4B-14600-790177E4 for ; Mon, 19 Sep 2011 05:51:20 -0400 Received: by qyl16 with SMTP id 16so2197487qyl.8 for ; Mon, 19 Sep 2011 02:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=FTn4652VhR5w47MY17kO1DKwZBzw1jwa0oPVKUZ0+0o=; b=b5MSrveV59jQ1z4IosYs/2+m+CpfflCrDlUsfi6wq11pkR88lv0u1u5hcYIvHQyczB DgAnlGhiSx4ieh+A4fPRHwpilkY8io/LgVDbPU8Iz4HE8aOCRtQDvCdkp4jjZiy1gbix JHMUaZW6Yp+flvD7PYwPtY+gzET1zC3kDsC24= Received: by 10.229.190.129 with SMTP id di1mr1826996qcb.142.1316425877122; Mon, 19 Sep 2011 02:51:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.53.193 with HTTP; Mon, 19 Sep 2011 02:50:57 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: References: <4E74E5A0.2030006@sugarcrm.com> <4E76320F.6010904@sugarcrm.com> <4E764137.9080507@sugarcrm.com> <4E7685DE.6010805@sugarcrm.com> <4E768C86.3030307@sugarcrm.com> <4E769418.6040200@sugarcrm.com> <4E76CD67.2020700@thelounge.net> <4E77080E.7030107@mageekbox.net> Date: Mon, 19 Sep 2011 10:50:57 +0100 Message-ID: To: Etienne Kneuss Cc: frederic.hardy@mageekbox.net, internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] __constructor parameter limitations. From: rquadling@gmail.com (Richard Quadling) On 19 September 2011 10:17, Etienne Kneuss wrote: > Hi, > > 2011/9/19 Fr=C3=A9d=C3=A9ric Hardy > >> Hi ! >> >> What is the utility of abstract method if implementation can not follow >> the signature (constraints ?) of the abstract method ? >> > In this case, abstract methods are totaly useless ! >> Moreover, i think that it's not compatible with Liskov substitution >> principle. > Subclasses can loosen the preconditions, that's eactly what happens here = and > it is perfectly fine in theory. WOW. I really didn't expect this as a response to what, for me, was quite an innocent question. Normally I get a 3 comments pointing me in the right direction and I'm happy. Maybe its me. But something that is abstract certain implies to me a loose idea. The keywords have inherent meaning. At least in English. If a class, abstract or otherwise, has the requirement to have an enforced parameter list for a method, then would seem to be the role of an interface. An abstract class and an method declared in an interface, both require implementation. But with an interface, you are not able to change the parameters. would seem to satisfy LSP. Unless you use an interface to enforce the parameter order, how else do you guarantee the contract? If you also enforce the parameters for other methods (abstract or otherwise - I'm still not 100% on the reason for the difference - or, at this stage, if there even is a difference), then interfaces are seemingly redundant. Take the following code ... The signatures here feel completely right, though MAYBE one could argue that SuperCrete's constructor is off because $c is not optional. I don't think $a and $b can ever become optional or missing from any sub-class' definition. As things stand, 5.4.0-beta doesn't report any problem with this code. Have I made a mountain out of a mole hill? (http://en.wikipedia.org/wiki/Make_a_mountain_out_of_a_molehill for those who don't know the English idiom). --=20 Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea