Skip to content

Commit 4566b0b

Browse files
zonuexestaabm
authored andcommitted
Drop the constant checks that the combination count already covers
getConstantScalarTypes() returns nothing for a type that is only partly a constant, so such an argument leaves no combination, and a non-zero number of combinations already means that every argument is a constant. The isConstantScalarValue() checks before returning never were therefore always true.
1 parent 2577c9b commit 4566b0b

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

‎src/Type/Php/RangeFunctionReturnTypeExtension.php‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,9 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
149149
return TypeCombinator::union(...$constantReturnTypes);
150150
}
151151

152-
// nothing is returned when every combination of the constant arguments throws
153-
if (
154-
$constantCombinations > 0
155-
&& $throwingCombinations === $constantCombinations
156-
&& $startType->isConstantScalarValue()->yes()
157-
&& $endType->isConstantScalarValue()->yes()
158-
&& $stepType->isConstantScalarValue()->yes()
159-
) {
152+
// nothing is returned when every combination of the constant arguments throws; an argument
153+
// that is only partly a constant has no constant scalar types, so it leaves no combination
154+
if ($constantCombinations > 0 && $throwingCombinations === $constantCombinations) {
160155
return new NeverType();
161156
}
162157
}

0 commit comments

Comments
 (0)