Nette\Utils\Callback doesn't pass by reference in 5.6

Notice: This thread is very old.
jiri.pudil
Nette Blogger | 1029
+
0
-

PHP 5.6 emits the “Parameter expected to be a reference, value given” warning when a callable proxied with Nette\Utils\Callback expects a reference. I ran into this issue when Cache::load is passed a fallback expecting the cache dependencies. Here goes a minimal code to reproduce:

$ composer require nette/utils:~2.2
$foo = 42;
function foo(&$foo) {}

$cb = Nette\Utils\Callback::closure('foo');
call_user_func_array($cb, [&$foo]);
Warning: Parameter 1 to foo() expected to be a reference, value given in .../vendor/nette/utils/src/Utils/Callback.php on line 38

The code works fine on 5.5 and I couldn't find any relevant notes in PHP changelog nor docs, thus I'm not sure if this is something Nette should address or if it is just a good old PHP bug. I'd like to get your opinions on this before reporting.

PHP 5.6.3, OS X 10.10.1

David Grudl
Nette Core | 8218
+
0
-

Affected versions: 5.5.6–5.5.7, 5.6.0–5.6.4. See https://bugs.php.net/bug.php?…

David Grudl
Nette Core | 8218
+
0
-

It seems that it did not work in any PHP version, in “affected” versions it only triggers warning.

hrach
Member | 1838
+
0
-

It seems they are not going to fix this, do they? So, it's 5.6.0-*.

jiri.pudil
Nette Blogger | 1029
+
0
-

Thanks!

David Grudl
Nette Core | 8218
+
0
-

Alternative fix for PHP > 5.3 https://github.com/…e8c470c85793