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

chained method wrapping inconsistent when comments inside arguments #2171

Open
MasonD opened this issue Apr 17, 2023 · 0 comments
Open

chained method wrapping inconsistent when comments inside arguments #2171

MasonD opened this issue Apr 17, 2023 · 0 comments

Comments

@MasonD
Copy link

MasonD commented Apr 17, 2023

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,
    ]),
]);
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