Skip to content

Commit af02bd8

Browse files
vokuondrejmirtes
authored andcommitted
faster TypeCombinator::compareTypesInUnion()
1 parent 21ac778 commit af02bd8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Type/IntegerRangeType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ public function tryRemove(Type $typeToRemove): ?Type
508508
return new NeverType();
509509
}
510510

511-
if ($typeToRemove instanceof IntegerRangeType || $typeToRemove instanceof ConstantIntegerType) {
512-
if ($typeToRemove instanceof IntegerRangeType) {
511+
if ($typeToRemove instanceof self || $typeToRemove instanceof ConstantIntegerType) {
512+
if ($typeToRemove instanceof self) {
513513
$removeMin = $typeToRemove->min;
514514
$removeMax = $typeToRemove->max;
515515
} else {

src/Type/TypeCombinator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ private static function compareTypesInUnion(Type $a, Type $b): ?array
417417
return [null, $b];
418418
}
419419
}
420+
if ($a instanceof IntegerRangeType && $b instanceof IntegerRangeType) {
421+
return null;
422+
}
420423

421424
if ($a instanceof SubtractableType) {
422425
$typeWithoutSubtractedTypeA = $a->getTypeWithoutSubtractedType();

0 commit comments

Comments
 (0)