You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Variables being assigned a value via the list() construct - including PHP 7.1 short list syntax - are not recognized as variable assignments for the purposes of the GlobalVariablesOverride and the PrefixAllGlobals sniffs.
This causes false negatives.
Minimal Code Snippet
The below code doesn't produce any errors for the above mentioned sniffs, while it should.
// PREFIX ALL GLOBALS.// Detect variables being set via the list() construct.list( $var1, $var2 ) = $array; // Bad x 2.list( $acronym_var1, $acronym_var2 ) = $array;
[ $var1, $var2 ] = $array; // Bad x 2.
[ $acronym_var1, $acronym_var2 ] = $array;
/** * GLOBAL VARS OVERRIDE. * Detect var override via list construct. */functionacronym_prepare_items() {
global$wp_query, $post_mime_types, $avail_post_mime_types, $mode;
list( $post_mime_types, $avail_post_mime_types ) = get_an_array(); // Bad x2.
[ $post_mime_types, $avail_post_mime_types ] = get_an_array(); // PHP 7.1 short list syntax, bad x2.
}
Tested Against develop branch?
I have verified the issue still exists in the develop branch of WPCS.
The text was updated successfully, but these errors were encountered:
Bug Description
Variables being assigned a value via the
list()
construct - including PHP 7.1 short list syntax - are not recognized as variable assignments for the purposes of theGlobalVariablesOverride
and thePrefixAllGlobals
sniffs.This causes false negatives.
Minimal Code Snippet
The below code doesn't produce any errors for the above mentioned sniffs, while it should.
Tested Against
develop
branch?develop
branch of WPCS.The text was updated successfully, but these errors were encountered: