@@ -151,8 +151,9 @@ public function getType(Type $inputType, ?Type $filterType, ?Type $flagsType): T
151151
152152 $ inputIsArray = $ inputType ->isArray ();
153153 $ hasRequireArrayFlag = $ this ->hasFlag ('FILTER_REQUIRE_ARRAY ' , $ flagsType );
154+ $ hasThrowOnFailureFlag = $ this ->hasFlag ('FILTER_THROW_ON_FAILURE ' , $ flagsType );
154155 if ($ inputIsArray ->no () && $ hasRequireArrayFlag ->yes ()) {
155- if ($ this -> hasFlag ( ' FILTER_THROW_ON_FAILURE ' , $ flagsType ) ->yes ()) {
156+ if ($ hasThrowOnFailureFlag ->yes ()) {
156157 return new ErrorType ();
157158 }
158159
@@ -197,9 +198,13 @@ public function getType(Type $inputType, ?Type $filterType, ?Type $flagsType): T
197198 }
198199 }
199200
201+ if ($ hasThrowOnFailureFlag ->yes ()) {
202+ $ type = TypeCombinator::remove ($ type , $ defaultType );
203+ }
204+
200205 if ($ hasRequireArrayFlag ->yes ()) {
201206 $ type = new ArrayType ($ inputArrayKeyType ?? $ mixedType , $ type );
202- if (!$ inputIsArray ->yes ()) {
207+ if (!$ hasThrowOnFailureFlag -> yes () && ! $ inputIsArray ->yes ()) {
203208 $ type = TypeCombinator::union ($ type , $ defaultType );
204209 }
205210 }
@@ -208,10 +213,6 @@ public function getType(Type $inputType, ?Type $filterType, ?Type $flagsType): T
208213 return new ArrayType ($ inputArrayKeyType ?? $ mixedType , $ type );
209214 }
210215
211- if ($ this ->hasFlag ('FILTER_THROW_ON_FAILURE ' , $ flagsType )->yes ()) {
212- $ type = TypeCombinator::remove ($ type , $ defaultType );
213- }
214-
215216 return $ type ;
216217 }
217218
0 commit comments