Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77857 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83791 invoked from network); 10 Oct 2014 20:41:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2014 20:41:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.54 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.216.54 mail-qa0-f54.google.com Received: from [209.85.216.54] ([209.85.216.54:62860] helo=mail-qa0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/81-06615-D5448345 for ; Fri, 10 Oct 2014 16:41:02 -0400 Received: by mail-qa0-f54.google.com with SMTP id i13so2190468qae.13 for ; Fri, 10 Oct 2014 13:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=PoloT38Lgy0wUOQlNaP+iES8zCPHj61sDRNia+F1GjM=; b=ECdxydvyJAAwsEFh2tO/Aga+jjYS/GTgSPuViJBQYt87PxPIS6jfAwNueNkQTsOx1z ieXgxJDMJanpcHP/VjTXqy1gSRQaiUfaum8fW8VBaj209n19i113hKGSEUgW3AR7s5Sk fxgMufEkVTrSIvpMilPdoW5lTm0qvfCsJOhKun/K+j7J5FDvzcmCF994hIEzhyDDUvlK WXxlUlOfLUxRmAEoFK4T42HTIL3t6702Q+nLI6FaudXyYTx9CEyuIuuVHr9YyQnd6Hdq CQrFhVL70WAWUtAByidl2FdrnNGTVOme0fZmvBhFOCT32sMdgkP5d/1Z2yLuV66/q15T XPKQ== X-Received: by 10.224.119.197 with SMTP id a5mr12221134qar.104.1412973659256; Fri, 10 Oct 2014 13:40:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.97.139 with HTTP; Fri, 10 Oct 2014 13:40:39 -0700 (PDT) In-Reply-To: <4D642F36-81F2-42DD-876D-78B4B8368214@ajf.me> References: <4D642F36-81F2-42DD-876D-78B4B8368214@ajf.me> Date: Fri, 10 Oct 2014 22:40:39 +0200 Message-ID: To: Andrea Faulds Cc: PHP Internals List Content-Type: multipart/alternative; boundary=001a11c2f2aa097f05050517913e Subject: Re: [PHP-DEV] Deprecation of func_get_args(), call_user_func_array() and related API From: ocramius@gmail.com (Marco Pivetta) --001a11c2f2aa097f05050517913e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10 October 2014 22:34, Andrea Faulds wrote: > > On 10 Oct 2014, at 21:27, Marco Pivetta wrote: > > > While rambling with some code today, I realized that `call_user_func` > > behaves strangely, appearing and disappearing from stack traces dependi= ng > > on versions of PHP. For an example, compare > > http://3v4l.org/fGpIk#vphp7@20140901, http://3v4l.org/fGpIk#v530 and > > http://3v4l.org/fGpIk#vhhvm-301. > > IIRC this is a bug caused by PHP7 eliminating the call to the function > entirely, and instead inserting a normal function call opcode. See: > https://github.com/php/php-src/blob/292421d3a1fcefe88c3017ffdb9f889c39a6c= 8c1/Zend/zend_compile.c#L2777 > > This could possibly be fixed somehow. > Having the stack trace entry there would be enough too. > > Additionally, it seems like `call_user_func` and similars are impacting > > performance in some parts of my codebase (event dispatcher logic). > > In PHP 7, due to the function call removal, it should be just the same, > performance-wise, as a normal function call. > Good to know! And I suppose no additional stack frame is created either? > > Therefore, here comes my idea of simply getting rid of `call_user_func`= , > > `call_user_func_array`, `func_get_args`, `func_num_args` and > `func_get_arg`. > > > > My plan for it would be to add a deprecation (notice? not sure about > that) > > in PHP 5.7, and a complete removal of those methods in PHP 7.0. > > > > BC compatibility is easily achieved as variadics ( > > https://wiki.php.net/rfc/variadics) allow for writing cleaner and less > > complex versions: > > =E2=80=9CEasily=E2=80=9D achieved? No. This would break an awful, awful l= ot of existing > PHP code with no gain. There=E2=80=99s no need to deprecate it any time s= oon. The > variadics syntax is merely a nicer alternative. We should not force peopl= e > to rewrite existing code to use it. There is absolutely no need to get ri= d > of func_get_args. > > I would vote against any such proposal, and I hope others on the list > would join me in doing so. > I'd actually just deprecate any API for which there isn't a use-case anymore, but that's my own vision. As I've already demonstrated, a polyfill already exists and is easy to implement/use too. Exactly like what happened with `register_globals` (which is much harder to find), it would be a small addition at the beginning of you are using. Could you elaborate a bit on this? Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a11c2f2aa097f05050517913e--