Skip to content

Commit 38c316f

Browse files
Fix RuleLevelHelper
1 parent ae06b48 commit 38c316f

7 files changed

+7
-31
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.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
"line": 7,
1010
"ignorable": true
1111
}
12-
]
12+
]

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)