Skip to content

Passing some combinations of union types to parameter types messes up the closure param type inference #5675

@canvural

Description

@canvural

Bug report

Passing some combinations of union types seems to break the closure param type inference.

For example, @param (\Closure(static<T>): void)|array<array-key, int> $column or @param (\Closure(Hello<T>): void)|array<array-key, int> $column works.
But * @param (\Closure(static<T>): void)|string|array<int, mixed> $column or @param (\Closure(static<T>): void)|array<array-key, int>|Bar $column does not work.

Code snippet that reproduces the problem

https://phpstan.org/r/24e0e585-9288-4b2a-95e9-8317dfd53426

Expected output

No error

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions