-
Notifications
You must be signed in to change notification settings - Fork 568
Expand file tree
/
Copy pathbug-10862-php83.php
More file actions
59 lines (43 loc) · 888 Bytes
/
bug-10862-php83.php
File metadata and controls
59 lines (43 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php // lint >= 8.3
declare(strict_types = 1);
namespace Bug10862Php83;
use function PHPStan\Testing\assertType;
// PHP 8.3+: negative keys always affect auto-index (both imperative and literal)
// Imperative assignment
function () {
$a = [];
$a[-4] = 1;
$a[] = 2;
assertType('array{-4: 1, -3: 2}', $a);
};
function () {
$a = [];
$a[-1] = 'x';
$a[] = 'y';
assertType("array{-1: 'x', 0: 'y'}", $a);
};
function () {
$a = [];
$a[-10] = 'a';
$a[-5] = 'b';
$a[] = 'c';
assertType("array{-10: 'a', -5: 'b', -4: 'c'}", $a);
};
function () {
$a = [];
$a[-3] = 'a';
$a[5] = 'b';
$a[] = 'c';
assertType("array{-3: 'a', 5: 'b', 6: 'c'}", $a);
};
// Array literal
function () {
$a = [-4 => 1];
$a[] = 2;
assertType('array{-4: 1, -3: 2}', $a);
};
function () {
$a = [-10 => 'a', -5 => 'b'];
$a[] = 'c';
assertType("array{-10: 'a', -5: 'b', -4: 'c'}", $a);
};