mirror of
https://github.com/php/php-src.git
synced 2026-03-26 17:22:15 +01:00
The comparator function used at ksort in SORT_REGULAR mode need to be consistent with basic comparison rules. These rules were changed in PHP-8.0 for numeric strings, but comparator used at ksort kept the old behaviour. It leads to inconsistent situations, when after ksort the first key is GREATER than some of the next ones by according to the basic comparison operators. Closes GH-9293.
18 lines
334 B
PHP
18 lines
334 B
PHP
--TEST--
|
|
GH-9296: incorrect ksort(..., SORT_REGULAR) behaviour on arrays with numeric and string keys
|
|
--FILE--
|
|
<?php
|
|
$array = ["aaa" => 0, 600 => 1];
|
|
ksort($array, SORT_REGULAR);
|
|
var_dump($array);
|
|
var_dump(array_key_first($array) <=> array_key_last($array));
|
|
?>
|
|
--EXPECT--
|
|
array(2) {
|
|
[600]=>
|
|
int(1)
|
|
["aaa"]=>
|
|
int(0)
|
|
}
|
|
int(-1)
|