Skip to content

Commit

Permalink
do not detect the deserialization_path context value twice
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Nov 24, 2023
1 parent 2f1a7ea commit 9b027a5
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 9b027a5

Please sign in to comment.