prettier / prettier/plugin-php

[BUG] Please remove Unnecessary Parenthesis like Foo;

Open
#2,454 3 comments 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.