Skip to content

Commit 298261c

Browse files
committed
Simplify range limit conditionals
1 parent c742c79 commit 298261c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/Analyser/TypeSpecifier.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,15 +1102,9 @@ private function specifyTypesForCountFuncCall(
11021102
if (
11031103
$sizeType instanceof IntegerRangeType
11041104
&& $sizeType->getMin() !== null
1105-
&& $sizeType->getMin() <= ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT
1105+
&& ($sizeType->getMax() ?? $sizeType->getMin()) <= ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT
11061106
&& $arrayType->getKeyType()->isSuperTypeOf(IntegerRangeType::fromInterval(0, $sizeType->getMin() - 1))->yes()
1107-
&& (
1108-
$sizeType->getMax() === null
1109-
|| (
1110-
$sizeType->getMax() <= ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT
1111-
&& $arrayType->getKeyType()->isSuperTypeOf(IntegerRangeType::fromInterval(0, $sizeType->getMax() - 1))->yes()
1112-
)
1113-
)
1107+
&& ($sizeType->getMax() === null || $arrayType->getKeyType()->isSuperTypeOf(IntegerRangeType::fromInterval(0, $sizeType->getMax() - 1))->yes())
11141108
) {
11151109
// turn optional offsets non-optional
11161110
$valueTypesBuilder = ConstantArrayTypeBuilder::createEmpty();

0 commit comments

Comments
 (0)