Automatic Index In Non Empty Array

When starting from an array whose maximum key is integer and negative, PHP used to continue assigning indices with 0, instead of the following negative number. It is fixed in PHP 8.0.

PHP code

<?php

$array = [
    -10 => 'a',
];
$array[] = 'b';

print_r($array);

?>

Before

Array
(
    [-10] => a
    [0] => b
)

After

Array
(
    [-10] => a
    [-9] => b
)

PHP version change

This behavior changed in 8.0