Arquivos
hhvm/hphp/test/quick/cuf-byref.php
T
Mark Williams 6f4b1c76a8 Fix issue with call_user_func_array and by-ref params
We can't box a non-ref value for a ref param because
we could be modifying an array with refCount != 1.

zend warns, skips the call and returns null. For now, this
makes us warn, but do the call (without modifying the array).

A file scope flag controls whether to skip the call or not,
and should be changed (and eliminated) once all our tests pass.

With the flag turned on, we still dont match zend's behavior,
because its happy to go ahead and call the function with no
warning in the case of a literal array parameter
(cuf('foo', array(1))), even though it warns and skips it when
the array is in a variable ($a=array(1); cuf('foo', $a)).
2013-04-30 09:58:57 -07:00

16 linhas
359 B
PHP

<?php
error_reporting(-1);
function foo(&$a) { var_dump($a++); }
function test($cuf, $f) {
$a = array(1);
$cuf($f, $a);
var_dump($a, array(1));
$cuf($f, array(1));
var_dump($a, array(1));
call_user_func_array($f, $a);
var_dump($a, array(1));
call_user_func_array($f, array(1));
var_dump($a, array(1));
}
test('call_user_func_array', 'foo');