plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

First class callable syntax treated like arguments, trailing comma causes error

Open MasonD opened this issue 2 years ago • 1 comments

@prettier/plugin-php v0.19.3 Playground link

Input:

<?php

 return $this->longMethodName(
        
          
                $this->longPropertyName->evenLongerMethodNameNowCausesTheDotsToWrapWithComma(...),
              
        );

Output:

<?php

return $this->longMethodName(
    $this->longPropertyName->evenLongerMethodNameNowCausesTheDotsToWrapWithComma(
        ...,
    ),
);

Expected Output: No trailing comma after ... in first class callable syntax, which is a syntax error. Or preferentially treating the (...) as being inseparable and not allowing line breaks inside it.

MasonD avatar Feb 16 '23 23:02 MasonD

Yea, just bumped into this one myself, extracted a Laravel query filter to a named function for reuse, and a deep/long relation name caused it to break to a new line. Would agree that func(...) should be an unbreakable unit of syntax.

Spice-King avatar May 08 '24 14:05 Spice-King