@@ -242,12 +242,28 @@ protected function validateInputs(array $inputs, $data = [], $context = null)
242242
243243 foreach ($ inputs as $ name ) {
244244 $ input = $ this ->inputs [$ name ];
245+
246+ // Validate an input filter
247+ if ($ input instanceof InputFilterInterface) {
248+ if (!$ input ->isValid ($ context )) {
249+ $ this ->invalidInputs [$ name ] = $ input ;
250+ $ valid = false ;
251+ continue ;
252+ }
253+ $ this ->validInputs [$ name ] = $ input ;
254+ continue ;
255+ }
256+
257+ // If input is not InputInterface then silently continue (BC safe)
258+ if (!$ input instanceof InputInterface) {
259+ continue ;
260+ }
261+
245262 $ hasFallback = ($ input instanceof Input && $ input ->hasFallback ());
246263
247264 // If the value is required, not present in the data set, and
248265 // has no fallback, validation fails.
249266 if (!array_key_exists ($ name , $ data )
250- && $ input instanceof InputInterface
251267 && $ input ->isRequired ()
252268 && !$ hasFallback
253269 ) {
@@ -266,7 +282,6 @@ protected function validateInputs(array $inputs, $data = [], $context = null)
266282 // has a fallback, validation passes, and we set the input
267283 // value to the fallback.
268284 if (!array_key_exists ($ name , $ data )
269- && $ input instanceof InputInterface
270285 && $ input ->isRequired ()
271286 && $ hasFallback
272287 ) {
@@ -279,34 +294,20 @@ protected function validateInputs(array $inputs, $data = [], $context = null)
279294 $ data [$ name ] = null ;
280295 }
281296
282- // Validate an input filter
283- if ($ input instanceof InputFilterInterface) {
284- if (!$ input ->isValid ($ context )) {
285- $ this ->invalidInputs [$ name ] = $ input ;
286- $ valid = false ;
287- continue ;
288- }
289- $ this ->validInputs [$ name ] = $ input ;
290- continue ;
291- }
292-
293297 // Validate an input
294- if ($ input instanceof InputInterface) {
295- $ inputContext = $ context ?: $ data ;
298+ $ inputContext = $ context ?: $ data ;
296299
297- if (!$ input ->isValid ($ inputContext )) {
298- // Validation failure
299- $ this ->invalidInputs [$ name ] = $ input ;
300- $ valid = false ;
300+ if (!$ input ->isValid ($ inputContext )) {
301+ // Validation failure
302+ $ this ->invalidInputs [$ name ] = $ input ;
303+ $ valid = false ;
301304
302- if ($ input ->breakOnFailure ()) {
303- return false ;
304- }
305- continue ;
305+ if ($ input ->breakOnFailure ()) {
306+ return false ;
306307 }
307- $ this ->validInputs [$ name ] = $ input ;
308308 continue ;
309309 }
310+ $ this ->validInputs [$ name ] = $ input ;
310311 }
311312
312313 return $ valid ;
0 commit comments