Skip to content

Array values get nested #259

Closed
Closed
@subiabre

Description

@subiabre

When there is mapping from a source array property to a target array property, the values in the source array get each nested in their own array.

class UserApiResource
{
    public array $roles; // ["ROLE_USER"]
}

...

class UserEntity
{
    public function setRoles(array $roles)
    {
        $this->roles = $roles; // [["ROLE_USER"]];
    }
}

This occurs because the generated mapping class does wrap each value in the array in their own array:

$values = [];
foreach ($value->roles ?? [] as $key => $value_2) {
    $values[] = [$value_2];
}
$result->setRoles($values);

This issue was not present in 9.2.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions