-
-
Notifications
You must be signed in to change notification settings - Fork 931
Closed
phpstan/phpstan-src
#2051Labels
Milestone
Description
Feature request
I have an event handler system where things that want to listen to an event can subscribe to it, by class.
This system also allows handlers to receive events which are of a subclass of the event they want to receive.
Closures already support contravariance on parameters, so I can implement this using bare closures, like this: https://phpstan.org/r/e59a6d1d-3bbd-411e-83ba-049a85782c9e
But I can't wrap the closures in objects, because generics don't support contravariant bounds: https://phpstan.org/r/d3180b26-22a2-44c0-83ce-01e757299b90
(These samples are entirely manufactured to make the point; the real system I need this for is implemented in PocketMine-MP since 2018 or so).
LastDragon-ru