Skip to content

Incorrect generic type resolution #10612

@Creeperface01

Description

@Creeperface01

Bug report

In attached example, the first error in the associate function started happening only in quite recent versions of phpstan and worked fine until then.

The issue here is that even phpstan sees the $key variable as int, for some reason it's interpreted as int|string when passed as array key in the associate function

Code snippet that reproduces the problem

https://phpstan.org/r/617a52bd-892c-4ef5-8b98-11713751784a

Expected output

The type of array key should be int as well

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions