Skip to content

Commit f24e1e2

Browse files
committed
Removing mutants.
1 parent 48b0b46 commit f24e1e2

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

‎src/Type/Php/FilterFunctionReturnTypeHelper.php‎

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -394,33 +394,23 @@ private function determineExactType(Type $in, int $filterValue, Type $defaultTyp
394394
}
395395

396396
if ($filterValue === $this->getConstant('FILTER_DEFAULT')) {
397-
$scalarOrNull = new UnionType([
398-
new StringType(),
399-
new FloatType(),
400-
new BooleanType(),
401-
new IntegerType(),
402-
new NullType(),
403-
]);
404-
405-
$scalarOrNullType = $in;
397+
$inputType = $in;
406398
$useDefaultType = false;
407399

408-
if ($scalarOrNull->isSuperTypeOf($in)->maybe()) {
409-
// $in is a union of maybe null, maybe scalar, and a non-scalar.
410-
// Force it to a union of maybe null and maybe scalar.
411-
$scalarOrNullType = TypeCombinator::remove(
412-
TypeCombinator::remove($in, new ObjectShapeType([], [])),
413-
new ArrayType(new MixedType(), new MixedType()),
414-
);
415-
// Combine future results with defaultType as $in might be an array or an object.
400+
if ($inputType->isArray()->maybe()) {
401+
$inputType = TypeCombinator::remove($inputType, new ArrayType(new MixedType(), new MixedType()));
402+
$useDefaultType = true;
403+
}
404+
if ($inputType->isObject()->maybe()) {
405+
$inputType = TypeCombinator::remove($inputType, new ObjectShapeType([], []));
416406
$useDefaultType = true;
417407
}
418408

419409
if ($this->canStringBeSanitized($filterValue, $flagsType)->no()) {
420-
$stringType = $scalarOrNullType->toString();
410+
$stringType = $inputType->toString();
421411
} else {
422412
$stringType = TypeCombinator::union(
423-
TypeCombinator::remove($scalarOrNullType, new StringType()),
413+
TypeCombinator::remove($inputType, new StringType()),
424414
new StringType(),
425415
);
426416
}

0 commit comments

Comments
 (0)