Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77855 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80839 invoked from network); 10 Oct 2014 20:34:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2014 20:34:46 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.216 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.216 imap10-3.ox.privateemail.com Received: from [192.64.116.216] ([192.64.116.216:57599] helo=imap10-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/D0-06615-5E248345 for ; Fri, 10 Oct 2014 16:34:46 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 8A0F32400D3; Fri, 10 Oct 2014 16:34:42 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap10.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap10.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id vedGMK2zjPZn; Fri, 10 Oct 2014 16:34:42 -0400 (EDT) Received: from oa-res-26-28.wireless.abdn.ac.uk (oa-res-26-28.wireless.abdn.ac.uk [137.50.26.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 6C0122400D0; Fri, 10 Oct 2014 16:34:41 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Fri, 10 Oct 2014 21:34:37 +0100 Cc: PHP Internals List Content-Transfer-Encoding: quoted-printable Message-ID: <4D642F36-81F2-42DD-876D-78B4B8368214@ajf.me> References: To: Marco Pivetta X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] Deprecation of func_get_args(), call_user_func_array() and related API From: ajf@ajf.me (Andrea Faulds) 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 = depending > 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/292421d3a1fcefe88c3017ffdb9f889c39a6c8= c1/Zend/zend_compile.c#L2777 This could possibly be fixed somehow. > 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. > 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`. >=20 > 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. >=20 > BC compatibility is easily achieved as variadics ( > https://wiki.php.net/rfc/variadics) allow for writing cleaner and less > complex versions: =93Easily=94 achieved? No. This would break an awful, awful lot of = existing PHP code with no gain. There=92s no need to deprecate it any = time soon. The variadics syntax is merely a nicer alternative. We should = not force people to rewrite existing code to use it. There is absolutely = no need to get rid of func_get_args. I would vote against any such proposal, and I hope others on the list = would join me in doing so. -- Andrea Faulds http://ajf.me/