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

chained method wrapping inconsistent when comments inside arguments

Open MasonD opened this issue 2 years ago • 0 comments

When a comment is added inside the argument of secondMethod below, it changes the way that the chained methods are wrapped in a way that doesn't seem intuitive for it to affect.

@prettier/plugin-php v0.19.3 Playground link

Input:

<?php

        $builder->firstMethod()->secondMethod([
            new ClassName('c-' . $some_long_variable, [
                EXTEND::THIS, LINE::SO, IT::HASNEWLINES
            ]),
           new ClassName('c-' . $some_long_variable, [
                EXTEND::THIS, LINE::SO, IT::HASNEWLINES
            ]),
        ]);

Output:

<?php

$builder
    ->firstMethod()
    ->secondMethod([
        new ClassName("c-" . $some_long_variable, [
            EXTEND::THIS,
            LINE::SO,
            IT::HASNEWLINES,
        ]),
        new ClassName("c-" . $some_long_variable, [
            EXTEND::THIS,
            LINE::SO,
            IT::HASNEWLINES,
        ]),
    ]);

@prettier/plugin-php v0.19.3 Playground link

Input:

<?php

        $builder->firstMethod()->secondMethod([
            new ClassName('c-' . $some_long_variable, [
                EXTEND::THIS, LINE::SO, IT::HASNEWLINES
            ]),
           //  comment 
           new ClassName('c-' . $some_long_variable, [
                EXTEND::THIS, LINE::SO, IT::HASNEWLINES
            ]),
        ]);

Output:

<?php

$builder->firstMethod()->secondMethod([
    new ClassName("c-" . $some_long_variable, [
        EXTEND::THIS,
        LINE::SO,
        IT::HASNEWLINES,
    ]),
    //  comment
    new ClassName("c-" . $some_long_variable, [
        EXTEND::THIS,
        LINE::SO,
        IT::HASNEWLINES,
    ]),
]);

MasonD avatar Apr 17 '23 04:04 MasonD