Skip to content

Commit 7571bdf

Browse files
Add more cases
1 parent bc59757 commit 7571bdf

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

tests/PHPStan/Levels/data/arrayOffsetAccess.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
class Foo {
66
/**
7+
* @param array|object $arrayOrObject
78
* @param int|null $intOrNull
89
* @param object|int $objectOrInt
910
* @param object|null $objectOrNull
1011
* @param mixed $explicitlyMixed
11-
* @return void
1212
*/
13-
public function test(array $a, $intOrNull, $objectOrInt, $objectOrNull, $explicitlyMixed, $implicitlyMixed)
13+
public function test(array $a, $arrayOrObject, $intOrNull, $objectOrInt, $objectOrNull, $explicitlyMixed, $implicitlyMixed): void
1414
{
1515
$a[42];
1616
$a[null];
@@ -20,5 +20,32 @@ public function test(array $a, $intOrNull, $objectOrInt, $objectOrNull, $explici
2020
$a[$objectOrNull];
2121
$a[$explicitlyMixed];
2222
$a[$implicitlyMixed];
23+
24+
$arrayOrObject[42];
25+
$arrayOrObject[null];
26+
$arrayOrObject[new \DateTimeImmutable()];
27+
$arrayOrObject[$intOrNull];
28+
$arrayOrObject[$objectOrInt];
29+
$arrayOrObject[$objectOrNull];
30+
$arrayOrObject[$explicitlyMixed];
31+
$arrayOrObject[$implicitlyMixed];
32+
33+
$explicitlyMixed[42];
34+
$explicitlyMixed[null];
35+
$explicitlyMixed[new \DateTimeImmutable()];
36+
$explicitlyMixed[$intOrNull];
37+
$explicitlyMixed[$objectOrInt];
38+
$explicitlyMixed[$objectOrNull];
39+
$explicitlyMixed[$explicitlyMixed];
40+
$explicitlyMixed[$implicitlyMixed];
41+
42+
$implicitlyMixed[42];
43+
$implicitlyMixed[null];
44+
$implicitlyMixed[new \DateTimeImmutable()];
45+
$implicitlyMixed[$intOrNull];
46+
$implicitlyMixed[$objectOrInt];
47+
$implicitlyMixed[$objectOrNull];
48+
$implicitlyMixed[$explicitlyMixed];
49+
$implicitlyMixed[$implicitlyMixed];
2350
}
2451
}

0 commit comments

Comments
 (0)