Skip to content

Conditional while loop causes wrong assumption about array's contents #3314

@gmta

Description

@gmta

Code snippet that reproduces the problem

https://phpstan.org/r/49a3d04d-8e39-4420-b0cd-66a0db7fa541
Old example: https://phpstan.org/r/0eededac-4378-4914-8928-ce5cb34cba85

Problem

The fact that the contents of the while block is never executed is not taken into account, leading PHPStan to incorrectly conclude that the first entry of the array is always present and has a constant value.

Still an issue as of PHPStan version 0.12.28.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions