-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Conversation
{ | ||
if (!$object instanceof FlattenException) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
- https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php#L53
- https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php#L42
- https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/Serializer/Normalizer/JsonSerializableNormalizer.php#L33
- https://github.com/symfony/symfony/blob/5.x/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php#L55
So I added consistency
Thank you @VincentLanglet. |
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
The ProblemNormalizer is the only one Normalizer which
$exception
instead of the one in the interface$object
.The first point lead to an unfixable error with Psalm when extending the ProblemNormalizer
$object
it does not match with the parent$exception
it does not match with the interface