Skip to content

[Serializer] Use DenormalizerAwareInterface instead of SerializerAwareInterface #52764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 7.4
Choose a base branch
from

Conversation

jschaedl
Copy link
Contributor

Q A
Branch? 7.1
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

The UnwrappingDenormalizer does not depend on the SerializerInterface. Using the DenormalizerInterfacce is enough, because only denormalize() is called. Also, the SerializerInterface does not define method denormalize() and it currently only works, because at runtime the serializer service is injected, which implements the DenormalizerInterface.

The UnwrappingDenormalizer does not depend on the SerializerInterface.
Using the DenormalizerInterfacce is enough, because only denormalize is called.
Also, the SerializerInterface does not define method denormalize and it currently only works,
because at runtime the serializer service is injected, which implements the DenormalizerInterface.
@jschaedl jschaedl changed the title Use DenormalizerAwareInterface instead of SerializerAwareInterface [Serializer] Use DenormalizerAwareInterface instead of SerializerAwareInterface Nov 27, 2023
@jschaedl jschaedl requested a review from dunglas as a code owner November 27, 2023 20:16
@carsonbot carsonbot changed the title [Serializer] Use DenormalizerAwareInterface instead of SerializerAwareInterface Use DenormalizerAwareInterface instead of SerializerAwareInterface Nov 27, 2023
@carsonbot carsonbot added this to the 7.1 milestone Nov 27, 2023
@derrabus
Copy link
Member

This is a breaking change that we need a deprecation layer for. By removing SerializerAwareInterface/SerializerAwareTrait from this class, we're effectively removing a public method from that class.

@jschaedl
Copy link
Contributor Author

Hi @derrabus,

This is a breaking change that we need a deprecation layer for. By removing SerializerAwareInterface/SerializerAwareTrait from this class, we're effectively removing a public method from that class.

You are right, I missed this. I am going to add a deprecation layer.

@jschaedl jschaedl force-pushed the unwrappin-denormalizer branch from 94663b7 to c4542ef Compare November 28, 2023 08:09
@jschaedl jschaedl force-pushed the unwrappin-denormalizer branch from c4542ef to 4dea4e0 Compare November 28, 2023 08:10

/**
* @author Eduard Bulava <bulavaeduard@gmail.com>
*/
final class UnwrappingDenormalizer implements DenormalizerInterface, SerializerAwareInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep SerializerAwareInterface as long as we implement setSerializer().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we implement SerializerAwareInterface, the Serializer class will be calling the deprecated method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the reason why I removed SerializerAwareInterface. The Serializer class will call setSerializer() here: https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Serializer/Serializer.php#L85

But without it, its a bc-break for code relying on UnwrappingDenormalizer implementing SerializerAwareInterface. I am not sure how to solve this problem.

@carsonbot carsonbot changed the title Use DenormalizerAwareInterface instead of SerializerAwareInterface [Serializer] Use DenormalizerAwareInterface instead of SerializerAwareInterface May 15, 2024
@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 15, 2024
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants