Skip to content

Callable signature types cannot be used as template bounds #15273

Description

@klimick

Bug report

Callable signature types cannot be used as template bounds.
In particular, Closure(int): int, callable, and callable(int): int bounds are rejected when the template type is used for a natively typed Closure or callable parameter, even though a concrete closure can satisfy these bounds.

Code snippet that reproduces the problem

https://phpstan.org/r/142a3689-bc7a-4a5b-a612-1c0c3e199c20

Expected output

Callable types should be usable as template bounds, and the concrete type inferred for the template should be preserved.
In this example, static-Closure(int): int satisfies all four template bounds, so all four calls should infer:
static-Closure(int): int

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

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions