Skip to content

Type array<mixed> should be equivalent to array<int|string, mixed> #12051

@thg2k

Description

@thg2k

Bug report

Trying out PHPStan v2.0.1, I started noticing in various reports the type array<mixed, mixed>. I believe the largest possible array value is array<int|string, mixed>, so should it even be possible to instantiate a type larger than that?

I ran into the following error which, unless I'm missing something, makes no sense:

Parameter #1 $a of function foo expects array<int|string, mixed>, array<mixed> given.
  argument.type                                                                      

Type array<mixed> should always be equivalent to array<int|string, mixed>.

Code snippet that reproduces the problem

https://phpstan.org/r/b6e2e23b-0605-4956-bced-a5b8be0682de

Expected output

No error

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