Skip to content

Comma after last argument in single line call creates fix failure #3588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mabar opened this issue May 6, 2022 · 2 comments
Closed

Comma after last argument in single line call creates fix failure #3588

mabar opened this issue May 6, 2022 · 2 comments

Comments

@mabar
Copy link

mabar commented May 6, 2022

Describe the bug
When comma is used after last argument in call, following sniffs report an issue and fail to fix it. It is caused by these sniffs colliding with each other.

Code sample

call($arg,); // Reports Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma
call($arg, ); // Reports PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket

Custom ruleset

<?xml version="1.0"?>
<ruleset>
  <rule ref="PSR2.Methods.FunctionCallSignature"/>
  <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
</ruleset>

To reproduce
Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcbf test.php ...
  3. See error message displayed
PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
test.php                                              FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 0 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Expected behavior
Fixes the error without failure.

I believe it could be fixed in Generic.Functions.FunctionCallArgumentSpacing by allowing no space after comma, when comma is followed by right parenthesis. - call($arg,) should be okay.

The comma itself can be removed by SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall sniff.

Versions:

  • OS: Windows 10 - WSL 2.0
  • PHP: 8.0.15
  • PHPCS: 3.6.2
  • Standard: custom
@jrfnl
Copy link
Contributor

jrfnl commented May 9, 2022

Duplicate of #3477 ?

@mabar
Copy link
Author

mabar commented May 9, 2022

Yes, it seems to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants