Skip to content

Comparison operation ">" between X and Y is always true #3867

@RubenAtPA

Description

@RubenAtPA

Bug report

In this situation there is an array defined with a fixed number of elements. Within a do-while loop elements are taken of the stack with the method array_shift. Within the do body an if-statements can break from this loop and the while section of the loop tests for the number of remaining elements. PHPStan doesn't recognize this however and fails with the message Comparison operation ">" between X and Y is always true.

Code snippet that reproduces the problem

https://phpstan.org/r/911404cc-308a-4334-ad23-a180a5dfccb7

Expected output

The error should not have been reported, because the list can be exhausted and will return false eventually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions