Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
Open
Description
Symfony version(s) affected
5.4, 6.x, 7.x
Description
If array with string key but list is nested under object with a list (like in a reproducer), Denormalizer seems to skew the key from string into int, resulting into error:
Symfony\Component\Serializer\Exception\NotNormalizableValueException : The type of the key "something" must be "int" ("string" given).
How to reproduce
Phpunit reproducer athttps://github.com/symfony/symfony/compare/7.3...ostrolucky:list-nesting-reproducer?expand=1
In comment form:
class Foo {/** @param array<string, list<\stdClass>> $operators */publicfunction__construct(publicarray$operators = []) {}}class Bar {/** @param list<Foo> $foos */publicfunction__construct(publicarray$foos = []) {}}
publicfunctiontestPropertyPhpDocWithKeyTypes(){$json =<<<JSON { "foos": [{"operators": {"something": [{}]}}] } JSON;$serializer =newSerializer([newObjectNormalizer(null,null,null,newPhpDocExtractor()),newArrayDenormalizer(), ], ['json' =>newJsonEncoder()]);$serializer->deserialize($json, Bar::class,'json');}
Possible Solution
No response
Additional Context
No response