-
Notifications
You must be signed in to change notification settings - Fork 40
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
Hooks logic fails for short array syntax #358
Comments
The line of logic is: elseif ( 'T_ARRAY' === $this->_tokens[ $callbackPtr ]['type'] ) which presumably misses checking for an array of the |
It's not as simple as adding a check for Ideally, we want to be able to use this WPCS method to accurately handle this. See #359 for how this might be possible. |
Now that #377 is merged, we can use the WPCS method to fix/improve our sniff. |
WPCS 3.0 will likely that utility method, as it will depend on the utility methods in PHPCSUtils instead. Good news is, after #474 is done, we can use these PHPCSUtils utility methods ourselves. |
As VIPCS is currently using WPCS 2.x, we can use the WPCS `Sniff::find_array_open_close()` method to get the opener/closer for an array independently of the type of array (long/short). Once VIPCS implements PHPCSUtils, this method call should be swopped out for the PHPCSUtils `Arrays::getOpenClose()` method. Addresses #358 for the `AlwaysReturnInFilter` sniff. Includes unit tests.
As VIPCS is currently using WPCS 2.x, we can use the WPCS `Sniff::find_array_open_close()` method to get the opener/closer for an array independently of the type of array (long/short). Once VIPCS implements PHPCSUtils, this method call should be swopped out for the PHPCSUtils `Arrays::getOpenClose()` method. Addresses #358 for the `PreGetPosts` sniff. Includes unit tests.
As VIPCS is currently using WPCS 2.x, we can use the WPCS `Sniff::find_array_open_close()` method to get the opener/closer for an array independently of the type of array (long/short). Once VIPCS implements PHPCSUtils, this method call should be swopped out for the PHPCSUtils `Arrays::getOpenClose()` method. Addresses #358 for the `PreGetPosts` sniff. Includes unit tests.
Changing to short array syntax in
Tests/Hooks/AlwaysReturnInFilterUnitTests.inc
andTests/Hooks/PreGetPostsUnitTests.inc
result in those tests failing.It suggests that some of the processing logic in each sniff is flawed for short array syntaxes.
Both long and short array syntax should be retained in the unit tests.
Environment
Use
php -v
andcomposer show
to get versions.master
Tested Against
master
branch?master
branch of VIPCS.The text was updated successfully, but these errors were encountered: