Skip to content

array-key is not inferred for TKey when checked for Traversable first #4498

@simPod

Description

@simPod

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions