prettier / prettier/plugin-php

Wrong indentation in match statements with multiple options

Offen
#2,435 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug
Vorherrschende Sprache
PHP
Sterne
1.9k
Forks
139
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

@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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der verknüpften Playground-Reproduktion und vergleichen Sie die gemeldete Ein- und Ausgabe für die match-Anweisung mit mehreren Optionen und ihrem verschachtelten Array. Verfolgen Sie das für Zeilenumbrüche und Einrückung verantwortliche Formatierungsverhalten und überprüfen Sie anschließend, dass Array-Einträge weiter eingerückt sind als ihre öffnende geschweifte Klammer und dass die schließende geschweifte Klammer bündig mit ihr abschließt, ohne die umgebende match-Formatierung zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
php
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.