WordPress-Coding-Standards
WordPress-Coding-Standards copied to clipboard
Review sniff handling of PHP 7.3 list() reference assignment
Since PHP 7.3 it's possible to use reference assignment with list()
.
Code like
$array = array( 1, 2 );
list( $a, &$b ) = $array;
Won't throw Fatal error: [] and list() assignments cannot be by reference
. That means you'd be able to do something like this:
$array = array(1, 2);
list($a, &$b) = $array;
$b = 4;
And the resulting $array
would be [1, 4]
.
PHPCSUtils lists util, already has support for detecting this so we need to examine where lists are used in WPCS, add examples and modify the sniffs to use Utils for this.
From a quick look prefix all globals sniff could be affected by this change so we need to take a look at it.
Refs:
- PHP RFC: https://wiki.php.net/rfc/list_reference_assignment
Related to #764