Skip to content

[3.2.0] - BC break - Argument #2 ($iriConverter) must be of type ApiPlatform\Api\IriConverterInterface, ApiPlatform\Symfony\Routing\IriConverter given #5881

Description

@perice

API Platform version(s) affected: 3.2.0

Description
After upgrading from 3.1.20 to 3.2.0, I get this exception:

AddIriApiNormalizer::__construct(): Argument #2 ($iriConverter) must be of type ApiPlatform\Api\IriConverterInterface, ApiPlatform\Symfony\Routing\IriConverter given.

Workaround is to downgrade to 3.1.20.

How to reproduce

services.yaml:

  'app.apiPlatform.serializer.addIri.json':
    class: Namespace\AddIriApiNormalizer
    decorates: 'api_platform.serializer.normalizer.item'

AddIriApiNormalizer (relevant parts):

use ApiPlatform\Api\IriConverterInterface;
use ArrayObject;
use InvalidArgumentException;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\SerializerAwareInterface;
use Symfony\Component\Serializer\SerializerInterface;

class AddIriApiNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
{
    /**
     * @var DenormalizerInterface|NormalizerInterface
     */
    private $decorated;

    /**
     * @var IriConverterInterface
     */
    private $iriConverter;

    public function __construct(NormalizerInterface $decorated, IriConverterInterface $iriConverter)
    {
        if(!$decorated instanceof DenormalizerInterface)
        {
            throw new InvalidArgumentException(sprintf('The decorated normalizer must implement the %s.', DenormalizerInterface::class));
        }

        $this->decorated = $decorated;
        $this->iriConverter = $iriConverter;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions