Skip to content

Commit 9b2b519

Browse files
More
1 parent 74b397d commit 9b2b519

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Type/TypeCombinator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function remove(Type $fromType, Type $typeToRemove): Type
6868
}
6969

7070
$isSuperType = $typeToRemove->isSuperTypeOf($fromType);
71-
if ($isSuperType->yes()) {
71+
if ($isSuperType->yes() && !$fromType->isOversizedArray()->yes()) {
7272
return new NeverType();
7373
}
7474
if ($isSuperType->no()) {

tests/PHPStan/Type/TypeCombinatorTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5331,6 +5331,18 @@ public static function dataRemove(): array
53315331
ObjectShapeType::class,
53325332
'object{foo?: int}',
53335333
],
5334+
[
5335+
new IntersectionType([new ArrayType(new StringType(), new StringType()), new OversizedArrayType()]),
5336+
new ConstantArrayType([], []),
5337+
IntersectionType::class,
5338+
'non-empty-array<string, string>&oversized-array',
5339+
],
5340+
[
5341+
new IntersectionType([new ArrayType(new StringType(), new StringType()), new OversizedArrayType()]),
5342+
new ConstantArrayType([new ConstantStringType('A')], [new ConstantStringType('A')]),
5343+
IntersectionType::class,
5344+
'array<string, string>&oversized-array',
5345+
],
53345346
];
53355347
}
53365348

0 commit comments

Comments
 (0)