prettier / prettier/plugin-php
multi-line comment duplicated, leaking outside PHP blocks
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
The obvious problem is that the multi-line comment is being duplicated and jumping outside the PHP block. But it's weirder, variations are below the main report example.
@prettier/plugin-php v0.11.2
Playground link
Input:
<?php ?>
<?php ?>
<?php
/**
* comment
*/
$var = 0;
$var = 1;
?>
<?php ?>
Output:
<?php ?>
/**
* comment
*/<?php
/**
* comment
*/
?>
$var = 0;
$var = 1;
?>
Additional examples (links go to playground variations):
- Add a blank line between the first two
<?php ?>blocks: Works correctly. - Remove all blank lines between
<?php ?>blocks: Works correctly (mostly, whitespace) - Add a single character to the comment (
comments): Works correctly (mostly, whitespace) - Add two characters to the comment (
commentss): Broken
I didn't run into this with empty PHP blocks, here's the are some examples with code in the PHP blocks, behavior appears to be the same:
- Code blocks,
comment: Broken - Code blocks,
comments: Works correctly (mostly, whitespace - Code blocks, no blank lines: Works correctly (mostly, whitespace)
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 reported multi-line comment duplication with the linked Playground example, then compare the listed variations involving blank lines, comment length, and code blocks. Trace the PHP formatting path responsible for comments and PHP block boundaries. Done means the comment is emitted once and remains inside the PHP block across the reported cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100