Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| publicfunctionnormalize($exception,$format =null,array$context = []) | ||
| publicfunctionnormalize($object,$format =null,array$context = []) | ||
| { | ||
| if (!$objectinstanceof 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 allowingobject ; 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 thesupportNormalization 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
fabpot commentedJan 13, 2021
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 | MITThe 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 interfaceCommits-------7e6eee2 Rename normalize param
The ProblemNormalizer is the only one Normalizer which
$exceptioninstead of the one in the interface$object.The first point lead to an unfixable error with Psalm when extending the ProblemNormalizer
$objectit does not match with the parent$exceptionit does not match with the interface