Req #68475 [Asn]: call_user_func($a) not equivalent to $a()

From: Date: Fri, 09 Jan 2015 11:47:04 +0000
Subject: Req #68475 [Asn]: call_user_func($a) not equivalent to $a()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189832@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68475&edit=1

 ID:                 68475
 Updated by:         jpauli@php.net
 Reported by:        nicolas dot grekas+php at gmail dot com
 Summary:            call_user_func($a) not equivalent to $a()
 Status:             Assigned
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 PHP Version:        5.6.3
 Assigned To:        jpauli
 Block user comment: N
 Private report:     N

 New Comment:

I don't think we need to RFC that.
What we want, is uniformisation and consistency in the way we can call a PHP function from a PHP
string.
No new idea, no debatte, no RFC needed.


Previous Comments:
------------------------------------------------------------------------
[2015-01-08 20:16:32] aharvey@php.net

I might prefer unifying the VM code with the code call_user_func() and friends use: something like
https://github.com/LawnGnome/php-src/compare/call-static-methods?expand=1
(albeit I think we'd want to refactor the critical code path out of
zend_is_callable_check_func() into a separate function to minimise the overhead). Having two sources
of truth for what a string callable can look like is what got us in this mess. :)

Whatever the approach, let's do this in PHP 7. Julien, do you want to write the RFC, or shall
I?

------------------------------------------------------------------------
[2014-12-16 13:19:24] jpauli@php.net

I agree that for consistency, this should be supported

------------------------------------------------------------------------
[2014-12-14 15:19:23] nicolas dot grekas+php at gmail dot com

You can't say "just use the standard ['Class', 'method'] callback
style"; there are of code out there that use the 'Class::method' style, you
can't ignore it. This is where the blocker is: BC

------------------------------------------------------------------------
[2014-12-04 19:37:15] nikic@php.net

I don't get why this is a blocker for anything. Why not just use the standard
['Class', 'method'] callback style?

Imho the 'Class::method' style is just unnecessary duplication and should be removed in
the future, rather than implemented in more places.

------------------------------------------------------------------------
[2014-12-04 11:03:44] stof at notk dot org

> This behavior was never supported in PHP5, so it's not a bug but a feature request. I
> think, such change may be accepted in PHP7 (no way for php-5.6).

Well, "foo::bar" callables are supported by PHP in all places except the $a() syntax:

- is_callable is returning true for them
- the callable typehint accepts them
- call_user_func and call_user_func_array accept them.

So this means that callables in PHP still cannot be called directly. PHP 5.4 only expanded the
support for direct call, but it is still incomplete.

So this makes it a blocker for deprecating the call_user_func functions altogether, as they are
still the only reliable way to call a generic callable.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=68475


--
Edit this bug report at https://bugs.php.net/bug.php?id=68475&edit=1


Thread (15 messages)

« previous php.bugs (#189832) next »