-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] avoid calling undefined built-in is_*() functions #57320
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
xabbuh
commented
Jun 5, 2024
Q | A |
---|---|
Branch? | 7.1 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Issues | Fix #57314 |
License | MIT |
$dataMatchesExpectedType = match ($builtinType) { | ||
LegacyType::BUILTIN_TYPE_ARRAY => \is_array($data), | ||
LegacyType::BUILTIN_TYPE_BOOL => \is_bool($data), | ||
LegacyType::BUILTIN_TYPE_CALLABLE => \is_callable($data), | ||
LegacyType::BUILTIN_TYPE_FALSE => false === $data, | ||
LegacyType::BUILTIN_TYPE_FLOAT => \is_float($data), | ||
LegacyType::BUILTIN_TYPE_INT => \is_int($data), | ||
LegacyType::BUILTIN_TYPE_ITERABLE => is_iterable($data), | ||
LegacyType::BUILTIN_TYPE_NULL => null === $data, | ||
LegacyType::BUILTIN_TYPE_OBJECT => \is_object($data), | ||
LegacyType::BUILTIN_TYPE_RESOURCE => $data, | ||
LegacyType::BUILTIN_TYPE_STRING => \is_string($data), | ||
LegacyType::BUILTIN_TYPE_TRUE => true === $data, | ||
default => false, | ||
}; |
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.
Would worth a private method maybe? As you're using the same logic twice?
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.
In fact, the legacy type doesn't support mixed here. So I have reverted these changes.
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.
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.
src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
Outdated
Show resolved
Hide resolved
Hello! When are we planning to release this? It's a breaking change for us. |
Patch releases are published once a month. |
…ypes (xabbuh) This PR was merged into the 5.4 branch. Discussion ---------- [Serializer] properly handle invalid data for false/true types | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #57320 (comment) | License | MIT Commits ------- d35d4a3 properly handle invalid data for false/true types
…ypes (xabbuh) This PR was merged into the 5.4 branch. Discussion ---------- [Serializer] properly handle invalid data for false/true types | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony/symfony#57320 (comment) | License | MIT Commits ------- d35d4a337b properly handle invalid data for false/true types