Skip to content

Commit 35af5a4

Browse files
Fix
1 parent 03e629c commit 35af5a4

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Rules/Arrays/NonexistentOffsetInArrayDimFetchCheck.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,12 @@ public function check(
9595
$report = true;
9696
break;
9797
}
98-
if ($dimType instanceof UnionType) {
99-
foreach ($dimType->getTypes() as $subDimType) {
100-
if ($innerType->hasOffsetValueType($subDimType)->no()) {
101-
$report = true;
102-
break 2;
103-
}
104-
}
105-
continue;
98+
if ($dimType instanceof BenevolentUnionType) {
99+
$flattenedInnerTypes = [$dimType];
100+
} else {
101+
$flattenedInnerTypes = TypeUtils::flattenTypes($dimType);
106102
}
107-
foreach (TypeUtils::flattenTypes($dimType) as $innerDimType) {
103+
foreach ($flattenedInnerTypes as $innerDimType) {
108104
if ($innerType->hasOffsetValueType($innerDimType)->no()) {
109105
$report = true;
110106
break 2;

0 commit comments

Comments
 (0)