1
0
mirror of https://github.com/php/php-src.git synced 2026-03-25 08:42:29 +01:00
Files
archived-php-src/ext/standard/tests/array/bug52719.phpt
Nikita Popov dadb92ea35 Don't allow separation in array functions
The only case here that might be *somewhat* sensible is the userdata
argument of array_walk(), which could be used to keep persistent state
between callback invokations -- with the WTF moment that the final
result after the walk finishes will be unchanged. Nowdays, this is
much better achieved using a closure with a use-by-reference.
2020-07-07 09:15:43 +02:00

19 lines
512 B
PHP

--TEST--
Bug #52719: array_walk_recursive crashes if third param of the function is by reference
--FILE--
<?php
$array = array("hello", array("world"));
$userdata = array();
array_walk_recursive(
$array,
function ($value, $key, &$userdata) { },
$userdata
);
echo "Done";
?>
--EXPECTF--
Warning: {closure}(): Argument #3 ($userdata) must be passed by reference, value given in %s on line %d
Warning: {closure}(): Argument #3 ($userdata) must be passed by reference, value given in %s on line %d
Done