Skip to content

Commit

Permalink
Use foreach instead of array_map
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgarlag committed May 10, 2019
1 parent 52945cb commit 8ca9a60
Showing 1 changed file with 4 additions and 6 deletions.
Expand Up @@ -354,12 +354,10 @@ 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));
}

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

$params = array_merge($params, $variadicParameters);
unset($data[$key]);
Expand Down

0 comments on commit 8ca9a60

Please sign in to comment.