Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55492 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35042 invoked from network); 17 Sep 2011 21:39:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2011 21:39:44 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; 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:37385] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/69-05466-F93157E4 for ; Sat, 17 Sep 2011 17:39:43 -0400 Received: by qyl16 with SMTP id 16so1379926qyl.8 for ; Sat, 17 Sep 2011 14:39:40 -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=b+1jB1Tb6hKcN5zraoUZMCSIxZhc62CjUVlRPShOgj0=; b=E+6NlZRainPTTJPP1aKZnV6T/6WwY+1dXOrGpEciH/QDa+jS6AAXVF1Mt5XSpY3+og 6M5j3Hs3bxN4d6XkgFohC08Rf3LDUW7aBsI+Ocj70OLH3rWuXTxptb70XjbVBxEAOFT2 50shr+TYDCXItbfaV0wCm0vR3YkswVifHdv6o= Received: by 10.229.91.16 with SMTP id k16mr681937qcm.104.1316295580715; Sat, 17 Sep 2011 14:39:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.53.193 with HTTP; Sat, 17 Sep 2011 14:39:20 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: References: Date: Sat, 17 Sep 2011 22:39:20 +0100 Message-ID: To: Ferenc Kovacs Cc: Nikita Popov , PHP internals 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 17 September 2011 15:52, Ferenc Kovacs wrote: > maybe Richard referring to https://bugs.php.net/bug.php?id=3D55085 ? > but those change only affects the abstract classes. > > Tyrael > > On Sat, Sep 17, 2011 at 3:43 PM, Nikita Popov = wrote: >> Hi Richard! >> >> Which change are you talking about? I just tried doing: >> =C2=A0 =C2=A0> =C2=A0 =C2=A0class A =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { public functio= n __construct($a) =C2=A0 =C2=A0 { } } >> =C2=A0 =C2=A0class B extends A { public function __construct($a, $b) { }= } >> And it worked on 5.4 Beta 1 without errors. >> >> Nikita >> >> On Sat, Sep 17, 2011 at 3:27 PM, Richard Quadling = wrote: >>> Hi. >>> >>> With the recent BC with regard the locking of the constructor's >>> signature for subclasses, what is the expected mechanism for allowing >>> a subclass to have additional parameters? >>> >>> You can always supply them and use func_get_args() / func_num_args() / >>> etc. to read them. >>> >>> It would seem that the limitation restricts the capabilities. I'm not >>> a purist. Software development is a compromise between purity and >>> getting the job done in an efficient and understandable manner. >>> >>> By allowing undocumented parameters to the constructor (due to the >>> enforced signature), this would seem to break things on a different >>> front (I can't docblock non defined parameters for examples). My question was due to the documentation commit http://news.php.net/php.doc.cvs/8818 and http://news.php.net/php.doc.cvs/8819. Not being an expert, so I don't know all the theory, but it would seem an abstract class defines the idea and the concrete class defines it more - I need a better grasp of words here. An interface is the absolute here. Sub classes (the super class being abstract or otherwise), should be able to define MORE parameters (with or without default values). Otherwise they aren't extending, but implementing - and for me that's the role of an interface. It is only interfaces that guarantee things because the interface IS the guarantee. A class isn't beholden to anything it inherits. You can override methods, completely obscuring the super class if you so want. A subclass can completely divorce itself from the superclass. But not with an interface. PHP has always been a very very flexible language. I feel that if a developer absolutely must enforce a method's signature, then an interface is going to do that 100% and is a relatively easy way to do things. Enforcing method signatures in subclasses (I don't know why abstract classes are treated differently) does sort of make the interface redundant. Unless there is a real issue with the internal engine, then the method signatures should be flexible. Unless an interface is used. Richard. --=20 Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea