Php-cs-fixer: Add "remove_unneeded_parentheses" - feature request

Created on 6 Jun 2020  路  4Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

Feature request for "remove_unneeded_parentheses".

Very important rule to allow to remove unneeded parentheses when:

  • code is generated as generated code like:
    throw (new Exception(('string')));
  • overused manually like:
    return ($v > 0) ? ($a + 1) : ($b - 1);
kinfeature request

Most helpful comment

Let's have some features merged first (as we have 31 opened feature pull requests, when I write this message) and then add NoUselessParenthesisFixer here.

All 4 comments

Let's have some features merged first (as we have 31 opened feature pull requests, when I write this message) and then add NoUselessParenthesisFixer here.

Is it now the good time? :)

Sure ;)

How about making a no_unneeded_parentheses fixer with options so that no_unneeded_control_parentheses can be deprecated and be a proxy till we remove it on 3.0 in favor of the more generic new no_unneeded_parentheses?

I would also like to see the most basic ones cleaned up, like; echo 2 + foo(( 1 )) + 1;

How about making a no_unneeded_parentheses fixer with options so that no_unneeded_control_parentheses can be deprecated and be a proxy till we remove it on 3.0 in favor of the more generic new no_unneeded_parentheses?

I agree, now we can merge as proxy and possibly replace https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/d658dc0201bdd457d32fc412d810885f282ac064/src/RuleSet.php#L109 with the new no_unneeded_parentheses with BC settings).

In 3.0, we can change the Doctrine ruleset with more stricter/breaking settings.

Was this page helpful?
0 / 5 - 0 ratings