Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83620 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66166 invoked from network); 23 Feb 2015 23:03:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2015 23:03:48 -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.174 as permitted sender) X-PHP-List-Original-Sender: marcio.web2@gmail.com X-Host-Fingerprint: 209.85.217.174 mail-lb0-f174.google.com Received: from [209.85.217.174] ([209.85.217.174:38513] helo=mail-lb0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 15/01-61054-1D1BBE45 for ; Mon, 23 Feb 2015 18:03:46 -0500 Received: by lbiz11 with SMTP id z11so21478621lbi.5 for ; Mon, 23 Feb 2015 15:03:42 -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=98GBpOpQsm0yYqbZHs5uVecpgedrrZr72KtCbsVcoug=; b=YxbQ3uCcxDH1cZhDxu0MgC8q4vFeLYWhBTvkcQDuOqTlVy+fQAeP5Urd/jPEqpL2bC PHFdRP2ilXtnmtqlC6g1IoBVvZaIW+wWBdXnufHKya88MzBrSvwJN4yoC6lZnq2t/Wyv 3aaSSdIxtRZyO0ClbWdcLa/nNcgA47RBrK8/X79htMPww/7diXnUkANT45hVgWinHaQf yPe3FTG/pEqOmeWkHs630BJs4FI3JxRS9EI36fD/965Ab/mz3sayK2m28XpQwgxcYYLG wahohHzUAowxlVj/Djf26yLtAWZOu9kiAUo1FDgw4W8e8USIRdRc/qY2laOXUpyGX2XO BfiQ== X-Received: by 10.112.199.162 with SMTP id jl2mr11798836lbc.48.1424732622189; Mon, 23 Feb 2015 15:03:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.118.193 with HTTP; Mon, 23 Feb 2015 15:03:21 -0800 (PST) Reply-To: marcio3w@gmail.com In-Reply-To: <54EB905C.6030706@mabe.berlin> References: <54EB8043.7050108@mabe.berlin> <54EB905C.6030706@mabe.berlin> Date: Mon, 23 Feb 2015 20:03:21 -0300 Message-ID: To: Marc Bennewitz Cc: PHP internals Content-Type: multipart/alternative; boundary=001a11c38254d87978050fc9691a Subject: Re: [PHP-DEV] Proposal: deprecate undefined passed arguments From: marcio.web2@gmail.com (Marcio Almada) --001a11c38254d87978050fc9691a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, 2015-02-23 17:41 GMT-03:00 Marc Bennewitz : > Hi Marcio > > Wow, nice to see this - didn't noted it before. > > But I have to questions/notes: > 1. Why you throw only a warning and not an error (deprecating this featur= e > first). I don't see the benefit. > Because https://github.com/search?l=3Dphp&q=3Dfunc_get_args&type=3DCode&utf8=3D%E2%= 9C%93 brings 2,031,405 results. All packages made to support PHP 5.5 and below will break. Remember PHP only got variadic functions on v5.6. E_WARNING vs E_DEPRECATED is a debatable topic though. E_DEPRECATED means func_get_args() will be removed some day, while E_WARNING means func_get_args() will not be removed and will stay as an option to explicit variadic fucntions. That's a legit topic to throw on discussion phase IMMO (though we probably already know the result...) 2. As I understand it correctly passing unknown arguments will be allowed > if the function uses one of the func_[get|num]_arg[s]() functions. > > This looks wired to me as the caller should not know the body to know how > a function can be called > and because of the dynamic nature of PHP this check isn't possible in all > cases as you already noted. > Yes, hence why I'm proposing to block dynamic calls to *func_get_args() func_num_arg()* API, see https://wiki.php.net/rfc/strict_argcount#open_issues > > Additionally such strict check is for detecting wrong calls but this > detection doesn't work with code like this: > https://github.com/zendframework/zf2/blob/master/library/Zend/Cache/Stora= ge/Adapter/Memcached.php#L213 > That's a great point! Maybe *func_num_args()* detection shouldn't mark the function as sensitive to dynamic argcount. I only added it for "completeness", but now I see that maybe it was an unnecessary implementation detail. > > In my opinion functions using func_[get|num]_arg[s]() to implement > variadic arguments are totally outdated and should be refactored using ne= w > semantic. I also think such code isn't used very often and deprecating it= + > removing later on (PHP 8) will give more than enough time to update it as > it's simple to find and simple to fix. > > Also to previous example given for ZF2 shows that the function > func_num_args() have it's rights to exit but i'm unsure about > func_get_arg[s](). > > Marc > I agree with you here, but honestly, deprecating *func_get_args()* is not a passable option because people currently still have to support PHP 5.5 and it has no variadic functions. I had this same idea, originally, but then reality bitten and I decided to do the compile time check for the variable-lengh argument list API usage. M=C3=A1rcio Almada. --001a11c38254d87978050fc9691a--