Skip to content

Commit 09ae197

Browse files
committed
Use IntegerRangeType::fromInterval() instead of new
1 parent e301f6d commit 09ae197

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Type/Php/FilterVarDynamicReturnTypeExtension.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ public function getTypeFromFunctionCall(
165165

166166
if (isset($otherTypes['range'])) {
167167
if ($type instanceof ConstantScalarType) {
168-
if ($type->getValue() < $otherTypes['range']->getMin()
169-
|| $type->getValue() > $otherTypes['range']->getMax()
170-
) {
168+
if ($otherTypes['range']->isSuperTypeOf($type)->no()) {
171169
$type = $otherTypes['default'];
172170
}
173171

@@ -209,7 +207,7 @@ private function determineExactType(Type $in, int $filterValue): ?Type
209207

210208
/**
211209
* @param list<string> $typeOptionNames
212-
* @return array{default: Type, range?: IntegerRangeType}
210+
* @return array{default: Type, range?: Type}
213211
*/
214212
private function getOtherTypes(?Node\Arg $flagsArg, Scope $scope, array $typeOptionNames): array
215213
{
@@ -246,7 +244,7 @@ private function getOtherTypes(?Node\Arg $flagsArg, Scope $scope, array $typeOpt
246244
if (isset($range['min']) || isset($range['max'])) {
247245
$min = isset($range['min']) && is_int($range['min']) ? $range['min'] : null;
248246
$max = isset($range['max']) && is_int($range['max']) ? $range['max'] : null;
249-
$otherTypes['range'] = new IntegerRangeType($min, $max);
247+
$otherTypes['range'] = IntegerRangeType::fromInterval($min, $max);
250248
}
251249

252250
return $otherTypes;

0 commit comments

Comments
 (0)