diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 274a3cbe912a1..2e11136ba0b87 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -342,15 +342,12 @@ protected function instantiateObject(array &$data, string $class, array &$contex $missingConstructorArguments = []; $params = []; $unsetKeys = []; - $objectDeserializationPath = $context['deserialization_path'] ?? null; foreach ($constructorParameters as $constructorParameter) { $paramName = $constructorParameter->name; $attributeContext = $this->getAttributeDenormalizationContext($class, $paramName, $context); $key = $this->nameConverter ? $this->nameConverter->normalize($paramName, $class, $format, $context) : $paramName; - $context['deserialization_path'] = $objectDeserializationPath ? $objectDeserializationPath.'.'.$paramName : $paramName; - $allowed = false === $allowedAttributes || \in_array($paramName, $allowedAttributes); $ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context); if ($constructorParameter->isVariadic()) { @@ -406,15 +403,13 @@ protected function instantiateObject(array &$data, string $class, array &$contex sprintf('Failed to create object because the class misses the "%s" property.', $constructorParameter->name), $data, ['unknown'], - $objectDeserializationPath, + $context['deserialization_path'] ?? null, true ); $context['not_normalizable_value_exceptions'][] = $exception; } } - $context['deserialization_path'] = $objectDeserializationPath; - if ($missingConstructorArguments) { throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires the following parameters to be present : "$%s".', $class, implode('", "$', $missingConstructorArguments)), 0, null, $missingConstructorArguments, $class); }