Skip to content
Snippets Groups Projects
Commit 399ee476 authored by Larry Garfield's avatar Larry Garfield Committed by Benni Mack
Browse files

[TASK] Add property and return types to EventDispatcher

The object return on dispatch() is not a formal part of
the interface for BC reasons, but is required by the spec,
so thanks to LSP it's safe to add this way, and recommended.

Resolves: #97484
Releases: main
Change-Id: I01037753a0cc0cdb87c42900958edb2c1438233f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74440


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarBenjamin Franzke <bfr@qbus.de>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: default avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent 82debbd0
Branches
Tags
No related merge requests found
......@@ -25,14 +25,14 @@ class EventDispatcher extends \TYPO3\CMS\Core\EventDispatcher\EventDispatcher
/**
* @var object[]
*/
protected $dispatchedEvents = [];
protected array $dispatchedEvents = [];
public function getDispatchedEvents(): array
{
return $this->dispatchedEvents;
}
public function dispatch(object $event)
public function dispatch(object $event): object
{
$this->dispatchedEvents[] = $event;
return parent::dispatch($event);
......
......@@ -28,17 +28,12 @@ use TYPO3\CMS\Core\SingletonInterface;
*/
class EventDispatcher implements EventDispatcherInterface, SingletonInterface
{
/**
* @var ListenerProviderInterface
*/
protected $listenerProvider;
public function __construct(ListenerProviderInterface $listenerProvider)
{
$this->listenerProvider = $listenerProvider;
public function __construct(
protected readonly ListenerProviderInterface $listenerProvider
) {
}
public function dispatch(object $event)
public function dispatch(object $event): object
{
// If the event is already stopped, nothing to do here.
if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment