Skip to content
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

Unsealed array with trailing comma causes parse error #566

Closed
AndrolGenhald opened this issue Oct 11, 2024 · 1 comment · Fixed by #597
Closed

Unsealed array with trailing comma causes parse error #566

AndrolGenhald opened this issue Oct 11, 2024 · 1 comment · Fixed by #597

Comments

@AndrolGenhald
Copy link
Contributor

Valinor currently fails to parse an unsealed array with a trailing comma:

class Foo
{
    /**
     * @param array{
     *     a: int,
     *     b: int,
     *     ...,
     * } $arr
     */
    public function __construct(private readonly array $arr) {}
}

$foo = (new \CuyZ\Valinor\MapperBuilder())
    ->allowPermissiveTypes()
    ->mapper()
    ->map(Foo::class, ["arr" => ["a" => 1, "b" => 2]])
;

It's debatable whether this trailing comma is really appropriate, since ... must appear last the comma isn't useful for diffs, but since Psalm and PHPStan both support it I think it would be good for it not to cause a parsing error.

@romm
Copy link
Member

romm commented Jan 25, 2025

Thanks! Should be fixed with #597 😊

@romm romm closed this as completed in #597 Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants