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

Open
AndrolGenhald opened this issue Oct 11, 2024 · 0 comments
Open

Unsealed array with trailing comma causes parse error #566

AndrolGenhald opened this issue Oct 11, 2024 · 0 comments

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.

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

No branches or pull requests

1 participant