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-key is not inferred for TKey when checked for Traversable first #4498

Closed
simPod opened this issue Feb 6, 2021 · 2 comments
Closed
Labels
Milestone

Comments

@simPod
Copy link
Contributor

simPod commented Feb 6, 2021

https://phpstan.org/r/503cd642-f76c-469c-8b33-ba37f44d98ab

iterable(TKey, TValue) is passed to a function where check for instance of Traversable is performed and returned early in that case.

Flow after that should expect that the value is of type array<TKey of array-key, TValue) because type iterable = array|Traversable and therefore if the value is not Traversable, it's of type array for sure and its key must be of type array-key.

(this works so issue is in array-key for sure https://phpstan.org/r/2b2944c0-34bf-46f9-8ae6-d60e075fd92b)

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Feb 6, 2021
@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@c1f7aaf

@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 Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants