Skip to content

[Serializer] Constructor parameters handled incorrectly when denormalizing in GetSetMethodNormalizer #10499

Closed
@vojtagrec

Description

@vojtagrec

When trying to denormalize an object (from JSON, but this is not relevant) using the "constructor way", the parameter order can be incorrect under certain conditions.

For example if I use a constructor like this

public function __construct($foo, $bar = array(), $baz = array())

and use the following data for denormalization

array('foo' => 'test', 'baz' => array(1, 2, 3))

I'd expect the constructor to be called like this

new MyClass('test', array(), array(1, 2, 3))

but this is what happens in reality

new MyClass('test', array(1, 2, 3))

so the value that is "baz" is used for "bar", which is really unpleasant.

I'm only starting my "life with Symfony" and don't have the time to read on the docs and make a proper pull request now, so I hope anybody else could do that. This bug is present ever since Symphony 2.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueIdeal for your first contribution! (some Symfony experience may be required)Serializer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions