Skip to content

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

Open
@sirbrillig

Description

@sirbrillig
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions