Replace \Closure(...) with \Closure(mixed...)#451
Replace \Closure(...) with \Closure(mixed...)#451
Conversation
|
The |
|
I originally removed this syntax to support PHPStan: 138801f So this has now changed? |
|
🤦🤦🤦 Well, the only thing I can tell is that with |
|
In fact my solution is wrong: https://phpstan.org/r/9c17bb5f-4087-4201-b684-72a28b0e069c . PHPStan is correct: you cannot pass a This is how Here's the possible solution:
https://phpstan.org/r/4e98ea03-a863-4b39-8fcf-07cfdc2e8ea4 |
You cannot pass a Closure with narrower parameters to a Closure with wider parameters, since parameters are contravariant. Here's the possible solution: - for PHPStan use a Closure with a bunch of never parameters for to indicate that Closure might have parameters with any wider types and suppress the place where it is invoked, - for Psalm keep the current Closure(...) syntax, because Psalm does not allow to have never parameters. https://phpstan.org/r/4e98ea03-a863-4b39-8fcf-07cfdc2e8ea4 https://psalm.dev/r/cda9b2565b
See phpstan/phpstan#12954