-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Fix denormalization of arrays #19649
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
647fdf9
to
4603627
Compare
$builtinType = isset($context['key_type']) ? $context['key_type']->getBuiltinType() : null; | ||
foreach ($data as $key => $value) { | ||
if (null !== $builtinType && !call_user_func('is_'.$builtinType, $key)) { | ||
throw new UnexpectedValueException(sprintf('The type of the key "%s" must be "%s" ("%s" given).', $key, $builtinType, gettype($key))); |
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.
No need for the brackets, just a comma
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.
Brackets are used for the similar exception here https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php#L270
WSYT of standardizing messages with the rest of the code base in another PR?
👍 |
/** | ||
* @var ObjectInner[] | ||
*/ | ||
private $inners; |
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.
if we're missing this phpdoc, the serializer won't try to normalize inner
before calling setInners()
right?
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.
If there is no type defined (through a PHPDoc or any other way supported by registered extractors), the old behavior (don't check anything) occurs.
👍 |
Thank you @dunglas. |
This PR was squashed before being merged into the 3.1 branch (closes #19649). Discussion ---------- [Serializer] Fix denormalization of arrays | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19545 | License | MIT | Doc PR | n/a ping @hensoko @theofidry Commits ------- 99c582b [Serializer] Fix denormalization of arrays
ping @hensoko @theofidry