Skip to content

Commit 5e15e2e

Browse files
Add integration test
1 parent d81cb77 commit 5e15e2e

File tree

6 files changed

+93
-0
lines changed

6 files changed

+93
-0
lines changed

tests/PHPStan/Levels/LevelsIntegrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static function dataTopics(): array
4141
['arrayDestructuring'],
4242
['listType'],
4343
['missingTypes'],
44+
['arrayOffsetAccess'],
4445
];
4546
if (PHP_VERSION_ID >= 80300) {
4647
$topics[] = ['constantAccesses83'];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"message": "Invalid array key type DateTimeImmutable.",
4+
"line": 17,
5+
"ignorable": true
6+
}
7+
]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[
2+
{
3+
"message": "Expression \"$a[42]\" on a separate line does not do anything.",
4+
"line": 15,
5+
"ignorable": true
6+
},
7+
{
8+
"message": "Expression \"$a[null]\" on a separate line does not do anything.",
9+
"line": 16,
10+
"ignorable": true
11+
},
12+
{
13+
"message": "Expression \"$a[$intOrNull]\" on a separate line does not do anything.",
14+
"line": 18,
15+
"ignorable": true
16+
},
17+
{
18+
"message": "Expression \"$a[$objectOrInt]\" on a separate line does not do anything.",
19+
"line": 19,
20+
"ignorable": true
21+
},
22+
{
23+
"message": "Expression \"$a[$objectOrNull]\" on a separate line does not do anything.",
24+
"line": 20,
25+
"ignorable": true
26+
},
27+
{
28+
"message": "Expression \"$a[$explicitlyMixed]\" on a separate line does not do anything.",
29+
"line": 21,
30+
"ignorable": true
31+
},
32+
{
33+
"message": "Expression \"$a[$implicitlyMixed]\" on a separate line does not do anything.",
34+
"line": 22,
35+
"ignorable": true
36+
}
37+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"message": "Method Levels\\ArrayOffsetAccess\\Foo::test() has parameter $a with no value type specified in iterable type array.",
4+
"line": 7,
5+
"ignorable": true
6+
},
7+
{
8+
"message": "Method Levels\\ArrayOffsetAccess\\Foo::test() has parameter $implicitlyMixed with no type specified.",
9+
"line": 7,
10+
"ignorable": true
11+
}
12+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"message": "Possibly invalid array key type int|object.",
4+
"line": 19,
5+
"ignorable": true
6+
},
7+
{
8+
"message": "Possibly invalid array key type object|null.",
9+
"line": 20,
10+
"ignorable": true
11+
}
12+
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Levels\ArrayOffsetAccess;
4+
5+
class Foo {
6+
/** @return void */
7+
public function test(
8+
array $a,
9+
int|null $intOrNull,
10+
object|int $objectOrInt,
11+
object|null $objectOrNull,
12+
mixed $explicitlyMixed,
13+
$implicitlyMixed,
14+
) {
15+
$a[42];
16+
$a[null];
17+
$a[new \DateTimeImmutable()];
18+
$a[$intOrNull];
19+
$a[$objectOrInt];
20+
$a[$objectOrNull];
21+
$a[$explicitlyMixed];
22+
$a[$implicitlyMixed];
23+
}
24+
}

0 commit comments

Comments
 (0)