mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

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.
22 lines
494 B
PHP
22 lines
494 B
PHP
--TEST--
|
|
Fix UMR in array_user_key_compare (MOPB24)
|
|
--FILE--
|
|
<?php
|
|
$arr = array("A" => 1, "B" => 1);
|
|
|
|
function array_compare(&$key1, &$key2)
|
|
{
|
|
$GLOBALS['a'] = &$key2;
|
|
unset($key2);
|
|
return 1;
|
|
}
|
|
|
|
uksort($arr, "array_compare");
|
|
var_dump($a);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Warning: array_compare(): Argument #1 ($key1) must be passed by reference, value given in %s on line %d
|
|
|
|
Warning: array_compare(): Argument #2 ($key2) must be passed by reference, value given in %s on line %d
|
|
string(1) "B"
|