Skip to content

array_pop/array_shift false positive #2851

@dereuromark

Description

@dereuromark

Bug report

array_* false positive

while (count($arguments) > 0) {
	$words .= array_pop($arguments);
	if (count($arguments) > 0) {
		$words .= ' ';
	}
}

Code snippet that reproduces the problem

$arguments = ['x', 'y'];

$words = '';
while (count($arguments) > 0) {
	$words .= array_pop($arguments);
	if (count($arguments) > 0) {
		$words .= ' ';
	}
}

echo $words;

https://phpstan.org/r/172e2161-c350-4466-8867-de074489c34f

Expected output

No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions