squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.66k stars 1.48k forks source link

Generic/FunctionCallArgumentSpacing: prevent fixer conflict over PHP 7.3+ trailing comma's in function calls #3805

Closed jrfnl closed 1 year ago

jrfnl commented 1 year ago

Reported via Mastodon by @WyriHaximus: https://phpc.social/@wyri@haxim.us/110224066521542315

As of PHP 7.3, trailing comma's in function calls are allowed.

This sniff should leave those alone to prevent fixer conflicts with sniffs dealing with the spacing around the parentheses of a function call, like the PEAR.Functions.FunctionCallSignature sniff, which this sniff is often combined with.

While the sniff did take trailing comma's into account for multi-line function calls, it did not handle them correctly for single-line function calls.

Note: too much space can still be removed, but space should not be added.

Fixed now.

Includes tests.

jrfnl commented 1 year ago

Merged manually.

jrfnl commented 9 months ago

FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).