Php-cs-fixer: Blank space after isset when using combine_consecutive_issets

Created on 21 Dec 2017  ·  3Comments  ·  Source: FriendsOfPHP/PHP-CS-Fixer

The PHP version you are using ($ php -v):

=> 7.1.12

PHP CS Fixer version you are using ($ php-cs-fixer -V):

=> 2.9.0

The command you use to run PHP CS Fixer:

=> php-cs-fixer fix . --rules=combine_consecutive_issets

The configuration file you are using, if any: -

If applicable, please provide minimum samples of PHP code (as plain text, not screenshots):

  • before running PHP CS Fixer (no changes):
if(isset($a) && isset($b)) {
...
}
  • with unexpected changes applied when running PHP CS Fixer:
if (isset($a, $b) ) {
...
}
  • with the changes you expected instead:
if (isset($a, $b)) {
...
}

I was just about to submit a fix for that, but I realize that even our tests have this space. Is this on purpose, or something that should be fix?

kinquestion

All 3 comments

cc @SpacePossum as author of rule

Hi @carusogabriel and thanks for opening this issue.

I've designed the fixer to do one thing (combining consecutive isset calls into one call) and nothing more. Keeping to the single responsibility principle comes with great benefits, especially in this project.

Removing the additional white space seems trivial but might become complex when a lot comments are around it or when other configuration options are applicable.

Therefore I left the white space handling to another dedicated fixer that was already present; no_spaces_inside_parenthesis
The priority system will make sure the end result is what you want.

Please let me know if you've more questions about this :+1:

@SpacePossum Thanks for your explanation. I’ll combine the two rules to achieve what I want 👨‍💻

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vitek-rostislav picture vitek-rostislav  ·  3Comments

OskarStark picture OskarStark  ·  3Comments

BackEndTea picture BackEndTea  ·  3Comments

amitbisht511 picture amitbisht511  ·  3Comments

ro0NL picture ro0NL  ·  3Comments