prettier / prettier/plugin-php
Invalid output caused by combo of if statement, inline node, and comment
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- PHP
- Sterne
- 1.9k
- Forks
- 139
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Input:
<?php
if (true) {
?>inline<?php
// comment
}
Output:
<?php
if (true) { ?>inline<?php
// comment
// comment
?>}
Note the extra closing tag that has been added, which makes the code invalid, and that the comment is duplicated, which is unexpected.
If you comment out this line, it doesn't print out the closing tag that breaks the code, but it also removes the closing tag from the test file inline3.php.
If you comment out the line above, prettier throws the following error, I think about inline3.php again.
Comment "// test" was not printed. Please report this error!
I've tried to debug, but the printing system is quite large. I'll still keep looking, but might as well put it out to the community too!
Problem aslo with
<!DOCTYPE html>
<html lang="de">
<head>
<?php /* ups */
if (1==1)
{
echo 'FOO';
} ?>
</head>
<body>
</body>
</html>
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 in src/printer.js bei etwa den Zeilen 1362–1363 und reproduziere die bereitgestellten PHP-Fälle. Vergleiche die Ausgabe mit tests/comments/inline3.php, insbesondere das Verhalten des Inline-Schließ-Tags. Als erledigt gilt die Aufgabe, wenn der Formatter das erforderliche Schließ-Tag beibehält, ohne ein ungültiges zusätzliches Tag hinzuzufügen oder Kommentare zu duplizieren, während die bestehende Erwartung in inline3.php weiterhin gültig 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
- 35/100