I'm currently migrating a project from php5.6 to php7.1. Most is going well, but I just hit a wall one one test.
The function usort doesn't have the same behavior on both version, and it doesn't seem to be documented (it's not that two values are equals and then the order is undefined). In my test case, the returned array order is reversed.
Here is a reproduction of the problem. Note that I return -1 all the time for simplification (I'm focusing in the diff between PHP5.6 and 7 here)
Code run on both versions:
$a = [['value' => 1, 'toto' => 'toto'], ['value' => 1, 'toto' => null]];
usort($a, function ($a, $b) { return -1;});
print_r($a);
Results in PHP 5.6:
Array
(
[0] => Array
(
[value] => 1
[toto] =>
)
[1] => Array
(
[value] => 1
[toto] => toto
)
)
PHP 7.1
Array
(
[0] => Array
(
[value] => 1
[toto] => toto
)
[1] => Array
(
[value] => 1
[toto] =>
)
)