-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Fix ObjectNormalizer
gives warnings on normalizing with public static property
#58255
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
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Hey! Thanks for your PR. You are targeting branch "7.1" but it seems your PR description refers to branch ">= 7.1.2". Cheers! Carsonbot |
Does this also affect 6.4? |
src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
Outdated
Show resolved
Hide resolved
@xabbuh It also affects 6.4. I have tested it with v6.4.11. |
@alexandre-daubois try-catch is removed. However, I have left |
You may rebase your PR onto 6.4 and change the target branch of the PR. This way, the fix is available on all (still supported) affected branches |
src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
Outdated
Show resolved
Hide resolved
ObjectNormalizer
gives warnings on normalizing with static property
src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php
Outdated
Show resolved
Hide resolved
ObjectNormalizer
gives warnings on normalizing with static propertyObjectNormalizer
gives warnings on normalizing with public static property
src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
Outdated
Show resolved
Hide resolved
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.
LGTM
…h public static property
fc8583a
to
bcc38d9
Compare
Thank you @alaugks. |
The error message has been occurring since version 6.4.11/7.1.2. If the condition is changed to version >=7.1.2, the error message no longer occurs.
The error is thrown with the following ObjectNormalizer configuration:
(\is_object($classOrObject) && $this->propertyAccessor->isReadable($classOrObject, $attribute))
is true and therefore the entire condition is true.I moved the condition into a method to improve readability and reduce complexity.
All serializer tests are successful.
Condition
For better readability here with breaks.
7.1.1
https://github.com/symfony/symfony/blob/v7.1.1/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L180
>=7.2.2
https://github.com/symfony/symfony/blob/v7.1.2/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L180
Fixed condition