Skip to content

Collapsing of \Closure / callable types fails  #10594

@krchiper

Description

@krchiper

Bug report

The type \Closure(string)|\Closure(string, string) is collapsed to \Closure(string, string), with the assumption that \Closure(string) is covered by \Closure(string, string). This seems wrong, when considering optional parameters.

It's true that

$closure("Hello", "World");

can be passed to \Closure(string) as extranous parameters are ignored by php. But considering \Closure(string, int=) the above doesn't hold and produce an error.

Code snippet that reproduces the problem

https://phpstan.org/r/f502c295-dde6-4647-9dd7-1f4bd1ba6219

Expected output

I would expect \Closure(string)|\Closure(string, string) to not be collapsed to \Closure(string, string)

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

Of course it did

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions