src/Serializer/AbstractItemNormalizer.php
protected function denormalizeCollection(string $attribute, PropertyMetadata $propertyMetadata, Type $type, string $className, $value, ?string $format, 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, $this->createChildContext($context, $attribute));
        }

        return $values;
    }
protected function denormalizeCollection(string $attribute, PropertyMetadata $propertyMetadata, Type $type, string $className, $value, ?string $format, 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, $this->createChildContext($context, $attribute));
        }

        return $values;
    }
protected function denormalizeCollection ( string $ attribute , PropertyMetadata $ propertyMetadata , Type $ type , string $ className , $ value , ? string $ format , 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 , $ this -> createChildContext ( $ context , $ attribute ) ) ; } return $ values ; }
Denormalizes a collection of objects.

@throws InvalidArgumentException
Denormalizes a collection of objects .