prettier / prettier/plugin-php
Improve formatting of heredoc/nowdoc
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
As suggested in https://github.com/prettier/plugin-php/issues/1274#issuecomment-570709723:
I'd say, it would be The Prettier Way™ (and also the prettier way ) to figure out one way to print heredocs and to enforce that.
One process which sounds reasonable to me: If the starting tag goes on its own line, align the content with that. Otherwise indent it one
tabWidthfurther.Examples of the described rule
Example 1
The heredoc-opening tag goes on its own line.
Input:
some_function(<<<'EOT' Hello World! EOT );Current output:
some_function( <<<'EOT' Hello World! EOT );Envisioned output:
some_function( <<<'EOT' Hello World! EOT );Example 2
The heredoc-opening tag goes on the same line as the preceding code.
Input:
$string = <<<'EOT' Hello World! EOT;Current output:
$string = <<<'EOT' Hello World! EOT;Envisioned output:
$string = <<<'EOT' Hello World! EOT;
The first example is actually already printed correctly, but the second one isn't (playground)
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 linked playground examples for heredoc and nowdoc formatting, comparing the current and envisioned output. Done means the formatter consistently aligns content and closing tags according to whether the opening tag is on its own line or follows code, with coverage for the shown cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100