Skip to content

Commit 5e8d6b4

Browse files
Try
1 parent 2caa239 commit 5e8d6b4

File tree

7 files changed

+220
-30
lines changed

7 files changed

+220
-30
lines changed

tests/PHPStan/Levels/LevelsIntegrationTest.php

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,45 @@
66
use PHPUnit\Framework\Attributes\Group;
77
use const PHP_VERSION_ID;
88

9-
#[Group('levels')]
9+
//#[Group('levels')]
1010
class LevelsIntegrationTest extends LevelsTestCase
1111
{
1212

1313
public static function dataTopics(): array
1414
{
1515
$topics = [
16-
['returnTypes'],
17-
['acceptTypes'],
18-
['methodCalls'],
19-
['propertyAccesses'],
20-
['constantAccesses'],
21-
['variables'],
22-
['callableCalls'],
23-
['callableVariance'],
24-
['arrayDimFetches'],
25-
['clone'],
26-
['iterable'],
27-
['binaryOps'],
28-
['comparison'],
29-
['throwValues'],
30-
['casts'],
31-
['unreachable'],
32-
['echo_'],
33-
['print_'],
34-
['stringOffsetAccess'],
35-
['object'],
36-
['encapsedString'],
37-
['missingReturn'],
38-
['arrayAccess'],
39-
['typehints'],
40-
['coalesce'],
41-
['arrayDestructuring'],
42-
['listType'],
43-
['missingTypes'],
16+
// ['returnTypes'],
17+
// ['acceptTypes'],
18+
// ['methodCalls'],
19+
// ['propertyAccesses'],
20+
// ['constantAccesses'],
21+
// ['variables'],
22+
// ['callableCalls'],
23+
// ['callableVariance'],
24+
// ['arrayDimFetches'],
25+
// ['clone'],
26+
// ['iterable'],
27+
// ['binaryOps'],
28+
// ['comparison'],
29+
// ['throwValues'],
30+
// ['casts'],
31+
// ['unreachable'],
32+
// ['echo_'],
33+
// ['print_'],
34+
// ['stringOffsetAccess'],
35+
// ['object'],
36+
// ['encapsedString'],
37+
// ['missingReturn'],
38+
// ['arrayAccess'],
39+
// ['typehints'],
40+
// ['coalesce'],
41+
// ['arrayDestructuring'],
42+
// ['listType'],
43+
// ['missingTypes'],
44+
['arrayOffsetAccess'],
4445
];
4546
if (PHP_VERSION_ID >= 80300) {
46-
$topics[] = ['constantAccesses83'];
47+
// $topics[] = ['constantAccesses83'];
4748
}
4849

4950
return $topics;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"message": "Possibly invalid array key type stdClass|string.",
4+
"line": 28,
5+
"ignorable": true
6+
}
7+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"message": "Possibly invalid array key type mixed.",
4+
"line": 45,
5+
"ignorable": true
6+
}
7+
]
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
}

0 commit comments

Comments
 (0)