Skip to content

Oversimplified huge const array #8636

Closed

Description

@ddebin

Bug report

Do you think we can disable the new optimization for huge const arrays?

Don't know if it can be considered a bug but my const is now oversimplified and the array shape is not guessed as precisely as it used to be with PHPStan <1.9.5.

Code snippet that reproduces the problem

https://phpstan.org/r/ba75c9cd-8683-421d-8996-742e72c108ea

Expected output

No error!

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

For sure, it's an amazing and helpful tool. 👏

Activity

  1. added this to the Easy fixes milestone on Jan 3, 2023
  2. VincentLanglet commented on Jan 8, 2023

    @VincentLanglet
    Contributor

    Do you think we can disable the new optimization for huge const arrays?

    What could be interesting maybe is to provide configuration for constants like

    ConstantArrayTypeBuilder::ARRAY_COUNT_LIMIT
    
  3. phpstan-bot commented on Oct 6, 2024

    @phpstan-bot
    Collaborator

    @ddebin After the latest push in 2.0.x, PHPStan now reports different result with your code snippet:

    @@ @@
    -309: Method Config::huge() should return string but returns array<int, string>|string.
    +309: Method Config::huge() should return string but returns list<string>|string.
    Full report
    Line Error
    309 `Method Config::huge() should return string but returns list
  4. phpstan-bot commented on Apr 27, 2026

    @phpstan-bot
    Collaborator

    Closed via merging phpstan/phpstan-src#5555

  5. github-actions commented on May 29, 2026

    @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.

  6. locked as resolved and limited conversation to collaborators on May 29, 2026
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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions