Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55482 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96130 invoked from network); 17 Sep 2011 15:20:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2011 15:20:42 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.177 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.216.177 mail-qy0-f177.google.com Received: from [209.85.216.177] ([209.85.216.177:63885] helo=mail-qy0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/04-05466-9CAB47E4 for ; Sat, 17 Sep 2011 11:20:41 -0400 Received: by qyk31 with SMTP id 31so4726626qyk.8 for ; Sat, 17 Sep 2011 08:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=fFxhMCn6x6vjalBJ1NPGfZba6/czT5XcpbmpI2D+Ks8=; b=F7PdELkzGgqEA75sbfahhCUEn/4O7PLXypQFMp06kOtjhT8wAqs+Sfpu2Akb/MGvVW Rj9gwV17e9/IfEbuNI4Am+Md1BEwRQWUFIdktJC5Fy8o8eiwqHLQIP2yRUzcCNBz5pm9 g4Wdmk94LdnBcVJU46GZSwxbGEunbLowQIWy8= Received: by 10.52.35.112 with SMTP id g16mr555807vdj.24.1316272837064; Sat, 17 Sep 2011 08:20:37 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.94.142 with HTTP; Sat, 17 Sep 2011 08:20:17 -0700 (PDT) In-Reply-To: References: Date: Sat, 17 Sep 2011 23:20:17 +0800 X-Google-Sender-Auth: 0zqJg3e64eMwUoGtAI-OJ2925K0 Message-ID: To: Etienne Kneuss Cc: devis@lucato.it, internals@lists.php.net, RQuadling@gmail.com, Nikita Popov Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] __constructor parameter limitations. From: laruence@php.net (Laruence) 2011/9/17 Etienne Kneuss : > > > On Sat, Sep 17, 2011 at 17:08, Laruence wrote: >> >> 2011/9/17 =C2=A0: >> > Hi, >> > >> > I think Richards intended other methods often used in combination with >> > __construct: >> > >> > class A =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { public function init($a, = $b) { } } >> > class B extends A { public function init($a) { } } >> > >> > =3D> PHP Strict Standards: =C2=A0Declaration of B::init() should be co= mpatible >> > with >> > that of A::init() >> =C2=A0do you know any reason for this? > > The reason for this is simply that B must act like A since every B object= is > also an object of A. sure, but why we need interface? in addition, I don't think this can be done by restricting the argument thanks > >> >> > >> > The example with __construct() is valid (at least in 5.3). >> > >> > >> > Devis >> > >> > >> > On 17 September 2011 14:43, 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 func= tion __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 allowi= ng >> >> > 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 n= ot >> >> > 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). >> >> >> >> -- >> >> PHP Internals - PHP Runtime Development Mailing List >> >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> >> >> >> > >> >> >> >> -- >> Laruence =C2=A0Xinchen Hui >> http://www.laruence.com/ >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > > > -- > Etienne Kneuss > http://www.colder.ch > --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/