Skip to content

Performance regression involving array count check #12787

@crocodele

Description

@crocodele

Bug report

There's a severe performance regression between PHPStan versions 2.1.8 and 2.1.9 involving count() with big arrays. See the attached minimal code snippet, and change MAX_COUNT to 100_000_000. In 2.1.8, the analysis finishes almost instantly with very little memory usage. In 2.1.9, the analysis goes on and on until it crashes with the memory limit hit (8GB).

Code snippet that reproduces the problem

https://phpstan.org/r/1e4dbed4-d931-4415-8aed-4473e36f5d58

Expected output

Quick static analysis, no crash

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

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions