plugin-php
plugin-php copied to clipboard
Wrong indentation in match statements with multiple options
@prettier/plugin-php v0.22.4 Playground link
Input:
<?php
echo match ($operation) {
"short", "really very long option 2" => SomeClass::fairlyLongMethodNameThatRunsOn($variable, ["short", "short"]),
}
Output:
<?php
echo match ($operation) {
"short",
"really very long option 2"
=> SomeClass::fairlyLongMethodNameThatRunsOn($variable, [
"short",
"short",
]),
};
As you can see, the indentation in the output is off. There's arguments for each individual line being ok, but at the very least, the array entries should by indented one more than their braces (now: same as opening, 1 more than closing), and the closing brace for the array should be indented as much as the line with the opening brace.
As far as I can tell, the length of the individual parts is irrelevant, only that they are in total long enough for a line break to be forced.
Thanks for the bug report @Triqueon! PRs welcome.