Skip to content

[Serializer] camelCase keys in arrays are not mapped to constructor parameter with CamelCaseToSnakeCaseNameConverter #48779

Open
@faizanakram99

Description

@faizanakram99

Symfony version(s) affected

6.2.2

Description

When CamelCaseToSnakeCaseNameConverter is enabled, both snake_case keys and camelCase keys in array are denormalized to public camelCase properties.

OTOH when the class has a constructor, only snake_case keys are denormalized into constructor parameters, camelCase array keys cause the object construction to fail (serializer is unable to map camelCase key from array to camelCase constructor parameter). This is inconsistent with denormalization without constructor.

How to reproduce

Here is the reproducer, checkout the repo and run test cases. 4th test case is exactly like the second test case with the difference of constructor and it fails.

https://github.com/faizanakram99/serializer-bug-reproducer

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions