prettier / prettier/plugin-php
Prettier adds incorrect semicolon with nested foreach, for, try/catch
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- PHP
- Sterne
- 1.9k
- Forks
- 139
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
@prettier/plugin-php v0.18.8
Playground link
Input:
<?php
foreach( $x as $y)
foreach ($a as $b) {
$a = $x;
}
foreach ($x as $y)
for ($a = 1; $a < 10; a++) {
$a = $x;
};
if( $foo)
foreach($b as $a)
{
$foo = bar;
}
if($foo)
try {
} catch (Exception $e){
}
Output:
<?php
foreach ($x as $y) {
foreach ($a as $b) {
$a = $x;
};
}
foreach ($x as $y) {
for ($a = 1; $a < 10; a++) {
$a = $x;
};
}
if ($foo) {
foreach ($b as $a) {
$foo = bar;
};
}
if ($foo) {
try {
} catch (Exception $e) {
};
}
I think this shows the issue. The expected output should be the same as the output, without the extra semicolons.
If you run prettier on the same file a second time, it will removed the extra semicolons. I know this affects foreach, for, try/catch, but I'm not sure that is a comprehensive list.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem verlinkten Playground-Beispiel und vergleiche den ersten Formatierungsdurchlauf mit dem zweiten Durchlauf. Reproduziere die verschachtelten Fälle von foreach, for, try/catch und verwandte Fälle und überprüfe anschließend, dass die Formatierung keine zusätzlichen Semikolons erzeugt und bei einer erneuten Ausführung unverändert bleibt.
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