Skip to content
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

[Serializer] Fix denormalization of arrays #19649

Closed
wants to merge 2 commits into from

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Aug 17, 2016

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

$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)));
Copy link
Member

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

Copy link
Member Author

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?

@nicolas-grekas
Copy link
Member

👍

/**
* @var ObjectInner[]
*/
private $inners;
Copy link
Contributor

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?

Copy link
Member Author

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.

@theofidry
Copy link
Contributor

👍

@fabpot
Copy link
Member

fabpot commented Aug 19, 2016

Thank you @dunglas.

@fabpot fabpot closed this Aug 19, 2016
fabpot added a commit that referenced this pull request Aug 19, 2016
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
@dunglas dunglas deleted the fix_collections branch August 23, 2016 11:10
@fabpot fabpot mentioned this pull request Sep 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants