Skip to content

[Serializer] Cannot get base type on int|string compound type #56874

@ruudk

Description

@ruudk

Symfony version(s) affected

7.1-RC1

Description

The Serializer component switched to the new TypeInfo component and now our serialization breaks:

Symfony\Component\TypeInfo\Exception\LogicException : Cannot get base type on "int|string" compound type.

How to reproduce

final readonly class AddToCart
{
    /**
     * @param array<string, string|int> $metadata
     */
    public function __construct(
        public string $cartId,
        public array $metadata,
    ) {}
}

Symfony\Component\TypeInfo\Exception\LogicException : Cannot get base type on "int|string" compound type.
/Volumes/CS/www/cosmos/vendor/symfony/type-info/Type/UnionType.php:48
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:705
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:830
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractNormalizer.php:371
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:239
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:335
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Serializer.php:238
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Serializer.php:143

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions