From a68a0fb82bef69ff050c608baa0360944a983497 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 16 Jan 2026 15:29:41 +0100 Subject: [PATCH] TypeCombinator: filter NeverType out earlier --- src/Type/Accessory/NonEmptyArrayType.php | 4 ---- src/Type/TypeCombinator.php | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Type/Accessory/NonEmptyArrayType.php b/src/Type/Accessory/NonEmptyArrayType.php index 3015e948ce..2718af8a53 100644 --- a/src/Type/Accessory/NonEmptyArrayType.php +++ b/src/Type/Accessory/NonEmptyArrayType.php @@ -76,10 +76,6 @@ public function getConstantStrings(): array public function accepts(Type $type, bool $strictTypes): AcceptsResult { - if ($type instanceof CompoundType) { - return $type->isAcceptedBy($this, $strictTypes); - } - $isArray = $type->isArray(); $isIterableAtLeastOnce = $type->isIterableAtLeastOnce(); diff --git a/src/Type/TypeCombinator.php b/src/Type/TypeCombinator.php index b5db780c34..45a3596560 100644 --- a/src/Type/TypeCombinator.php +++ b/src/Type/TypeCombinator.php @@ -1150,11 +1150,17 @@ public static function intersect(Type ...$types): Type $slice1 = array_slice($types, 0, $i); $slice2 = array_slice($types, $i + 1); foreach ($innerTypes as $innerUnionSubType) { - $topLevelUnionSubTypes[] = self::intersect( + $intersected = self::intersect( $innerUnionSubType, ...$slice1, ...$slice2, ); + + if ($intersected instanceof NeverType) { + continue; + } + + $topLevelUnionSubTypes[] = $intersected; } $union = self::union(...$topLevelUnionSubTypes);