Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84534 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5423 invoked from network); 11 Mar 2015 09:50:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2015 09:50:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=patrickallaert@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.177 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 74.125.82.177 mail-we0-f177.google.com Received: from [74.125.82.177] ([74.125.82.177:44040] helo=mail-we0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/62-26266-BEF00055 for ; Wed, 11 Mar 2015 04:50:35 -0500 Received: by wesp10 with SMTP id p10so7819751wes.11 for ; Wed, 11 Mar 2015 02:50:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=yyS54pHLMWp7MdO5mhWuVoIZkN5MZe4RA1u8kj+/u0k=; b=LaADHi6Az3NpcrO6mgXUNTfR37+oBb8VU+7Dc8YjXawJhBmJ+qGpfVyOYSEAYBNKQS OlSB28xteAbfmLWokNFnIvtDYpV2STj6nCxx/uzkKAFN2pmZrUV/L4IqDx3ZGCjABa6C Whwm3P6PNCu54nxB8DaKBU2oY1I6325Ddd+6LoA23A44iN8n3qIcdlKKB8EGsm7cm/sC tJt+EuRVx7U5GjWw6m+37SAeUEMMTFoC9drzDeBEkEUOr69px/CHj0GCsF692dhM43MC EEk2E+vPQ4S3BvO1QVB/fiJentmHAgcrJ+HcPTPKHN+lxaceIazp5LyR2aNbDZAB9dH5 9N5A== X-Received: by 10.194.89.195 with SMTP id bq3mr52288350wjb.123.1426067431950; Wed, 11 Mar 2015 02:50:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 11 Mar 2015 09:50:31 +0000 Message-ID: To: marcio3w@gmail.com Cc: PHP internals Content-Type: multipart/alternative; boundary=089e010d833cb5104d0511003259 Subject: Re: [PHP-DEV][RFC][DISCUSSION] Strict Argument Count From: patrickallaert@php.net (Patrick ALLAERT) --089e010d833cb5104d0511003259 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Le mar. 10 mars 2015 =C3=A0 21:04, Marcio Almada a =C3=A9crit : > > > 2015-03-10 12:31 GMT-03:00 Patrick ALLAERT : > >> Hello, >> >> Le lun. 2 mars 2015 =C3=A0 00:03, Marcio Almada = a >> =C3=A9crit : >> >> >> I'm globally +0.5, however I have some concerns: >> >> What about constructors? >> >> Children classes may have a bigger number of arguments for their ctors >> than their parents. Even if not very elegant, it is possible some are >> passing a fixed number of arguments while constructing an object, whethe= r >> that object will take it into account or not. >> >> Something like: >> >> class A { >> function __construct($a) >> } >> >> class B extends A { >> function __construct($a, $b) >> } >> >> $kind =3D $bool ? "A" : "B"; >> >> $object =3D new $kind($foo, $bar); >> > > I think this is somehow covered here > https://wiki.php.net/rfc/strict_argcount#hassle_factor, the example is > not explicit to ctors but the same principles seem to apply. Not sure you > have a deeper point on it though as PHP is a weirdo and allows constructo= rs > on interfaces. > > Also, FYI, before we reach discussion phase, there was an idea to ignore > ctors and other magic methods but you are the first person to bring it up > on the ML. I'm not very inclined to ignore any other magic methods other > than *__call* and *__callStatic* for now. > No deep point, just wanted to bring your attention on it. > > >> E_WARNING: >> -1, IMHO, calling functions/methods with more arguments generally has >> less impact than other aspects that currently generate E_NOTICES (e.g. >> using undefined variables, constants,...). Using an error reporting leve= l >> stronger than for those cases looks inconsistent. >> > > I disagree with the "looks inconsistent" part. The E_WARNING option would > actually be the most consistent with current PHP behavior. Ex: > > function fn($a, $b){} > fn(1); > PHP warning: Missing argument 2 for fn(), called in... > > If we choose E_WARNING both minimum and maximum argument count will have > the same error level. BTW, in some cases an exceeding argument can be eve= n > more dangerous than a missing argument. > You have a (debatable) point :) It depends according to what aspect of PHP your are comparing it with. Greping zend_error(E_NOTICE,.*) in the code I had the feeling that already many notices where the sign of a bigger problem than when passing extra parameters, hence why I suggested E_NOTICE. My consistency argument was therefore "severity based". > I have no strong feelings regarding to the error level, the E_WARNING vs > E_NOTICE seems legit so I'm waiting for more opinions. > I wouldn't -1 for E_WARNING because of your extra arguments (sorry for the pun ;), someone had to do it!). Still in favor of E_NOTICE though. Patrick --089e010d833cb5104d0511003259--