prettier / prettier/plugin-php
Multiple shorthand echoes in a row break when formatted
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
Prettier 2.4.0
PHP Plugin 0.18.4
Input:
<?= $var1 ?><?= $var2 ?>
Output:
<?=
$var1
$var2
?>
Expected behavior:
The above output does not work, it is fundamentally broken code.
There should be no change:
<?= $var1 ?><?= $var2 ?>
...or the variables should be concatenated:
<?= $var1 . $var2 ?>
Note that if there is a space in the middle, this works fine and is not changed:
<?= $var1 ?> <?= $var2 ?>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the adjacent shorthand echo input in the PHP formatter and compare it with the spaced variant, since the issue provides both cases. Trace the formatter entry point that handles consecutive PHP echo tags. Done means the no-space input remains valid—unchanged or safely concatenated—while the existing spaced case continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100