-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Allow to denormalize objects that have constructor checks without using constructor #45508
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
base: 7.3
Are you sure you want to change the base?
[Serializer] Allow to denormalize objects that have constructor checks without using constructor #45508
Conversation
…ut using constructor
Hey! I think @BafS has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php
Outdated
Show resolved
Hide resolved
I'm not against this feature, but we should stop "polluting" the abstract class. Our long-term goal is to get rid of it. In my opinion, we should finish and merge #38487 first, then add features such as this one as small, single-responsibility classes. |
Sure, I agree that it would be clearer. |
Any help is welcome to finish #38487. |
I have a question. Not about the pull request but more about a way to go faster in my company's project. Thank you. |
@fbiesse you can always create your own custom normalizer in your application to support your needs. That way you only need to maintain the normalizer instead of the whole fork. |
#38487 is somewhat finished for what I could do, the remaining issue is linked to #38487 (comment), if you can find a solution the PR will be unblocked, but there is not much to change appart from that. |
I just don't want to finish #38487 for my simple need. For me it's out of the context of this PR. |
#38487 have been closed. Is there any interest in updating this PR? Automapper allows skipping the constructor using |
In some cases it would be great to be able to denormalize objects without having to pass by the constructor.
In my case, I have Value Objects that perform validations in their constructor. These objects are normalized, json encoded and persisted in a mongodb database.
If the validation rules changed, it is impossible to denormalize some objects because of the constructor checks, even if the properties exists.
This PR allow to use pure property reflection by skiping the constructor even if it is not private.
To allow this you only need to add the new context param create_instance_without_constructor