Skip to content

Commit 5156669

Browse files
committed
Adjust for PHP 8 negative array key change
1 parent 2f0881e commit 5156669

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

spec/10-expressions.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -888,9 +888,8 @@ and value of the result is the type and value of that element;
888888
otherwise, the result is `NULL`.
889889

890890
If *expression* is omitted, a new element is inserted. Its key has type
891-
`int` and is one more than the highest, previously assigned, non-negative
892-
`int` key for this array. If this is the first element with a non-negative
893-
`int` key, key `0` is used.
891+
`int` and is one more than the highest, previously assigned `int` key for
892+
this array. If this is the first element with an `int` key, key `0` is used.
894893
If the largest previously assigned `int` key is the largest integer value that can be represented,
895894
the new element is not added.
896895
The result is the added new element, or `NULL` if the element was not added.

tests/expressions/postfix_operators/subscripting_2.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var_dump($a);
1111
echo "------\n";
1212

1313
$a = array(-30 => 33, -10 => -11);
14-
var_dump($a[] = 991); // creates $a[0]
14+
var_dump($a[] = 991); // creates $a[-9]
1515
var_dump($a);
1616
echo "------\n";
1717

@@ -170,7 +170,7 @@ array(3) {
170170
int(33)
171171
[-10]=>
172172
int(-11)
173-
[0]=>
173+
[-9]=>
174174
int(991)
175175
}
176176
------

0 commit comments

Comments
 (0)