You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHPUnit's event system could potentially allow a single subscriber to subscribe to multiple events using union types. For example:
class MySubscriber implements PHPUnit\Event\Test\PreparedSubscriber, PHPUnit\Event\Test\FinishedSubscriber
{
public function notify(PHPUnit\Event\Test\Prepared | PHPUnit\Event\Test\Finished $event): void
{
// Do something interesting with either event
}
}
However, currently in PHPUnit\Event\Dispatcher\DirectDispatcher::registerSubscriber(), it is assumed each subscriber only implements a single subscriber interface.
If you try to add MySubscriber anyway, it will be registered to only one of the two event types (whichever comes first in the PHPUnit\Event\Facade::registerDefaultTypes() list), and thus never receive events of the second type.
Allowing a single subscriber to define multiple subscriber interfaces could help reduce boilerplate in extensions.
The text was updated successfully, but these errors were encountered:
PHPUnit's event system could potentially allow a single subscriber to subscribe to multiple events using union types. For example:
However, currently in
PHPUnit\Event\Dispatcher\DirectDispatcher::registerSubscriber()
, it is assumed each subscriber only implements a single subscriber interface.If you try to add
MySubscriber
anyway, it will be registered to only one of the two event types (whichever comes first in thePHPUnit\Event\Facade::registerDefaultTypes()
list), and thus never receive events of the second type.Allowing a single subscriber to define multiple subscriber interfaces could help reduce boilerplate in extensions.
The text was updated successfully, but these errors were encountered: