Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Serializer] Denormalize support forstdClass
#52850
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
base:6.4
Are you sure you want to change the base?
Conversation
43d71df
to0479a92
Compare@dunglas could you make a code review and eventually merge the commit? |
0479a92
to0238782
Compare0238782
to20a49a9
Compare@nicolas-grekas Could you please make a review? |
Instead of hacking that in the ObjectNormalizer, I think this should rather be a new Normalizer |
@stof Good point. However, currently the normalizing process of stdClass is part of the same class -https://github.com/symfony/symfony/pull/52850/files#diff-397b4689ce56cc95e54911f6d78639bb3258a9ee9b36bfa06ec719e9635e6b1dR67 |
@stof I thought about it and think it should be part of the ObjectNormalizer.
@stof@dunglas Could you please make a review and eventually merge it? |
if we go that way,all core normalizers would be removed by bundling them into ObjectNormalizer, because BackedEnum or DateTime are also objects. ObjectNormalizer is not about being the implementation to use for all objects. It is thegeneric implementation used for objects that don't have another normalizer registered with a higher priority to take over the normalization with specific logic.
The JSON ODM does not use the ObjectNormalizer directly. It uses a Serializer with multiple normalizers registered in it. This means that they could totally register the new normalizer once it is available. They already did exactly that for the BackedEnumNormalizer and the UidNormalizer btw. |
I'm with@stof here. Adding special behavior for a specific class usually means we're adding a new normalizer. |
Agreed as well. The Plus, a |
jg-development commentedOct 29, 2024
We have this problem too: |
AKAIK, there is no ongoing work on that normalizer, so feel free to step in 🙂 |
jg-development commentedOct 29, 2024
Questions regarding "new normalizer". What about a class, that is a mixture of stdclass and object? <?phpdeclare(strict_types =1);usestdClass;class Contactextends stdClass{publicstring$email ='';} I am not sure if a new normalizer is the best solution here. But I will kick in and give feedback |
jg-development commentedNov 5, 2024
Hi.. The problem with an extra stdclass normalizer is the shared logic of stdclass objects and objects that extends stdclasses. It should be possible to extract the stdclass logic into a StdclassNormalizer and extend the ObjectNormalizer. Imho the ObjectNormalizer needs an overhaul, but this is an issue for later and not for now. Maybe, than it is possible to seperate the normalizers. |
stdClass
jg-development commentedNov 5, 2024
@dunglas |
What about acting directly on The actual behavior in PropertyAccessor is checking the following: I'm still not sure why we need that |
The property_exists is used to check whether a property with a |
jg-development commentedNov 19, 2024
@mtarld@alexandre-daubois |
Uh oh!
There was an error while loading.Please reload this page.
Add support for denormalizing stdClass objects in Symfony serializer