-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
AbstractFunctionRestrictionsSniff::is_targetted_token() incorrectly treats first class callable as a function call #2478
Comments
@rodrigoprimo Well, no. The abstract tries to determine whether a function is being used, not whether it is called. That includes recognizing
That's something to think about. Should the sniffs using that method handle this potential situation ? Should the Also note that the WPCS native abstracts will be phased out once the planned (and fully tested) abstracts in PHPCSUtils will be available.
At this time, the abstracts are tested via the sniffs, in particular via the |
@jrfnl, maybe then the short description of the DocBlock for
My understanding is that the That being said, I also see some reasons that make me wonder if it is worth doing this change at this point:
What do you think?
Thanks for the additional context. I agree that it doesn't make sense to add dedicated tests as those abstracts will be replaced. |
Bug Description
The method
AbstractFunctionRestrictionsSniff::is_targetted_token()
is used to determine if a given token is a function call or not. It does not handle first class callables properly and identifies them as function calls, which is incorrect.I found this while using
AbstractFunctionParameterSniff::process_no_parameters()
to create the sniff for #2473.AbstractFunctionParameterSniff
is affected by this bug and sees first class callables as a function call without parameters.Loosely related to this PHPCSUtils PR: PHPCSStandards/PHPCSUtils#362
Minimal Code Snippet
The issue happens when running this command:
Over a file containing this code:
Error Code
Environment
develop
branchAdditional Context (optional)
I can try to create a PR to fix this problem, but it seems there are no tests for the
AbstractFunctionRestrictionsSniff::is_targetted_token()
and for the rest of theAbstractFunctionRestrictionsSniff
. I believe it would be important to start by creating tests first.Tested Against
develop
Branch?develop
branch of WordPressCS.The text was updated successfully, but these errors were encountered: