Skip to content

Commit

Permalink
Fix denormalization of object with variadic constructor typed argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgarlag committed May 9, 2019
1 parent 54667d5 commit 7108f84
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -354,7 +354,14 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name));
}

$params = array_merge($params, $data[$paramName]);
$variadicParameters = array_map(
function($parameterData) use ($reflectionClass, $constructorParameter, $paramName, $context, $format) {
return $this->denormalizeParameter($reflectionClass, $constructorParameter, $paramName, $parameterData, $context, $format);
},
$data[$paramName]
);

$params = array_merge($params, $variadicParameters);
}
} elseif ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
$parameterData = $data[$key];
Expand Down

0 comments on commit 7108f84

Please sign in to comment.