prettier / prettier/plugin-php
Invalid output caused by combo of if statement, inline node, and comment
Nessuno ha ancora preso questa issue.
- Lingua principale
- PHP
- Stelle
- 1.9k
- Fork
- 139
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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>
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in src/printer.js intorno alle righe 1362-1363 e riproduci i casi PHP forniti. Confronta l'output con tests/comments/inline3.php, in particolare il comportamento del tag di chiusura inline. Il lavoro è completato quando il formatter preserva il tag di chiusura richiesto senza aggiungere un tag extra non valido né duplicare i commenti, mentre l'aspettativa esistente di inline3.php rimane valida.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100