Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55497 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9795 invoked from network); 18 Sep 2011 14:59:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2011 14:59:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.45 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.212.45 mail-vw0-f45.google.com Received: from [209.85.212.45] ([209.85.212.45:61569] helo=mail-vw0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/A2-22692-637067E4 for ; Sun, 18 Sep 2011 10:59:03 -0400 Received: by vws17 with SMTP id 17so9154532vws.32 for ; Sun, 18 Sep 2011 07:58:59 -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=kc0YUuBN6IMdj+kUiAY9T+eY+PCShm6M7AVH9vJa2w4=; b=sq9Tg5qc9LeB68tMExLnIYTR3UMvJOBsepA5JuyCk/qpJoAtycsSq3C67rh3Pygbnd 9ThjZp5/S6qek0Sfu3FNKXoSKVK9G/LVZLUS7Md9Iz34atZ6Kc6e7TP5X2R0+w7RIhVq Lc9198oHs+ziopMnE0UBXeeA0kAoodnQgSvFw= Received: by 10.52.188.195 with SMTP id gc3mr568572vdc.24.1316357939092; Sun, 18 Sep 2011 07:58:59 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.94.142 with HTTP; Sun, 18 Sep 2011 07:58:39 -0700 (PDT) In-Reply-To: <8A2C4A73-0ECA-4EC0-A71D-BD28D1CCEA46@mageekbox.net> References: <8A2C4A73-0ECA-4EC0-A71D-BD28D1CCEA46@mageekbox.net> Date: Sun, 18 Sep 2011 22:58:39 +0800 X-Google-Sender-Auth: ykx8vnH3a_qeV-StvFo3Imvf-AM Message-ID: To: =?UTF-8?B?RnLDqWTDqXJpYyBIYXJkeQ==?= Cc: Pierre Joye , RQuadling@gmail.com, Ferenc Kovacs , Nikita Popov , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] __constructor parameter limitations. From: laruence@php.net (Laruence) Hi: if this change will not revert, I will ask a more clearly error message for this, I report a req, https://bugs.php.net/bug.php?id=3D55719, which is, the error message should told user what the correct argument list is. and also submitted a patch for this req. thanks 2011/9/18 Fr=C3=A9d=C3=A9ric Hardy : > Hi ! > >> For one I do think that enforcing strictness, or as I see it, clean >> code and implementation, should be done in php. We did not do that in >> the past and it has created more issues than anything else in the long >> run. > > +1. > >> One solution to solve the need of having different methods or >> constructors signatures is to support multiple signature per method or >> constructor, as long as the signature of the parent class or interface >> is available. This is something becoming more and more common in other >> languages and is actually very handy. Having such things would have >> also avoided bad (per design while necessary) sutff like the recent >> reflection function to create objects without invoking the >> constructor. > > +1. > The possibility to defined multiple signature per method will be a great = improvement. > > A class like this : > > class foo > { > =C2=A0 =C2=A0 =C2=A0 =C2=A0function barForArray(array $array) {...} > =C2=A0 =C2=A0 =C2=A0 =C2=A0function barForACall(aCall $objectClass) {...} > =C2=A0 =C2=A0 =C2=A0 =C2=A0function barForCallable(Callable $callable) {.= ..} > } > > foreach ($arrayOfUndeterminedThings =C2=A0as $data) > { > =C2=A0 =C2=A0 =C2=A0 =C2=A0switch (true) > =C2=A0 =C2=A0 =C2=A0 =C2=A0{ > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0case is_array($dat= a): > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0$foo->barForArray($data); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0break; > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0case $data instanc= eof aCall: > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0$foo->barForACall($data); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0break; > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0case $data instanc= eof Callable: > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0$foo->barForCallable($data); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0break; > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > } > > will become : > > class foo > { > =C2=A0 =C2=A0 =C2=A0 =C2=A0function bar(array $array) {...} > =C2=A0 =C2=A0 =C2=A0 =C2=A0function bar(aCall $objectClass) {...} > =C2=A0 =C2=A0 =C2=A0 =C2=A0function bar(Callable $callable) {...} > } > > foreach ($arrayOfUndeterminedThings =C2=A0as $data) > { > =C2=A0 =C2=A0 =C2=A0 =C2=A0$foo->bar($data); > } > > Best regards, > Fred > -- > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > Fr=C3=A9d=C3=A9ric Hardy : Architecte d'application/Admin. syst=C3=A8me/E= rgonome > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CV = : http://blog.mageekbox.net/public/cv.frederic.hardy.pdf > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Blog : http= ://blog.mageekbox.net > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Twitter : http://twitter.= com/mageekguy > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/