Skip to content

Commit a68a0fb

Browse files
committed
TypeCombinator: filter NeverType out earlier
1 parent 58c418b commit a68a0fb

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/Type/Accessory/NonEmptyArrayType.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ public function getConstantStrings(): array
7676

7777
public function accepts(Type $type, bool $strictTypes): AcceptsResult
7878
{
79-
if ($type instanceof CompoundType) {
80-
return $type->isAcceptedBy($this, $strictTypes);
81-
}
82-
8379
$isArray = $type->isArray();
8480
$isIterableAtLeastOnce = $type->isIterableAtLeastOnce();
8581

src/Type/TypeCombinator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,11 +1150,17 @@ public static function intersect(Type ...$types): Type
11501150
$slice1 = array_slice($types, 0, $i);
11511151
$slice2 = array_slice($types, $i + 1);
11521152
foreach ($innerTypes as $innerUnionSubType) {
1153-
$topLevelUnionSubTypes[] = self::intersect(
1153+
$intersected = self::intersect(
11541154
$innerUnionSubType,
11551155
...$slice1,
11561156
...$slice2,
11571157
);
1158+
1159+
if ($intersected instanceof NeverType) {
1160+
continue;
1161+
}
1162+
1163+
$topLevelUnionSubTypes[] = $intersected;
11581164
}
11591165

11601166
$union = self::union(...$topLevelUnionSubTypes);

0 commit comments

Comments
 (0)