Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84144 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25205 invoked from network); 2 Mar 2015 06:07:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Mar 2015 06:07:40 -0000 Authentication-Results: pb1.pair.com header.from=marcio.web2@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=marcio.web2@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.169 as permitted sender) X-PHP-List-Original-Sender: marcio.web2@gmail.com X-Host-Fingerprint: 209.85.217.169 mail-lb0-f169.google.com Received: from [209.85.217.169] ([209.85.217.169:33299] helo=mail-lb0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/61-15700-A2EF3F45 for ; Mon, 02 Mar 2015 01:07:39 -0500 Received: by lbdu14 with SMTP id u14so6753937lbd.0 for ; Sun, 01 Mar 2015 22:07:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=DNzSBeiJaXwujY6CE0cb9Nza07RI4cF6Xd8ku2WI7gU=; b=RUYEkww3apPgtAMWkgdVgToV+x0avdfMFrqOBG/Iwq+Uju6QyTlfbG8szbakYDooa2 AOY9cm4OW5TWI/IQZvqHNThSmpVBe4Hmw2rb/ncInzM/Yi+mHP/UD7uQNeCePNQRaFkc hYZoh9BiaUGvP/skQDlT5SbLGARX826zCX/QForHckGnoXcZEyr5lbKsuXbWf0ksmeeD +6PV2tEaG0NPa4FbywNjU1gbtzR+SRk8Cd8GoZBWr/e00vp60dJIgX32HuXfzWt31THF tcOdLqjrHq16axTNBW5CkizWfrP+GOwV2XMyv+VLh3LIMo3bBJ+Nosss7MQFrROiyWAf xuhg== X-Received: by 10.152.178.197 with SMTP id da5mr5510508lac.56.1425276454690; Sun, 01 Mar 2015 22:07:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.118.193 with HTTP; Sun, 1 Mar 2015 22:07:14 -0800 (PST) Reply-To: marcio3w@gmail.com In-Reply-To: References: Date: Mon, 2 Mar 2015 03:07:14 -0300 Message-ID: To: Yasuo Ohgaki Cc: PHP internals Content-Type: multipart/alternative; boundary=001a11340c68c9e429051048082a Subject: Re: [PHP-DEV][RFC][DISCUSSION] Strict Argument Count From: marcio.web2@gmail.com (Marcio Almada) --001a11340c68c9e429051048082a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Yasuo, 2015-03-02 1:43 GMT-03:00 Yasuo Ohgaki : > Hi Marcio, > > On Mon, Mar 2, 2015 at 8:02 AM, Marcio Almada > wrote: > > I like the idea. > > /** fn expects a variable-length argument lists */ > function fn($arg) { > $arg =3D func_get_arg(); > $args =3D func_get_args(); > } > > fn(1); // Ok > fn(...[1, 2, 3, 4, 5]); // Ok > call_user_func_array("fn", [1, 2, 3, 4, 5, 6, 7]); // Ok > > I understand motivation why your patch behave like this. It's for BC, > right? > Yes. If you search github for func_get_arg or func_get_args you wil get around 2,734,673 results. That's a lot. > However, isn't it better to declare variable length parameters by functio= n > signature > in the long run? > > function fn($arg, ...) {} > > Is it possible to have E_DEPRECATED error without "..."? and do not care > about func_get_arg*() existence? Make E_DEPRECATED error E_WARNING > in PHP 7.2 or 7.3. > > I'm not against doing this in a future when PHP v5.5 starts to fade away. But, right now, a lot of code still needs to support PHP 5.5+ with no alternative other than use func_get_args. Remember we only got the dedicated syntax for variadic functions recently on PHP v5.6. I'm afraid it's too soon to deprecate func_get_arg*s() or to overlook it. Maybe in the future somebody will build upon this RFC, specially if it gets approval, and start the deprecation. But at current pace I don't see this as an alternative unless we all reach consensus, which is unlikely. Another point is that internal functions are currently using warnings to signalize wrong argument counts: strlen ("foo", "bar"); // PHP warning: strlen() expects exactly 1 parameter, 2 given on line 1 If the mailing list reach consensus that we should emit deprecation instead, maybe internal functions will need to be updated too. I'm not against it also, but I think it would be too soon for a lot of people here. Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > Thanks, M=C3=A1rcio --001a11340c68c9e429051048082a--