Skip to content

Analysis of array passed to array_search takes prohibitively long with huge arrays #8147

Closed

Description

@bart-mollie

Bug report

After upgrading from PHPStan 1.8.2 to 1.8.8, and the CI pipeline that runs PHPStan started timing out. With --debug I isolated the issue to be in a classes that contain huge array constants. In the newer versions they take prohibitively long to analyse.

@rvanvelzen commented that it's caused by the analysis of the array_search call.

Code snippet that reproduces the problem

https://phpstan.org/r/46a17e15-22a3-414a-b8d7-c27617d5ac5b.

This does not fail yet, but with around 2000 entries in the array it times out (and then I can't shared the link). I've attached a sample with 10k entries that takes 66 seconds to analyse on it's own on my dev machine.

Expected output

I expected the size of the array not affect the analysis time this much, especially when it's type is annotated.

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

It's absolutely amazing and a complete paradigm shift for php.

HugeMapClass.php.txt

Activity

  1. ondrejmirtes commented on Oct 11, 2022

    @ondrejmirtes
    Member
  2. github-actions commented on Nov 12, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  3. locked as resolved and limited conversation to collaborators on Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions