Skip to content

Commit 891baf8

Browse files
Fix RuleLevelHelper
1 parent ae06b48 commit 891baf8

7 files changed

+8
-32
lines changed

src/Rules/RuleLevelHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ private function findTypeToCheckImplementation(
190190
bool $isTopLevel = false,
191191
): FoundTypeResult
192192
{
193-
if (!$this->checkNullables && !$type->isNull()->yes()) {
193+
if (
194+
!$this->checkNullables
195+
&& !$type->isNull()->yes()
196+
&& !$unionTypeCriteriaCallback(new NullType())
197+
) {
194198
$type = TypeCombinator::removeNull($type);
195199
}
196200

tests/PHPStan/Levels/data/arrayOffsetAccess-10-missing.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[
22
{
33
"message": "Method Levels\\ArrayOffsetAccess\\Foo::test() has parameter $a with no value type specified in iterable type array.",
4-
"line": 7,
4+
"line": 13,
55
"ignorable": true
66
},
77
{
88
"message": "Method Levels\\ArrayOffsetAccess\\Foo::test() has parameter $implicitlyMixed with no type specified.",
9-
"line": 7,
9+
"line": 13,
1010
"ignorable": true
1111
}
1212
]

tests/PHPStan/Levels/data/arrayOffsetAccess-7.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"ignorable": true
66
},
77
{
8-
"message": "Invalid array key type object.",
8+
"message": "Possibly invalid array key type object|null.",
99
"line": 20,
1010
"ignorable": true
1111
}

tests/PHPStan/Levels/data/arrayOffsetAccess-8-missing.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/PHPStan/Levels/data/arrayOffsetAccess-8.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/PHPStan/Levels/data/arrayOffsetAccess-9-missing.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)