prettier / prettier/plugin-php

multi-line comment duplicated, leaking outside PHP blocks

Offen
#1,228 7 Kommentare 9 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

The obvious problem is that the multi-line comment is being duplicated and jumping outside the PHP block. But it's weirder, variations are below the main report example.

@prettier/plugin-php v0.11.2
Playground link

Input:

<?php ?>
<?php ?>

<?php
/**
 * comment
 */

$var = 0;
$var = 1;
?>
<?php ?>

Output:


<?php  ?>

 /**
 * comment
 */<?php
/**
 * comment
 */
?>
$var = 0;
$var = 1;
?>

Additional examples (links go to playground variations):

  • Add a blank line between the first two <?php ?> blocks: Works correctly.
  • Remove all blank lines between <?php ?> blocks: Works correctly (mostly, whitespace)
  • Add a single character to the comment (comments): Works correctly (mostly, whitespace)
  • Add two characters to the comment (commentss): Broken

I didn't run into this with empty PHP blocks, here's the are some examples with code in the PHP blocks, behavior appears to be the same:

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

Beginne damit, die gemeldete Duplizierung von mehrzeiligen Kommentaren mit dem verknüpften Playground-Beispiel zu reproduzieren, und vergleiche anschließend die aufgeführten Variationen mit Leerzeilen, Kommentarlänge und Codeblöcken. Verfolge den für Kommentare und PHP-Blockgrenzen verantwortlichen PHP-Formatierungspfad. Als erledigt gilt die Aufgabe, wenn der Kommentar einmal ausgegeben wird und in den gemeldeten Fällen innerhalb des PHP-Blocks bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
php
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 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.