plugin-php
plugin-php copied to clipboard
Readonly properties crash Prettier when order is not "{access modifier} readonly"
@prettier/plugin-php v0.18.4 Playground link
Input:
<?php
class Foo {
public function __construct(readonly private string $baz){}
}
Output:
Parse Error : syntax error, unexpected 'private' (T_PRIVATE), expecting T_VARIABLE on line 4
2 |
3 | class Foo {
> 4 | public function __construct(readonly private string $baz){}
| ^
5 | }
The other way around works just as expected (private readonly).
I was unable to find anything about the order of those modifiers in the RFC.
However, php executes the script just fine, so the code itself seems valid.
I have encountered this too, I think it will need to be fixed in the parser.
Released in 0.19.1 :tada: