@@ -330,11 +330,7 @@ protected function instantiateComplexObject(array &$data, $class, array &$contex
330330
331331 $ params = array_merge ($ params , $ data [$ paramName ]);
332332 }
333-
334- continue ;
335- }
336-
337- if ($ allowed && !$ ignored && (isset ($ data [$ key ]) || array_key_exists ($ key , $ data ))) {
333+ } elseif ($ allowed && !$ ignored && (isset ($ data [$ key ]) || array_key_exists ($ key , $ data ))) {
338334 $ parameterData = $ data [$ key ];
339335 if (null !== $ constructorParameter ->getClass ()) {
340336 $ parameterData = $ this ->serializer ->deserialize ($ parameterData , $ constructorParameter ->getClass ()->getName (), $ format , $ context );
@@ -343,30 +339,24 @@ protected function instantiateComplexObject(array &$data, $class, array &$contex
343339 // Don't run set for a parameter passed to the constructor
344340 $ params [] = $ parameterData ;
345341 unset($ data [$ key ]);
346-
347- continue ;
348- }
349-
350- if ($ constructorParameter ->isDefaultValueAvailable ()) {
342+ } elseif ($ constructorParameter ->isDefaultValueAvailable ()) {
351343 $ params [] = $ constructorParameter ->getDefaultValue ();
352-
353- continue ;
344+ } else {
345+ throw new RuntimeException (
346+ sprintf (
347+ 'Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present. ' ,
348+ $ class ,
349+ $ constructorParameter ->name
350+ )
351+ );
354352 }
355-
356- throw new RuntimeException (
357- sprintf (
358- 'Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present. ' ,
359- $ class ,
360- $ constructorParameter ->name
361- )
362- );
363353 }
364354
365355 if ($ constructor ->isConstructor ()) {
366356 return $ reflectionClass ->newInstanceArgs ($ params );
357+ } else {
358+ return $ constructor ->invokeArgs (null , $ params );
367359 }
368-
369- return $ constructor ->invokeArgs (null , $ params );
370360 }
371361
372362 return new $ class ();
0 commit comments