prettier / prettier/plugin-php
Bug: Prettier will remove parenthesis around new objects calling a function
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
If I have a line like so:
$timestamp = (new DateTimeImmutable())->format(DATE_ATOM);
Prettier will reformat it as:
$timestamp = new DateTimeImmutable()->format(DATE_ATOM)
which is not valid PHP code.
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 PHP snippet from the issue and trace the formatter's handling of parenthesized new-object expressions and chained method calls. Done means Prettier preserves the parentheses required for valid PHP output and a regression test covers this example.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100