Skip to content

array<string, mixed>/array<int, mixed> accepts array<array-key, mixed> #9750

@LastDragon-ru

Description

@LastDragon-ru

Bug report

The array<string, mixed> and array<int, mixed> accepts array<array-key, mixed> (even in Strict Mode). The array<string|int, mixed> will throw error as it should (see https://phpstan.org/r/1633c836-5f7a-46c3-ae91-08b5b5f768b8).

Code snippet that reproduces the problem

https://phpstan.org/r/40b6815d-8143-4ef7-bf30-62cc18c0dfa6

Expected output

Parameter #1 $array of method HelloWorld::bug() expects array<string, mixed>, array<array-key, mixed> given.argument.type

Parameter #1 $array of method HelloWorld::bug2() expects array<int, mixed>, array<array-key, mixed> given.

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

Yep. It helps a lot while new package development.

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