prettier / prettier/plugin-php
Format multiple-catch
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
We're currently not respecting line length limitations in multiple-catch blocks, which we could.
@prettier/plugin-php v0.14.0
Playground link
Input:
<?php
try {
do_something();
} catch (\Some\Rather\Obscure\Exception | \Another\Obscure\Exception $exception) {
handle_exception();
}
Current Output:
<?php
try {
do_something();
} catch (\Some\Rather\Obscure\Exception | \Another\Obscure\Exception $exception) {
handle_exception();
}
Improved Output:
<?php
try {
do_something();
} catch (
\Some\Rather\Obscure\Exception |
\Another\Obscure\Exception $exception
) {
handle_exception();
}
To be honest, the improved output is not perfect (the $exception variable is a little bit "obscured" next to the exception class), but it's better than the current behavior IMO.
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 provided Playground reproduction and search the PHP printer for multiple-catch formatting; no file or test is named in the issue. Done means the exception list wraps to respect the configured line length while preserving the shown catch-block structure, with the relevant formatter tests passing.
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