Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Assignment to array element reference does not count as a write #319

Open
sirbrillig opened this issue Mar 27, 2024 · 0 comments
Open

Assignment to array element reference does not count as a write #319

sirbrillig opened this issue Mar 27, 2024 · 0 comments

Comments

@sirbrillig
Copy link
Owner

static function dotToMultiArray(
	array $array
): array {
	$multi = [];
	foreach($array as $key => $value){
		$level = &$multi;
		foreach(explode(".", $key) as $node)
			$level = &$level[$node];
		$level = $value;
	}
	return $multi;
}

This marks $level as unused but the third assignment actually changes the referenced variable.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant