Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
LastDragon-ru opened this issue Aug 11, 2023 · 3 comments
Closed

Comments

@LastDragon-ru
Copy link

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.

@ondrejmirtes
Copy link
Member

@LastDragon-ru
Copy link
Author

See: https://phpstan.org/config-reference#checkbenevolentuniontypes

Ahah, cool. Thanks :)

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants