On Fri, Oct 10, 2014 at 1:34 PM, Andrea Faulds <a...@ajf.me> wrote:

>
> On 10 Oct 2014, at 21:27, Marco Pivetta <ocram...@gmail.com> 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/292421d3a1fcefe88c3017ffdb9f889c39a6c8c1/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`.
> >
> > 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:
>
> “Easily” achieved? No. This would break an awful, awful lot of existing
> PHP code with no gain. There’s 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/
>
>
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Agreed.  The call_user_func() and call_user_func_array() functions are used
all over the place.  I see absolutely no gain, whatsoever in removing them
and forcing developers to write their own userland variants instead.

--Kris

Reply via email to