Skip to content

Array values get nested #259

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

Closed
subiabre opened this issue Apr 4, 2025 · 2 comments
Closed

Array values get nested #259

subiabre opened this issue Apr 4, 2025 · 2 comments
Labels
question Further information is requested

Comments

@subiabre
Copy link

subiabre commented Apr 4, 2025

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.

joelwurtz added a commit that referenced this issue Apr 5, 2025
@joelwurtz
Copy link
Member

I cannot reproduce this issue on master see the corresponding PR that add a test corresponding to your description

Can you try on master to check if this is still present ?

@joelwurtz joelwurtz added the question Further information is requested label Apr 5, 2025
@subiabre
Copy link
Author

Hi, can confirm the bug is no longer present in the master branch.

Closing this now. Thank you for the quick attention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants