Variables/ServerVariables: various sniff improvements #850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Variables/ServerVariables: improve the tests
Variables/ServerVariables: use the correct terminology
The sniff looks for specific indexes/keys for array access.
This commit fixes some documentation and variable names used to use this terminology correctly.
Variables/ServerVariables: bug fix - incorrect quote stripping
As things were, quotes within a text string would also be stripped.
Not that it's very likely for any of the
$_SERVER
keys to ever have these, but that's beside the point.Variables/ServerVariables: bug fix - false positives on OO property access
While it should probably be considered bad practice, it is allowed to declare an OO property called
$_SERVER
and this sniff should not get confused by that.Includes tests.
Variables/ServerVariables: bug fix - faulty array key determination
The code to find the array index was flawed and could walk beyond the brackets of this array access.
Additionally, array access keys comprised of multiple tokens were not handled correctly.
Includes tests.
Note: WordPressCS has helper functions to retrieve the array access name, but those are marked as internal, which is the reason to introduce a custom function.
Variables/ServerVariables: bug fix - false negatives for
$GLOBALS['_SERVER']
The
$GLOBALS['_SERVER']
superglobals access is equivalent to using$_SERVER
, so should be examined too.Includes tests.
Closes #550