prettier / prettier/plugin-php
Improper body indentation for split inline tags
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
Prettier 2.2.1
PHP Plugin 0.16.1
{
"printWidth": 100,
"useTabs": true,
"semi": true,
"quoteProps": "consistent",
"trailingComma": "all",
"phpVersion": "7.4",
"braceStyle": "1tbs"
}
Input:
<div>
<p> some html </p>
<div>
<p>some more html with an inline element <?= htmlspecialchars("test") ?> and another inline element <?= htmlspecialchars("test") ?> with even more <?= htmlspecialchars("test") ?></p>
</div>
</div>
Output:
<div>
<p> some html </p>
<div>
<p>some more html with an inline element <?= htmlspecialchars(
"test",
) ?> and another inline element <?= htmlspecialchars(
"test",
) ?> with even more <?= htmlspecialchars("test") ?></p>
</div>
</div>
Expected behavior:
This is an issue of opinion so there are multiple solutions here, however, I think everyone would agree that all the parts should be indented the same (or at least identically).

The two htmlspecialchars that got split have different amounts of indentation on their closing parenthesis. Additionally, I would argue that the entire block should be indented the same, even if it produced something weird like:
<p>some more html with an inline element <?= htmlspecialchars(
"test",
) ?> and another inline element <?= htmlspecialchars(
"test",
) ?> with even more <?= htmlspecialchars("test") ?></p>
(which is weird HTML with the <p> being on the same line of a multi-line body, however, this is a PHP prettier plugin, not HTML).
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
Commencez par reproduire l’entrée PHP fournie avec la configuration indiquée de Prettier et du plugin PHP, puis suivez la manière dont les balises inline scindées et les expressions qu’elles contiennent sont formatées. Le travail est terminé lorsque les expressions scindées utilisent une indentation cohérente et que le comportement choisi est couvert par un cas de régression pour cet exemple.
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é
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100