Skip to content

False positive with array_push/array_unshift and count($array[$key]) in a loop #3387

@nobuf

Description

@nobuf

Bug report

While $array[$key][] works fine, array_push/array_unshift with count($array[$key]) returns a fixed value in a loop. As a result, it gets an error: Comparison operation ">" between 1 and 1 is always false.

Code snippet that reproduces the problem

https://phpstan.org/r/dae26e88-0e7c-4b0e-bb31-e58cea1de089

Expected output

No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions