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

Format multiple-catch

Open loilo opened this issue 5 years ago • 1 comments

We're currently not respecting line length limitations in multiple-catch blocks, which we could.


@prettier/plugin-php v0.14.0 Playground link

Input:

<?php

try {
    do_something();
} catch (\Some\Rather\Obscure\Exception | \Another\Obscure\Exception $exception) {
    handle_exception();
}

Current Output:

<?php

try {
    do_something();
} catch (\Some\Rather\Obscure\Exception | \Another\Obscure\Exception $exception) {
    handle_exception();
}

Improved Output:

<?php

try {
    do_something();
} catch (
    \Some\Rather\Obscure\Exception |
    \Another\Obscure\Exception $exception
) {
    handle_exception();
}


To be honest, the improved output is not perfect (the $exception variable is a little bit "obscured" next to the exception class), but it's better than the current behavior IMO.

loilo avatar Apr 19 '20 12:04 loilo

I am also experiencing this.

djschilling avatar Oct 11 '20 17:10 djschilling