Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77854 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78851 invoked from network); 10 Oct 2014 20:28:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2014 20:28:28 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.53 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.216.53 mail-qa0-f53.google.com Received: from [209.85.216.53] ([209.85.216.53:51325] helo=mail-qa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/60-06615-66148345 for ; Fri, 10 Oct 2014 16:28:22 -0400 Received: by mail-qa0-f53.google.com with SMTP id v10so2192761qac.12 for ; Fri, 10 Oct 2014 13:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=BnXJ2IyrtO+TxlyC3s/gj2vTu08BeJ7DBtmXKCP7840=; b=vbfbjLr7hu4jN0h3OZuy7LTwXYV238Uf6WmGWEl3TZ+MdYtG4rBFE9r9MHseqj8pjO /pf/1jg/NttuTXRqHBbK2IuvTLSJlViwjcThRaqPL38Dq6NVEGxgVfyCjv0a/MdO3TyC 2FBZeqZXgIPx++Di+shcRcJOD0bUjAnHqAdhevycs+/z7SBmUuyzOEiGDrisAQlFR79w Yu7hsYFgc2VN9zZAcrcVa3eWdFxY9gSI14Y8QjUWJUFz3nU/a8gYEbLqOFLiaq7rYqG2 wbXXejUndoge3q7yF8E6SckfJbpm0s+bNPaj5HC4oWbiBcZyKvNzzcjxdjogP9jV70LT KAyQ== X-Received: by 10.224.119.197 with SMTP id a5mr12113170qar.104.1412972899955; Fri, 10 Oct 2014 13:28:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.97.139 with HTTP; Fri, 10 Oct 2014 13:27:59 -0700 (PDT) Date: Fri, 10 Oct 2014 22:27:59 +0200 Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary=001a11c2f2aac77cd105051763d6 Subject: Deprecation of func_get_args(), call_user_func_array() and related API From: ocramius@gmail.com (Marco Pivetta) --001a11c2f2aac77cd105051763d6 Content-Type: text/plain; charset=UTF-8 Hello folks, 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. This makes debugging code quite complicated if not just annoying and frustrating. Additionally, it seems like `call_user_func` and similars are impacting performance in some parts of my codebase (event dispatcher logic). 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: - http://3v4l.org/HDQb6 (call_user_func) - http://3v4l.org/AgEG5 (call_user_func_array) - http://3v4l.org/O3G6T (func_get_args) (broken in HHVM) - http://3v4l.org/vcYso (func_get_arg) (broken in HHVM) - http://3v4l.org/cg8i0 (func_num_args) (broken in HHVM) Those files could moved to a library and included when running on legacy codebases. Eventually, grepping for those function calls is also trivial. Here's also the example with the exception and the userland implementation of `call_user_func`, which has a much more readable/clear/inspectable stack trace: http://3v4l.org/i4G8c Thoughts? If this idea gets enough traction, I'd gladly go and ask for karma, open an RFC and eventually provide a patch if I'm able to. Greets, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a11c2f2aac77cd105051763d6--