diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 9a47138a2e0bd..a1aa4250e2155 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -323,14 +323,13 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref } } elseif ($allowed && !$ignored && (isset($data[$key]) || array_key_exists($key, $data))) { $parameterData = $data[$key]; - if (null !== $constructorParameter->getType()) { - try { + try { + if (null !== $constructorParameter->getClass()) { $parameterClass = $constructorParameter->getClass()->getName(); - } catch (\ReflectionException $e) { - throw new RuntimeException(sprintf('Could not determine the class of the parameter "%s".', $key), 0, $e); + $parameterData = $this->serializer->deserialize($parameterData, $parameterClass, $format, $context); } - - $parameterData = $this->serializer->deserialize($parameterData, $parameterClass, $format, $context); + } catch (\ReflectionException $e) { + throw new RuntimeException(sprintf('Could not determine the class of the parameter "%s".', $key), 0, $e); } // Don't run set for a parameter passed to the constructor