Skip to content

Generic (conditional) type behaviour with anonymous function #11055

Closed Answered by ondrejmirtes
uuf6429 asked this question in Support
Discussion options

You must be logged in to vote

You need this instead: https://phpstan.org/r/59b020d9-976e-43ac-8a20-c5c0b3284336

It's one of the examples in the docs: https://phpstan.org/blog/generics-by-examples#function-accepts-any-string%2C-but-returns-object-of-the-same-type-if-it%E2%80%99s-a-class-string

The fact that first-class callable doesn't work is a bug, please open a bug report, thanks.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by uuf6429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants