-
-
Notifications
You must be signed in to change notification settings - Fork 165
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Function URL
https://www.php.net/manual/en/function.array-walk-recursive.php
PHP Version
8.4
Safe Version
3.0.0
Description
Hello,
I noticed that passing argument by reference in array_walk_recursive doesn't work correctly with PHP 8.4 (like it worked with PHP 8.3).
Example:
$data = [
['foo', 'far'],
['bar', 'baz'],
];
array_walk_recursive($data, static function (&$item) {
$item = 111;
});
var_dump($data); // it's still original [['foo', 'far'], ['bar', 'baz']]
# using native PHP array_walk_recursive directly gives expected [[111, 111], [111, 111]] overwritten by reference valuesThe reason is probably because different way of wrapping it between PHP versions:
# /generated/8.3/array.php
function array_walk_recursive(&$array, callable $callback, $arg = null): void
{
error_clear_last();
if ($arg !== null) {
$safeResult = \array_walk_recursive($array, $callback, $arg);
} else {
$safeResult = \array_walk_recursive($array, $callback);
}
if ($safeResult === false) {
throw ArrayException::createFromPhpError();
}
}
# /generated/8.4/array.php
function array_walk_recursive()
{
return \array_walk_recursive(...func_get_args());
}Using func_get_args() probably doesn't handle reference as expected, so other wrapped functions in this way may be also affected.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working