|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-10-04 01:10 UTC] yohgaki@php.net
Description: ------------ As you can see, newer PHPs have additional errors with call_user_func(). https://3v4l.org/oBnkT Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 10 Warning: Parameter 1 to foo() expected to be a reference, value given in /in/oBnkT on line 11 I found this errors from Wordpress installation. https://wordpress.org/support/topic/wp-4-6-1-got-error-with-php-7-1/ PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
@nikic I agree that errors should be raised for bogus calls like call_user_func('foo', 'abc'); // Literal cannot be reference call_user_func('foo', [$o]); // There is no modifiable value call_user_func('foo', array_slice($a, 0, 1)); // There is no modifiable value when foo() is function foo(&$value) { ... } These call_user_func() calls cannot be pass by reference. I'll update http://php.net/manual/en/function.call-user-func.php and others to document behavior precisely. The issue remained is error on call_user_func('foo', $o); $o could be actual value like $o="abc". (We also should consider functions return reference which should be able to be updated) Could this error be fixed/removed? If not, I'll just document call_user_func() parameter cannot be a reference for any type of variables.> The issue remained is error on > > call_user_func('foo', $o); Just don't use call_user_func; just call the callable directly instead[1], what is possible for ages. It may be useful to document that on the call_user_func() page. The limitation regarding pass by reference is already documented. [1] <https://3v4l.org/NHHQR>