Skip to content

[Serializer] Correct all implementations of the NormalizerInterface to have the correct method signature #59496

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

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

Kefisu
Copy link
Contributor

@Kefisu Kefisu commented Jan 13, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #59495
License MIT

This PR corrects the signatures of all normalizers implementing the NormalizerInterface of the Serializer component effectively changing: function normalize($object, ... ) to function normalize(mixed $data, ...) as is in line with the interface.

Whilst Named Arguments is against the BC promise of Symfony, with the current implementation of the normalizers it is impossible to use named arguments with the Strategy Pattern using the Serializer component, with this change it is possible.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@Kefisu Kefisu force-pushed the fix_59495 branch 3 times, most recently from 8aedbb2 to 85da27d Compare January 13, 2025 18:12
@OskarStark OskarStark changed the title [Serializer] Correct all implementations of the NormalizerInterface to have the correct method signature [Serializer] Correct all implementations of the NormalizerInterface to have the correct method signature Jan 14, 2025
@derrabus derrabus removed the Bug label Jan 14, 2025
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Works for me, but as you mentioned, there is no BC guarantee that named arguments work nor will keep working. If you rely on them for the strategy pattern, you're on your own.

@Kefisu
Copy link
Contributor Author

Kefisu commented Jan 27, 2025

Any further idea's on this PR?

…rrect method signature

This commit fixes symfony#59495

Rename test method name

Remove void return type from test

Remove redundant docblock
@fabpot
Copy link
Member

fabpot commented Feb 7, 2025

Thank you @Kefisu.

@fabpot fabpot merged commit cb0a724 into symfony:7.3 Feb 7, 2025
7 of 9 checks passed
xabbuh added a commit that referenced this pull request Feb 7, 2025
This PR was merged into the 7.3 branch.

Discussion
----------

[Serializer] clean up unused property

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

leftover from #59496

Commits
-------

a68e42b clean up unused property
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.

[Serializer] Discrepancy between NormalizerInterface and it's implementation
6 participants