Skip to content

List assignment next to array causes unused variable warning #317

Closed
@djibarian

Description

@djibarian

This bit is throwing a VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable false positive for $notificationId. It seems it has to do with array destructuring the result, because if changed to $bar it disappears.

static function foo(DBC $db, int $notificationId): void {
	[$bar] = $db->queryGetRowIndexed("
		SELECT blah...
	", [
		"n.notificationId" => $notificationId
	]);
}

And this one too, in $level, although in this case it looks related to that "self reference assignment":

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions