Bug #68475 [Com]: call_user_func($a) not equivalent to $a()

From: Date: Tue, 16 Dec 2014 13:19:24 +0000
Subject: Bug #68475 [Com]: call_user_func($a) not equivalent to $a()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189084@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 Comment 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: Bug Package: Scripting Engine problem PHP Version: 5.6.3 Assigned To: jpauli Block user comment: N Private report: N New Comment: I agree that for consistency, this should be supported Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2014-12-01 11:18:27] dmitry@php.net 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). The real "fast" path (when OP2_TYPE == IS_CONST) must not be affected. The implementation is not a problem (I can take care about it), but such change should be approved. I'm not sure if this needs RFC or not (probably better to follow the standard RFC procedure). ------------------------------------------------------------------------ [2014-12-01 07:10:34] nicolas dot grekas+php at gmail dot com This check for double double colons is implemented for the callable type hint. This means that the performance argument is not relevant (since a type hint is checked as often if not more often than a callable is effectivelly called). More importantly, it means that the type hint is useless in the general case, since it gives no guarantee whatsoever when the $callable() syntax is used instead of the call_user_func($callable) one. Last but not least, making $callable() not an equivalent for call_user_func($callable) just because of this case is a blocker for deprecating the former, since there will always be a valid use case for it. Especially since most of the code out there uses call_user_func($callable), because of history. ------------------------------------------------------------------------ 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

« previous php.bugs (#189084) next »