Skip to content

Type inference after using array_pop could be improved. #7804

@mad-briller

Description

@mad-briller

Feature request

In the below case, using array_pop makes phpstan believe the $headers value could be an empty array, when prior it knew that there were atleast 4 values.
array_pop always removes one element from the array and as such the second count() value could return int<3, max> in this case, and also persist the non-empty-array type.

https://phpstan.org/r/5003d274-3690-464e-a5e1-6e898cd00411

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions