Closed
Description
It's very common in a service to inject the normalizer, and to use normalize()
or denormalize()
However, theses methods does not exist on SerializerInterface
.
So, if we want to use normalize()
, denormalize()
, and serializer
,we need to inject 3 services: NormalizerInterface, DenormalizerInterface, and SerializerInterface. Not really handy !
To be honest, I always inject the SerializerInterface, because I know methods exists on the implementations. But on every projects, I have to ignore error reported by static analysis.
So, what do you think of creating an interface that embrace all three others?
Side question, with PHP 8.1 we have intersection types, how does behave the containers with the following signature
public function __construct(NormalizerInterface&DenormalizerInterface&SerializerInterface $serializer) ?
Metadata
Metadata
Assignees
Labels
RFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)