Skip to content

False positive "non-empty-array<int, int> might not be a list" when change existing list key #13035

@LastDragon-ru

Description

@LastDragon-ru

Bug report

If we set the existing list key, the array still be a list, but phpstan thinks that it is not true.

if (isset($this->list[$offset])) {
	$this->list[$offset] = 123; 
	// `$this->list` still a list
}

Code snippet that reproduces the problem

https://phpstan.org/r/32e2baf1-42ba-4494-9500-13459f0d33b7

Expected output

No error.

Did PHPStan help you today? Did it make you happy in any way?

Yep 🤗

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions