Skip to content

Commit bfa881c

Browse files
committed
IntersectionType::toPhpDocNode - check empty types
1 parent 0c6d698 commit bfa881c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/Type/IntersectionType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,10 @@ public function toPhpDocNode(): TypeNode
18771877
return $describedTypes[0];
18781878
}
18791879

1880+
if (count($describedTypes) === 0) {
1881+
throw new ShouldNotHappenException(sprintf('Intersection consists of %s but there should be at least one base type.', implode('&', array_map(static fn (Type $type) => $type->describe(VerbosityLevel::precise()), $this->types))));
1882+
}
1883+
18801884
return new IntersectionTypeNode($describedTypes);
18811885
}
18821886

0 commit comments

Comments
 (0)