Skip to content

List + unset last item is not a list anymore #12768

@rudiedirkx

Description

@rudiedirkx

Bug report

Phpstan thinks $arr after unset($arr[n]); is never a list anymore, but that's not true if n is the last item.

Code snippet that reproduces the problem

https://phpstan.org/r/06411cac-e555-47a5-adbe-35c67b527741

Expected output

No error. array{0: 1, 1: 2, 2?: 3} is a list. With the phpdoc certain checkbox checked it's even more obvious: array{1, 2} is definitely a list.

More realistic but less readable example: https://phpstan.org/r/7375b8d0-2bc7-4ec5-a179-2459434273d2

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions