Skip to content

[Serializer] Rename normalize param #39735

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
Jan 13, 2021
Merged

Conversation

VincentLanglet
Copy link
Contributor

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
License MIT

The ProblemNormalizer is the only one Normalizer which

  • Use a different param name $exception instead of the one in the interface $object.
  • Doesn't type check the param.

The first point lead to an unfixable error with Psalm when extending the ProblemNormalizer

  • If the variable is named $object it does not match with the parent
  • If the variable is named $exception it does not match with the interface

@carsonbot carsonbot added this to the 4.4 milestone Jan 6, 2021
@carsonbot carsonbot changed the title Rename normalize param [Serializer] Rename normalize param Jan 6, 2021
{
if (!$object instanceof FlattenException) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe could you just add a @param tag here to make Psalm happy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove these lines if preferred ; this does not have impact psalm for developer which extends this class.
My main concern was about the name of the param.

This method is public, and the interface is allowing object ; so theorically this method should handle every possible object and not restricting the param directly in the phpdoc.

I agree that this seems duplicate with the supportNormalization method. We could consider that this is similar to Voter

* It is safe to assume that $attribute and $subject already passed the "supports()" method check.
.

But when I look at others Normalizer, it seems that checking the param was the strategy adopted

So I added consistency

@fabpot
Copy link
Member

fabpot commented Jan 13, 2021

Thank you @VincentLanglet.

@fabpot fabpot merged commit d23b74e into symfony:4.4 Jan 13, 2021
This was referenced Jan 27, 2021
hultberg pushed a commit to hultberg/symfony that referenced this pull request Sep 17, 2021
This PR was merged into the 4.4 branch.

Discussion
----------

[Serializer] Rename normalize param

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| License       | MIT

The ProblemNormalizer is the only one Normalizer which
- Use a different param name `$exception` instead of the one in the interface `$object`.
- Doesn't type check the param.

The first point lead to an unfixable error with Psalm when extending the ProblemNormalizer
- If the variable is named `$object` it does not match with the parent
- If the variable is named `$exception` it does not match with the interface

Commits
-------

7e6eee2 Rename normalize param
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.

5 participants