-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Generic/FunctionCallArgumentSpacing: improve code coverage #497
Generic/FunctionCallArgumentSpacing: improve code coverage #497
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rodrigoprimo !
The changes as-is are fine.
Having said that, I do think, there are more tests missing, all related to more modern PHP.
There are no tests with attributes, while the sniff does act on them:
#[AttributeName(1,2)]
There are no tests with first class callables. While these would not lead to errors being reported or false positives, I still think it would be good to have a test covering that code as the sniff will be triggered for them.
$callable = myCallable(...);
Other than that (not to be addressed in this PR):
The sniff skips over closures, anon classes and (short) arrays which may be passed as a parameter in a function call. It does so to prevent checking the spacing around commas in these (nested) structures, which may have their own rules.
The sniff, however, does not skip over inline match
control structures, while I think that it should.
The sniff also doesn't skip over arrow functions, while I believe it should do so too. For arrow functions, I can't come up with a code sample which would lead to false positives as any commas would always have to be in nested parentheses or within a short array/match. Having said that, I think skipping them is still the right choice as it makes the sniff slightly more efficient.
Either way, I've prepped a PR to fix these last two (as writing up the issue reminder would take me longer than creating the PR) and will pull that once this PR has been merged (to prevent creating a conflict).
Thanks for the review, @jrfnl!
I added the tests that you suggested. Regarding the attributes, I added the test you shared that triggers the sniff, and I also added another test that does not trigger the sniff to document the expected behavior. I did not add more tests as it seems to me, for the purposes of this sniff, the attributes behave just like a function call. |
Well, technically, both code samples trigger the sniff, but only one will trigger an error from the sniff.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rodrigoprimo !
I will rebase and squash the last commit before merging.
Doing this to be able to create tests with syntax errors on separate files
9bd569b
to
e9b9777
Compare
FYI: I've pulled the follow up mentioned in one of my previous comments as PR #513 |
Description
This PR improves code coverage for the Generic.Functions.FunctionCallArgumentSpacing sniff.
Related issues/external references
Part of #146
Types of changes
PR checklist