prettier / prettier/plugin-php
Issue in conditions followed by comments
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
I have such code:
<p>
<?php
if ($article['shop']['id'] === 10) { // TestShop
?>
<img alt="" src="test.png">
<?php
}
$this->load();
?>
</p>
and it's formatted to:
<p>
<?php
if ($article["shop"]["id"] === 10) {<?php
// TestShop
?>
<img alt="" src="test.png">
<?php }
$this->load();
?>
</p>
so - an invalid <?php is added
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 with the minimal PHP/HTML reproduction in the issue and compare its output using the linked Prettier PHP playground. Trace how a comment after a conditional opening brace is handled during formatting. Done means the formatter no longer inserts an invalid <?php tag and produces valid PHP/HTML output for this case.
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
- 48/100