Bug #70379 [NEW]: call_user_func_array only accepts explicit references
| From: | lolautruche at gmail dot com | Date: | Fri, 28 Aug 2015 09:00:05 +0000 |
| Subject: | Bug #70379 [NEW]: call_user_func_array only accepts explicit references | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-195584@lists.php.net to get a copy of this message | ||
From: lolautruche at gmail dot com
Operating system: OSX
PHP version: 7.0.0RC1
Package: Unknown/Other Function
Bug Type: Bug
Bug description:call_user_func_array only accepts explicit references
Description:
------------
In PHP 7, passing variables assigned by reference to
call_user_func_array() (as part of arguments) now triggers a warning :
"Warning: Parameter 1 to ... expected to be a reference, value given
in..."
It worked fine in PHP 5.6.
Current workaround is to explicitly pass the value by reference (see
code).
Not sure if this is on purpose, but I couldn't find any mention in the
UPGRADING doc about this specifically.
Test script:
---------------
<?php
$foo = function (&$arg) {
var_dump($arg);
};
$a = 'bar';
$b =& $a;
// Warning: Parameter 1 to {closure}() expected to be a reference, value
given in /Users/lolautruche/Desktop/reference.php on line 8
call_user_func_array($foo, [$b]);
// Works fine
call_user_func_array($foo, [&$a]);
Expected result:
----------------
string(3) "bar"
string(3) "bar"
Actual result:
--------------
Warning: Parameter 1 to {closure}() expected to be a reference, value
given in /Users/lolautruche/Desktop/reference.php on line 10
string(3) "bar"
--
Edit bug report at https://bugs.php.net/bug.php?id=70379&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70379&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70379&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70379&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70379&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70379&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70379&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70379&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70379&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70379&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70379&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70379&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70379&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70379&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70379&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70379&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70379&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70379&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70379&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70379&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70379&r=mysqlcfg