Skip to content

Oversized constant array is too much simplified and doesn't use the @var annotation. #10717

@VincentLanglet

Description

@VincentLanglet

Bug report

Hi,

When using @phpsan-var array<...> over a constant array, we get analysis about the values
https://phpstan.org/r/6ac176b2-3a05-43b6-9e9b-4b4dab715c87

PHPDoc tag @var for constant ... with type array<...> is not subtype of value array{...}.

which means that the @var is read and used.

When the array is oversized, I would expect phpstan to use the simplification provided in the @var annotation rather than the one computed by phpstan which are too much simplificed.

Code snippet that reproduces the problem

https://phpstan.org/r/048423be-a2da-4f17-9c3e-954c5d1f438f

Expected output

Rather than non-empty-array<literal-string&non-falsy-string, 'Faroese'|'fo'|'Føroyskt'|false>&oversized-array

I'd like something like array<string, array{code: string, english: string, local: string, rtl: bool, country: string, variant: bool}>.

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