Skip to content
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

Review sniff handling of PHP 7.3 list() reference assignment #2041

Closed
dingo-d opened this issue Apr 22, 2022 · 1 comment
Closed

Review sniff handling of PHP 7.3 list() reference assignment #2041

dingo-d opened this issue Apr 22, 2022 · 1 comment

Comments

@dingo-d
Copy link
Member

dingo-d commented Apr 22, 2022

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:

Related to #764

@dingo-d dingo-d added this to the 3.0.0 milestone Apr 22, 2022
@jrfnl
Copy link
Member

jrfnl commented Aug 18, 2023

All sniffs have been reviewed and fixed to support modern PHP in as far as my imagination reached.

If any more situations would be discovered which need to be taken into account, a new issue should be opened with code samples etc.

Closing this now as fixed.

@jrfnl jrfnl closed this as completed Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants