File tree Expand file tree Collapse file tree 6 files changed +183
-0
lines changed Expand file tree Collapse file tree 6 files changed +183
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ public static function dataTopics(): array
41
41
['arrayDestructuring ' ],
42
42
['listType ' ],
43
43
['missingTypes ' ],
44
+ ['arrayOffsetAccess ' ],
44
45
];
45
46
if (PHP_VERSION_ID >= 80300 ) {
46
47
$ topics [] = ['constantAccesses83 ' ];
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "message" : " Function doFoo not found." ,
4
+ "line" : 20 ,
5
+ "ignorable" : true
6
+ },
7
+ {
8
+ "message" : " Function doFoo not found." ,
9
+ "line" : 27 ,
10
+ "ignorable" : true
11
+ },
12
+ {
13
+ "message" : " Function doFoo not found." ,
14
+ "line" : 31 ,
15
+ "ignorable" : true
16
+ },
17
+ {
18
+ "message" : " Function doFoo not found." ,
19
+ "line" : 38 ,
20
+ "ignorable" : true
21
+ },
22
+ {
23
+ "message" : " Function doFoo not found." ,
24
+ "line" : 48 ,
25
+ "ignorable" : true
26
+ }
27
+ ]
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "message" : " Offset null does not exist on array{}." ,
4
+ "line" : 10 ,
5
+ "ignorable" : true
6
+ },
7
+ {
8
+ "message" : " Invalid array key type DateTimeImmutable." ,
9
+ "line" : 11 ,
10
+ "ignorable" : true
11
+ },
12
+ {
13
+ "message" : " Offset DateTimeImmutable does not exist on array{}." ,
14
+ "line" : 11 ,
15
+ "ignorable" : true
16
+ },
17
+ {
18
+ "message" : " Invalid array key type array." ,
19
+ "line" : 12 ,
20
+ "ignorable" : true
21
+ },
22
+ {
23
+ "message" : " Invalid array key type DateTimeImmutable." ,
24
+ "line" : 35 ,
25
+ "ignorable" : true
26
+ },
27
+ {
28
+ "message" : " Invalid array key type DateTimeImmutable." ,
29
+ "line" : 49 ,
30
+ "ignorable" : true
31
+ },
32
+ {
33
+ "message" : " Invalid array key type DateTimeImmutable." ,
34
+ "line" : 50 ,
35
+ "ignorable" : true
36
+ },
37
+ {
38
+ "message" : " Invalid array key type DateTimeImmutable." ,
39
+ "line" : 51 ,
40
+ "ignorable" : true
41
+ },
42
+ {
43
+ "message" : " Invalid array key type stdClass." ,
44
+ "line" : 51 ,
45
+ "ignorable" : true
46
+ },
47
+ {
48
+ "message" : " Invalid array key type DateTimeImmutable." ,
49
+ "line" : 52 ,
50
+ "ignorable" : true
51
+ }
52
+ ]
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "message" : " Expression \" $a[1]\" on a separate line does not do anything." ,
4
+ "line" : 13 ,
5
+ "ignorable" : true
6
+ },
7
+ {
8
+ "message" : " Expression \" $a[1.0]\" on a separate line does not do anything." ,
9
+ "line" : 14 ,
10
+ "ignorable" : true
11
+ },
12
+ {
13
+ "message" : " Expression \" $a['1']\" on a separate line does not do anything." ,
14
+ "line" : 15 ,
15
+ "ignorable" : true
16
+ },
17
+ {
18
+ "message" : " Expression \" $a[true]\" on a separate line does not do anything." ,
19
+ "line" : 16 ,
20
+ "ignorable" : true
21
+ },
22
+ {
23
+ "message" : " Expression \" $a[false]\" on a separate line does not do anything." ,
24
+ "line" : 17 ,
25
+ "ignorable" : true
26
+ },
27
+ {
28
+ "message" : " Expression \" $a[$stringOrNull]\" on a separate line does not do anything." ,
29
+ "line" : 21 ,
30
+ "ignorable" : true
31
+ },
32
+ {
33
+ "message" : " Expression \" $a[$stringOrObject]\" on a separate line does not do anything." ,
34
+ "line" : 28 ,
35
+ "ignorable" : true
36
+ },
37
+ {
38
+ "message" : " Expression \" $a[$mixed]\" on a separate line does not do anything." ,
39
+ "line" : 45 ,
40
+ "ignorable" : true
41
+ }
42
+ ]
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "message" : " Possibly invalid array key type stdClass|string." ,
4
+ "line" : 28 ,
5
+ "ignorable" : true
6
+ }
7
+ ]
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Levels \ArrayOffsetAccess ;
4
+
5
+ class Foo {
6
+ /** @return void */
7
+ public function test ()
8
+ {
9
+ $ a = [];
10
+ $ foo = $ a [null ];
11
+ $ foo = $ a [new \DateTimeImmutable ()];
12
+ $ a [[]] = $ foo ;
13
+ $ a [1 ];
14
+ $ a [1.0 ];
15
+ $ a ['1 ' ];
16
+ $ a [true ];
17
+ $ a [false ];
18
+
19
+ /** @var string|null $stringOrNull */
20
+ $ stringOrNull = doFoo ();
21
+ $ a [$ stringOrNull ];
22
+
23
+ $ obj = new \SplObjectStorage ();
24
+ $ obj [new \stdClass ()] = 1 ;
25
+
26
+ /** @var string|\stdClass $stringOrObject */
27
+ $ stringOrObject = doFoo ();
28
+ $ a [$ stringOrObject ];
29
+
30
+ $ constantArray = ['a ' => 1 ];
31
+ if (doFoo ()) {
32
+ $ constantArray ['b ' ] = 2 ;
33
+ }
34
+
35
+ $ constantArray [new \DateTimeImmutable ()] = 1 ;
36
+
37
+ /** @var string[] $array */
38
+ $ array = doFoo ();
39
+ foreach ($ array as $ i => $ val ) {
40
+ echo $ array [$ i ];
41
+ }
42
+
43
+ /** @var mixed $mixed */
44
+ $ mixed = null ;
45
+ $ a [$ mixed ];
46
+
47
+ /** @var array<int, array<int, int>> $array */
48
+ $ array = doFoo ();
49
+ $ array [new \DateTimeImmutable ()][5 ];
50
+ $ array [5 ][new \DateTimeImmutable ()];
51
+ $ array [new \stdClass ()][new \DateTimeImmutable ()];
52
+ $ array [new \DateTimeImmutable ()][] = 5 ;
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments