- PHP 8.1+
None
-
The
Eventclass is now abstract and requires extension. -
"target" references have been renamed as "sender". For instance, the
Event::$targetproperty has been renamed tosender. -
Events are not longer emitted during instantiation, you need to use the
emit()function for that. All code related to event reflexion to create non-firing events has been removed.<?php namespace ICanBoogie; $event = new SampleEvent();
<?php namespace ICanBoogie; $event = emit(new SampleEvent());
-
EventCollection::attach(),EventCollection::attach_to(),EventCollection::once()now require aClosureand no longer a callable.EventCollection::attach_many()still works with regular callables. -
The
typeparameter of theEventconstructor has been removed. The type is now the class of the event.<?php namespace ICanBoogie; $event = new SampleEvent(type: 'sample-event');
<?php namespace ICanBoogie; $event = new SampleEvent();
-
The
payloadparameter of theEventconstructor has been removed.class ProcessEvent extends Event { public $values; public function __construct(A $target, array $payload = []) { parent::__construct($target, 'process', $payload); } }
class ProcessEvent extends Event { public function __construct(A $sender, public array $values) { parent::__construct($sender); } }
-
Callables without senders are now supported for attachment:
$events->attach('count', function(CountEvent $event): void { // … }
$events->attach(function(CountEvent $event): void { // … }
-
Dropped
Event::$usedandEvent::$used_byproperties. The information is still available in the profiler.
None
None