-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add default object class resolver #31026
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
[Serializer] Add default object class resolver #31026
Conversation
Do you have some case where the object is a class and not an object ? I'm not sure we want to do that, as the current signature https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php#L237 specify an object (and not a string or object). |
I have the problem on a project I'm working on. I know that the interface specify that the argument need to be an object. But the class isn't specify as So it create an implicit contract for existing apps. And the change can break some projects whereas we want to make a bugfix update of Symfony. |
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.
(for 4.2)
src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
Outdated
Show resolved
Hide resolved
can we maybe trigger an error / deprecation when it's not an object and make it strict in 5.0 (by throwing an error if not an object), not necessarily here, will do the PR if that's ok with you. |
I push the changed suggested by @nicolas-grekas. @joelwurtz I let you trigger the error, it's ok for me |
@jdecool like @nicolas-grekas said you should base your branch on 4.2 and not on master (otherwise you will still have the bug in new 4.2 versions :) ) |
@joelwurtz Oh sorry. It's now OK 👍 |
Thank you @jdecool. |
This PR was squashed before being merged into the 4.2 branch (closes #31026). Discussion ---------- [Serializer] Add default object class resolver | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - The commit 1d8b5af introduce a BC break because before that commit the `extractAttributes` the `$object` can be a string which contain the fully qualified name of an object. To fix the BC break and preserve the new feature, I suggest to create a default object class resolver if it is not set by the developer. Commits ------- dd5b8f1 [Serializer] Add default object class resolver
The commit 1d8b5af introduce a BC break because before that commit the
extractAttributes
the$object
can be a string which contain the fully qualified name of an object.To fix the BC break and preserve the new feature, I suggest to create a default object class resolver if it is not set by the developer.