Skip to content

UnwrappingDenormalizer is badly designed #49645

Closed
@nicolas-grekas

Description

@nicolas-grekas

In #31390 we introduced UnwrappingDenormalizer, which can extract a nested object without creating unnecessary model class that we don't really need.

The design of this denormalizer looks broken to me: it implements SerializerAwareInterface but calls $this->serializer->denormalize(). This works because our implementation of Serializer implements both SerializerInterface and DenormalizerInterface but this is still broken, from a design pov.

Another thing I'm wondering: because it works as a denormalizer, the serializer will call supportsDenormalization() at each iteration. Is this legit or isn't this denormalizer supposed to work only at the root level? While I'm sure that we could construct use cases where this can be leveraged, the drawback of this behavior is a potential perf cost.

WDYT?

/cc @nonanerz FYI

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