Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55534 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49725 invoked from network); 19 Sep 2011 09:50:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2011 09:50:44 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.170 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.213.170 mail-yx0-f170.google.com Received: from [209.85.213.170] ([209.85.213.170:48731] helo=mail-yx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/0B-14600-170177E4 for ; Mon, 19 Sep 2011 05:50:43 -0400 Received: by yxi13 with SMTP id 13so4662733yxi.29 for ; Mon, 19 Sep 2011 02:50:37 -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=55Hzznn8kHuQ46sYgujtFuEJhyK68zjv59DouPrG6xA=; b=qzRaiiLlOpHHsRXwf5dvDu71Cfxq5QffoVRx0b6uRja3l04iwZyt8Ov4eXY2CoExvA 5qw9jjZfgycPYyBuj6vDlGdwreNqBwPNSX4xQ/Ccd0ObPHhzCFSJY5oy8bWMRGEJ6c5N kBrjkMYwS5QZFGwbaTdWprGWOUM9w+Om9PCJo= MIME-Version: 1.0 Received: by 10.236.177.72 with SMTP id c48mr12255129yhm.79.1316425837643; Mon, 19 Sep 2011 02:50:37 -0700 (PDT) Received: by 10.147.125.13 with HTTP; Mon, 19 Sep 2011 02:50:37 -0700 (PDT) In-Reply-To: References: <4E74E5A0.2030006@sugarcrm.com> <4E76320F.6010904@sugarcrm.com> <4E764137.9080507@sugarcrm.com> <4E7708FA.7080802@sugarcrm.com> Date: Mon, 19 Sep 2011 11:50:37 +0200 Message-ID: To: Gustavo Lopes Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] __constructor parameter limitations. From: tyra3l@gmail.com (Ferenc Kovacs) On Mon, Sep 19, 2011 at 11:32 AM, Gustavo Lopes wr= ote: > Em Mon, 19 Sep 2011 10:18:50 +0100, Stas Malyshev > escreveu: > >> On 9/19/11 2:12 AM, Gustavo Lopes wrote: >>> >>> Arbitrary as it may be, it's nevertheless reasonably arbitrated given h= ow >>> little useful it is to just ignore arguments and how likely it is to a >>> mistake. >> >> It is not little useful and it is not likely to make such mistake withou= t >> immediately being notified and corrected. I don't know how you make thes= e >> assumptions or what they are based on - could you please bring some >> evidence? > > It would obviously be hard to produce such evidence. Measuring how common > a mistake is very difficult without some study to that effect since those > mistakes are steeply underrepresented in the public PHP code corpus (i.e. > they get fixed). And measuring how common overrides with less arguments > are would still require relatively complex code analysis. > > So, no, I cannot prove the assertions behind my argument, I can only say = I > believe them to be plausible. > >>> And I don't buy the func_get_args() argument. Why would anyone use >>> func_get_args for anything other than variadic functions?... I certainl= y >>> don't. >> >> So you say if you personally don't use something in PHP nobody should us= e >> it? >> And, BTW, what's wrong with variadic functions (i.e., ones accepting >> variable number of arguments)? Such functions are commonplace in PHP. > > The thing if you introduce func_get_args() to the argument, any discussio= n > about enforcing signatures becomes meaningless. One could argue this > should be allowed: > > class A { > function foo() {} > } > > class B extends A { > function foo($a) {} > } > > Because for all we know the implementation of A::foo() could have: > > function foo() { > =C2=A0 =C2=A0 =C2=A0 =C2=A0$a =3D func_get_args()[0]; > } yeah, but you can't know from the method signature that there is, or isn't any place, where the parent method is called without arguments, but your class would be incompatible there. You aren't supposed to know at all time that what does the Superclass class/method internally or how is it used at all time(where it is called, with how many arguments, etc), but you get a guarantee that all call for that method has to be compatible with it's method signature, so as long as your method signature also compatible with it, you should be fine to change it. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu