Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Named Serializers do not work on intersection types #60682

Open
@MarijnDoeve

Description

@MarijnDoeve

Symfony version(s) affected

7.3.0, 7.2.0

Description

Named Serializes are only injected when using SerializerInterface. When I use an intersection type like SerializerInterface&DenormalizerInterface I'm getting the default Serializer.

How to reproduce

#config/serializer.yaml
framework:
    serializer:
        named_serializers:
            somthing:
                name_converter: 'serializer.name_converter.camel_case_to_snake_case'
                default_context:
                    datetime_format: 'U'
    public function __construct(
        protected SerializerInterface&DenormalizerInterface $somethingSerializer,
    ) {
    }

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