@@ -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