prettier / prettier/plugin-php
Unstable runs: comment in php tag mixed with html
Personne n'a encore pris cette issue.
- Langage dominant
- PHP
- Étoiles
- 1.9k
- Forks
- 139
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
When prettier-php has a comment directly after <php, it reformats the comment on each successive run, resulting in strange behaviour. The most bizarre is copying the line on each successive run of prettier.
note: By stable, I mean the second time you run prettier, it doesn't change the files. If there's a better word for this, I'm happy to change my description.
This bug is captured in a comment on another issue. However, due to this bug breaking a core properties of prettier, stable transformations, I think it's worth its own issue.
similar bugs:
- https://github.com/prettier/plugin-php/issues/2419 - does not have the unstable element
- https://github.com/prettier/plugin-php/issues/2380 - similar, but does not have the unstable element
Prettier 3.5.3
PHP Plugin 0.22.4
# Options (if any): None
module.exports = {
plugins: ["@prettier/plugin-php"],
};
Example 1
Input:
<?php
/**
* The template for displaying the footer
*/
?>
<div class="footer">
<?php
// Footer
get_template_part("template-parts/footer", "2022"); ?>
</div>
<?php wp_footer(); ?>
Output run 1:
<?php
/**
* The template for displaying the footer
*/
?>
<div class="footer">
<?php // Footer
get_template_part("template-parts/footer", "2022"); ?>
</div>
<?php wp_footer(); ?>
Output run 2:
<?php
/**
* The template for displaying the footer
*/
?>
<div class="footer">
<?php // Footer
// Footer
get_template_part("template-parts/footer", "2022"); ?>
</div>
<?php wp_footer(); ?>
Output run 3: each successive run adds a new line with // Footer
Example 2
Input:
</main><!-- #main -->
</div><!-- #primary -->
<?php
// get_sidebar();
get_footer();
Output run 1:
</main><!-- #main -->
</div><!-- #primary -->
<?php // get_sidebar();
get_footer();
Output run 2:
</main><!-- #main -->
</div><!-- #primary -->
<?php // get_sidebar();
get_footer();
Example 3
Input:
<header class="page-header">
<h1 class="page-title">
<?php
/* translators: %s: search query. */
printf(
esc_html__("Search Results for: %s", "gpo18"),
"<span>" . get_search_query() . "</span>"
); ?>
</h1>
</header><!-- .page-header -->
Output run 1:
<header class="page-header">
<h1 class="page-title">
<?php /* translators: %s: search query. */
printf(
esc_html__("Search Results for: %s", "gpo18"),
"<span>" . get_search_query() . "</span>"
); ?>
</h1>
</header><!-- .page-header -->
Output run 2:
<header class="page-header">
<h1 class="page-title">
/* translators: %s: search query. */<?php
/* translators: %s: search query. */
printf(
esc_html__("Search Results for: %s", "gpo18"),
"<span>" . get_search_query() . "</span>"
); ?>
</h1>
</header><!-- .page-header -->
Output run 3:
<header class="page-header">
<h1 class="page-title">
/* translators: %s: search query. */ /* translators: %s: search query. */<?php
/* translators: %s: search query. */
printf(
esc_html__("Search Results for: %s", "gpo18"),
"<span>" . get_search_query() . "</span>"
); ?>
</h1>
</header><!-- .page-header -->
cc: @movva-gpu
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Reproduisez les trois exemples avec Prettier 3.5.3 et PHP Plugin 0.22.4, en commençant par des commentaires immédiatement après la balise PHP. Suivez le chemin du formateur qui gère PHP et le HTML mixte, puis ajoutez une couverture de régression pour les exemples ; le travail est terminé lorsque des formatages répétés produisent une sortie identique et qu’aucune ligne de commentaire n’est dupliquée ou déplacée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- php
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100