prettier / prettier/plugin-php
Improper body indentation for split inline tags
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- PHP
- Sterne
- 1.9k
- Forks
- 139
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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).
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 damit, die bereitgestellte PHP-Eingabe mit der aufgeführten Prettier- und PHP-Plugin-Konfiguration zu reproduzieren, und verfolge dann, wie geteilte Inline-Tags und die darin eingebetteten Ausdrücke formatiert werden. Erledigt ist dies, wenn die geteilten Ausdrücke eine konsistente Einrückung verwenden und das gewählte Verhalten durch einen Regressionstestfall für dieses Beispiel abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100