prettier / prettier/plugin-php
[BUG] Please remove Unnecessary Parenthesis like Foo;
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 139
- PR merge metrics
- No merged PRs in 30d
Description
**Prettier 3.8.1 (lastest) **
PHP Plugin 0.24.0
# Options (if any):
--php-version 8.3
--single-quote
Input:
// TRUE
echo (match ('option1') {
'option1' => fn() => 'First',
'option2' => fn() => 'Second',
})();
// code snippet
$x = new Foo; // True style
$y = new Foo(1); // True style
$z = (new Foo)->value; // True style
Output:
// ERROR
echo match ('option1') {
'option1' => fn() => 'First',
'option2' => fn() => 'Second',
}();
$x = new Foo(); // False sytle: I don't want add ()
$y = new Foo(1); // True style
$z = (new Foo())->value; // False style: I don't want add ()
Expected behavior:
I dont want add unnecessary parenthesis
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 snippets with Prettier 3.8.1, PHP Plugin 0.24.0, PHP 8.3, and the stated options. Compare formatting for the match expression and each new Foo example; done means unnecessary constructor and access parentheses are not added while the other formatting remains correct, with regression coverage for these cases.
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
- 55/100