private function denormalizeCollection(string $attribute, PropertyMetadata $propertyMetadata, Type $type, string $className, $value, string $format = null, array $context) : array
{
if (!is_array($value)) {
throw new InvalidArgumentException(sprintf('The type of the "%s" attribute must be "array", "%s" given.', $attribute, gettype($value)));
}
$collectionKeyType = $type->getCollectionKeyType();
$collectionKeyBuiltinType = null === $collectionKeyType ? null : $collectionKeyType->getBuiltinType();
$values = [];
foreach ($value as $index => $obj) {
if (null !== $collectionKeyBuiltinType && !call_user_func('is_' . $collectionKeyBuiltinType, $index)) {
throw new InvalidArgumentException(sprintf('The type of the key "%s" must be "%s", "%s" given.', $index, $collectionKeyBuiltinType, gettype($index)));
}
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $context);
}
return $values;
}