-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Squiz.Functions.FunctionDeclarationArgumentSpacing fixer removes comment between parens when no args #2006
Comments
As an aside, you may want to document the variable arguments explicitly. Further details in this stackoverflow question. |
Right, I recognize there's other stuff I can do with this code, but I feel like both of my thoughts are still valid. |
Yes, it should only be making whitespace changes. In cases like this encountered in other sniffs, the sniff will actually report that the error is not fixable.
The sniff detected that the function has no arguments, but then assumes the content between the parenthesis must be spaces. It doesn't really matter if it checks spaces after the opener or before the closer (it used the closer) because it should be the same amount of whitespace. But the comment is tripping it up and it finds no spaces before the closer, hence the weird error message. I don't think the sniff should actually be throwing an error in this case as it is only trying to stop code like |
…fixer removes comment between parens when no args
The change I've made treats Thanks for reporting this. |
And thank you for getting in a fix! |
Interesting case I hit with SpacingBetween.
I have this code where in place of the parameters, there's a comment there that is meant to show that an arbitrary number of parameters can be passed into the function, as at a later point, it calls into another function with the result of
func_get_args()
:When running Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBetween on this, I get an interesting message with PHPCS:
"Expected 0 spaces between brackets of function declaration; 0 found"
When running that rule with the PHPCBF, it ends up removing the comment so it's just
bar()
.So beside the argument on whether the comment itself should or should not be there, I have some thoughts about this:
Thanks for the consideration.
The text was updated successfully, but these errors were encountered: