Skip to content

First-class closure return type not resolved correctly #11056

@uuf6429

Description

@uuf6429

Bug report

The return type of generic first-class closures doesn't seem to resolve correctly.

Wrapping them in an arrow function or anonymous function seems to bypass the problem.

The type of closure (method, static method or function) doesn't seem to make a difference.

(discovered in #11055 (comment))

Code snippet that reproduces the problem

https://phpstan.org/r/3ac8de30-a9c4-4c59-b5eb-fe58291e30f5

Expected output

In the given example, no errors/warnings were expected to be reported in PHP 8.3.

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

Yeah, managed to catch a couple of bugs that even testing didn't catch. 💪

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions