diff --git a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php index 1ec496b781c5d..f16fc64fd3ff4 100644 --- a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php +++ b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php @@ -27,7 +27,7 @@ */ class MergeDoctrineCollectionListener implements EventSubscriberInterface { - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { // Higher priority than core MergeCollectionListener so that this one // is called before diff --git a/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php b/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php index 64b3d65fa5adf..ab67e77581b14 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php @@ -133,7 +133,7 @@ public function onTerminate(ConsoleTerminateEvent $event) /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ ConsoleEvents::COMMAND => ['onCommand', 255], diff --git a/src/Symfony/Bridge/Monolog/Processor/ConsoleCommandProcessor.php b/src/Symfony/Bridge/Monolog/Processor/ConsoleCommandProcessor.php index 2891f4f2f4916..62c75d2e11190 100644 --- a/src/Symfony/Bridge/Monolog/Processor/ConsoleCommandProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/ConsoleCommandProcessor.php @@ -60,7 +60,7 @@ public function addCommandData(ConsoleEvent $event) } } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ ConsoleEvents::COMMAND => ['addCommandData', 1], diff --git a/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php b/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php index 778bfcfeff077..daf59ad2c0cff 100644 --- a/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php +++ b/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php @@ -59,7 +59,7 @@ public function onKernelFinishRequest(FinishRequestEvent $event) /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::REQUEST => [ diff --git a/src/Symfony/Component/Console/EventListener/ErrorListener.php b/src/Symfony/Component/Console/EventListener/ErrorListener.php index 783c10793f2c9..53e40b86683af 100644 --- a/src/Symfony/Component/Console/EventListener/ErrorListener.php +++ b/src/Symfony/Component/Console/EventListener/ErrorListener.php @@ -69,7 +69,7 @@ public function onConsoleTerminate(ConsoleTerminateEvent $event) $this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ ConsoleEvents::ERROR => ['onConsoleError', -128], diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php index 922b42126df63..57b640127420f 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -53,7 +53,7 @@ public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $sto /** * {@inheritdoc} */ - public function addListener(string $eventName, $listener, int $priority = 0) + public function addListener(string $eventName, $listener, int $priority = 0): void { $this->dispatcher->addListener($eventName, $listener, $priority); } @@ -61,7 +61,7 @@ public function addListener(string $eventName, $listener, int $priority = 0) /** * {@inheritdoc} */ - public function addSubscriber(EventSubscriberInterface $subscriber) + public function addSubscriber(EventSubscriberInterface $subscriber): void { $this->dispatcher->addSubscriber($subscriber); } @@ -69,7 +69,7 @@ public function addSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function removeListener(string $eventName, $listener) + public function removeListener(string $eventName, $listener): void { if (isset($this->wrappedListeners[$eventName])) { foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) { @@ -81,21 +81,21 @@ public function removeListener(string $eventName, $listener) } } - return $this->dispatcher->removeListener($eventName, $listener); + $this->dispatcher->removeListener($eventName, $listener); } /** * {@inheritdoc} */ - public function removeSubscriber(EventSubscriberInterface $subscriber) + public function removeSubscriber(EventSubscriberInterface $subscriber): void { - return $this->dispatcher->removeSubscriber($subscriber); + $this->dispatcher->removeSubscriber($subscriber); } /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(string $eventName = null): array { return $this->dispatcher->getListeners($eventName); } @@ -103,7 +103,7 @@ public function getListeners(string $eventName = null) /** * {@inheritdoc} */ - public function getListenerPriority(string $eventName, $listener) + public function getListenerPriority(string $eventName, $listener): ?int { // we might have wrapped listeners for the event (if called while dispatching) // in that case get the priority by wrapper @@ -121,7 +121,7 @@ public function getListenerPriority(string $eventName, $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(string $eventName = null): bool { return $this->dispatcher->hasListeners($eventName); } @@ -170,10 +170,7 @@ public function dispatch($event, string $eventName = null): object return $event; } - /** - * @return array - */ - public function getCalledListeners(Request $request = null) + public function getCalledListeners(Request $request = null): array { if (null === $this->callStack) { return []; @@ -191,10 +188,7 @@ public function getCalledListeners(Request $request = null) return $called; } - /** - * @return array - */ - public function getNotCalledListeners(Request $request = null) + public function getNotCalledListeners(Request $request = null): array { try { $allListeners = $this->getListeners(); @@ -250,7 +244,7 @@ public function getOrphanedEvents(Request $request = null): array return array_merge(...array_values($this->orphanedEvents)); } - public function reset() + public function reset(): void { $this->callStack = null; $this->orphanedEvents = []; @@ -260,9 +254,6 @@ public function reset() /** * Proxies all method calls to the original event dispatcher. * - * @param string $method The method name - * @param array $arguments The method arguments - * * @return mixed */ public function __call(string $method, array $arguments) @@ -273,14 +264,14 @@ public function __call(string $method, array $arguments) /** * Called before dispatching the event. */ - protected function beforeDispatch(string $eventName, object $event) + protected function beforeDispatch(string $eventName, object $event): void { } /** * Called after dispatching the event. */ - protected function afterDispatch(string $eventName, object $event) + protected function afterDispatch(string $eventName, object $event): void { } @@ -341,7 +332,7 @@ private function postProcess(string $eventName): void } } - private function sortNotCalledListeners(array $a, array $b) + private function sortNotCalledListeners(array $a, array $b): int { if (0 !== $cmp = strcmp($a['event'], $b['event'])) { return $cmp; diff --git a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php index 2d2cbaf709a01..b9bc0d19ef6f9 100644 --- a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php +++ b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php @@ -48,7 +48,7 @@ public function setHotPathEvents(array $hotPathEvents, $tagName = 'container.hot return $this; } - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) { return; @@ -134,7 +134,7 @@ class ExtractingEventDispatcher extends EventDispatcher implements EventSubscrib public static $aliases = []; public static $subscriber; - public function addListener(string $eventName, $listener, int $priority = 0) + public function addListener(string $eventName, $listener, int $priority = 0): void { $this->listeners[] = [$eventName, $listener[1], $priority]; } diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index d624beb58ec15..53a3f1f739a51 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -70,7 +70,7 @@ public function dispatch($event, string $eventName = null): object /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(string $eventName = null): array { if (null !== $eventName) { if (empty($this->listeners[$eventName])) { @@ -96,7 +96,7 @@ public function getListeners(string $eventName = null) /** * {@inheritdoc} */ - public function getListenerPriority(string $eventName, $listener) + public function getListenerPriority(string $eventName, $listener): ?int { if (empty($this->listeners[$eventName])) { return null; @@ -123,7 +123,7 @@ public function getListenerPriority(string $eventName, $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(string $eventName = null): bool { if (null !== $eventName) { return !empty($this->listeners[$eventName]); @@ -141,7 +141,7 @@ public function hasListeners(string $eventName = null) /** * {@inheritdoc} */ - public function addListener(string $eventName, $listener, int $priority = 0) + public function addListener(string $eventName, $listener, int $priority = 0): void { $this->listeners[$eventName][$priority][] = $listener; unset($this->sorted[$eventName], $this->optimized[$eventName]); @@ -150,7 +150,7 @@ public function addListener(string $eventName, $listener, int $priority = 0) /** * {@inheritdoc} */ - public function removeListener(string $eventName, $listener) + public function removeListener(string $eventName, $listener): void { if (empty($this->listeners[$eventName])) { return; @@ -179,7 +179,7 @@ public function removeListener(string $eventName, $listener) /** * {@inheritdoc} */ - public function addSubscriber(EventSubscriberInterface $subscriber) + public function addSubscriber(EventSubscriberInterface $subscriber): void { foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { if (\is_string($params)) { @@ -197,7 +197,7 @@ public function addSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function removeSubscriber(EventSubscriberInterface $subscriber) + public function removeSubscriber(EventSubscriberInterface $subscriber): void { foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { if (\is_array($params) && \is_array($params[0])) { @@ -220,7 +220,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) * @param string $eventName The name of the event to dispatch * @param object $event The event object to pass to the event handlers/listeners */ - protected function callListeners(iterable $listeners, string $eventName, object $event) + protected function callListeners(iterable $listeners, string $eventName, object $event): void { $stoppable = $event instanceof Event || $event instanceof StoppableEventInterface; @@ -235,7 +235,7 @@ protected function callListeners(iterable $listeners, string $eventName, object /** * Sorts the internal list of listeners for the given event by priority. */ - private function sortListeners(string $eventName) + private function sortListeners(string $eventName): void { krsort($this->listeners[$eventName]); $this->sorted[$eventName] = []; diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php index 0620f74f19683..29d03544ef7d4 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php @@ -34,7 +34,7 @@ public function dispatch($event, string $eventName = null): object; * @param int $priority The higher this value, the earlier an event * listener will be triggered in the chain (defaults to 0) */ - public function addListener(string $eventName, $listener, int $priority = 0); + public function addListener(string $eventName, $listener, int $priority = 0): void; /** * Adds an event subscriber. @@ -42,23 +42,21 @@ public function addListener(string $eventName, $listener, int $priority = 0); * The subscriber is asked for all the events it is * interested in and added as a listener for these events. */ - public function addSubscriber(EventSubscriberInterface $subscriber); + public function addSubscriber(EventSubscriberInterface $subscriber): void; /** * Removes an event listener from the specified events. * * @param callable $listener The listener to remove */ - public function removeListener(string $eventName, $listener); + public function removeListener(string $eventName, $listener): void; - public function removeSubscriber(EventSubscriberInterface $subscriber); + public function removeSubscriber(EventSubscriberInterface $subscriber): void; /** * Gets the listeners of a specific event or all listeners sorted by descending priority. - * - * @return array The event listeners for the specified event, or all event listeners by event name */ - public function getListeners(string $eventName = null); + public function getListeners(string $eventName = null): array; /** * Gets the listener priority for a specific event. @@ -66,15 +64,13 @@ public function getListeners(string $eventName = null); * Returns null if the event or the listener does not exist. * * @param callable $listener The listener - * - * @return int|null The event listener priority */ - public function getListenerPriority(string $eventName, $listener); + public function getListenerPriority(string $eventName, $listener): ?int; /** * Checks whether an event has any registered listeners. * * @return bool true if the specified event has any listeners, false otherwise */ - public function hasListeners(string $eventName = null); + public function hasListeners(string $eventName = null): bool; } diff --git a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php index 824f21599c256..97b2132bdfbbf 100644 --- a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php @@ -39,8 +39,6 @@ interface EventSubscriberInterface * * ['eventName' => 'methodName'] * * ['eventName' => ['methodName', $priority]] * * ['eventName' => [['methodName1', $priority], ['methodName2']]] - * - * @return array The event names to listen to */ - public static function getSubscribedEvents(); + public static function getSubscribedEvents(): array; } diff --git a/src/Symfony/Component/EventDispatcher/GenericEvent.php b/src/Symfony/Component/EventDispatcher/GenericEvent.php index 34b95cedee817..1b951aabb7c34 100644 --- a/src/Symfony/Component/EventDispatcher/GenericEvent.php +++ b/src/Symfony/Component/EventDispatcher/GenericEvent.php @@ -70,7 +70,7 @@ public function getArgument(string $key) * * @return $this */ - public function setArgument(string $key, $value) + public function setArgument(string $key, $value): object { $this->arguments[$key] = $value; @@ -79,10 +79,8 @@ public function setArgument(string $key, $value) /** * Getter for all arguments. - * - * @return array */ - public function getArguments() + public function getArguments(): array { return $this->arguments; } @@ -92,7 +90,7 @@ public function getArguments() * * @return $this */ - public function setArguments(array $args = []) + public function setArguments(array $args = []): object { $this->arguments = $args; @@ -101,10 +99,8 @@ public function setArguments(array $args = []) /** * Has argument. - * - * @return bool */ - public function hasArgument(string $key) + public function hasArgument(string $key): bool { return \array_key_exists($key, $this->arguments); } @@ -129,7 +125,7 @@ public function offsetGet($key) * @param string $key Array key to set * @param mixed $value Value */ - public function offsetSet($key, $value) + public function offsetSet($key, $value): void { $this->setArgument($key, $value); } @@ -139,7 +135,7 @@ public function offsetSet($key, $value) * * @param string $key Array key */ - public function offsetUnset($key) + public function offsetUnset($key): void { if ($this->hasArgument($key)) { unset($this->arguments[$key]); @@ -150,10 +146,8 @@ public function offsetUnset($key) * ArrayAccess has argument. * * @param string $key Array key - * - * @return bool */ - public function offsetExists($key) + public function offsetExists($key): bool { return $this->hasArgument($key); } @@ -163,7 +157,7 @@ public function offsetExists($key) * * @return \ArrayIterator */ - public function getIterator() + public function getIterator(): \Traversable { return new \ArrayIterator($this->arguments); } diff --git a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php index 8be7f4c53073a..123579e167a32 100644 --- a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php @@ -36,7 +36,7 @@ public function dispatch($event, string $eventName = null): object /** * {@inheritdoc} */ - public function addListener(string $eventName, $listener, int $priority = 0) + public function addListener(string $eventName, $listener, int $priority = 0): void { throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); } @@ -44,7 +44,7 @@ public function addListener(string $eventName, $listener, int $priority = 0) /** * {@inheritdoc} */ - public function addSubscriber(EventSubscriberInterface $subscriber) + public function addSubscriber(EventSubscriberInterface $subscriber): void { throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); } @@ -52,7 +52,7 @@ public function addSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function removeListener(string $eventName, $listener) + public function removeListener(string $eventName, $listener): void { throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); } @@ -60,7 +60,7 @@ public function removeListener(string $eventName, $listener) /** * {@inheritdoc} */ - public function removeSubscriber(EventSubscriberInterface $subscriber) + public function removeSubscriber(EventSubscriberInterface $subscriber): void { throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); } @@ -68,7 +68,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(string $eventName = null): array { return $this->dispatcher->getListeners($eventName); } @@ -76,7 +76,7 @@ public function getListeners(string $eventName = null) /** * {@inheritdoc} */ - public function getListenerPriority(string $eventName, $listener) + public function getListenerPriority(string $eventName, $listener): ?int { return $this->dispatcher->getListenerPriority($eventName, $listener); } @@ -84,7 +84,7 @@ public function getListenerPriority(string $eventName, $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(string $eventName = null): bool { return $this->dispatcher->hasListeners($eventName); } diff --git a/src/Symfony/Component/EventDispatcher/Tests/ChildEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ChildEventDispatcherTest.php index 442b88fbb39e1..e89544aa23a49 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ChildEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ChildEventDispatcherTest.php @@ -12,10 +12,11 @@ namespace Symfony\Component\EventDispatcher\Tests; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class ChildEventDispatcherTest extends EventDispatcherTest { - protected function createEventDispatcher() + protected function createEventDispatcher(): EventDispatcherInterface { return new ChildEventDispatcher(); } diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php index 75e90120736ec..b13c628851211 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/WrappedListenerTest.php @@ -28,7 +28,7 @@ public function testListenerDescription($listener, $expected) $this->assertStringMatchesFormat($expected, $wrappedListener->getPretty()); } - public function provideListenersToDescribe() + public function provideListenersToDescribe(): array { return [ [new FooListener(), 'Symfony\Component\EventDispatcher\Tests\Debug\FooListener::__invoke'], diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index 735bd805e1091..aa1b94c276afe 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Contracts\EventDispatcher\Event; @@ -43,7 +44,7 @@ protected function tearDown(): void $this->listener = null; } - protected function createEventDispatcher() + protected function createEventDispatcher(): EventDispatcherInterface { return new EventDispatcher(); } diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php index 53dd4ee8711d2..60c76faeccab6 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php @@ -41,7 +41,7 @@ public function onSubmit(FormEvent $event) } } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [FormEvents::SUBMIT => 'onSubmit']; } diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php index cd4a3b5430ea0..c5abbb38255a4 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php @@ -34,7 +34,7 @@ public function __construct(bool $allowAdd = false, bool $allowDelete = false) $this->allowDelete = $allowDelete; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ FormEvents::SUBMIT => 'onSubmit', diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php index d978117552d90..6616f6d1979c6 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php @@ -45,7 +45,7 @@ public function __construct(string $type, array $options = [], bool $allowAdd = $this->deleteEmpty = $deleteEmpty; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ FormEvents::PRE_SET_DATA => 'preSetData', diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php index 95763c26c7422..8c2e850e22ee6 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/TransformationFailureListener.php @@ -29,7 +29,7 @@ public function __construct(TranslatorInterface $translator = null) $this->translator = $translator; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ FormEvents::POST_SUBMIT => ['convertTransformationFailureToFormError', -1024], diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php index be8c38a854ccb..be763c78d2d72 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php @@ -34,7 +34,7 @@ public function preSubmit(FormEvent $event) $event->setData(StringUtil::trim($data)); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [FormEvents::PRE_SUBMIT => 'preSubmit']; } diff --git a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php index d30bdef61e8e3..8628563f77894 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php @@ -33,7 +33,7 @@ class CsrfValidationListener implements EventSubscriberInterface private $translationDomain; private $serverParams; - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ FormEvents::PRE_SUBMIT => 'preSubmit', diff --git a/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php b/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php index 77595ab38acea..4007935d62c8b 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php @@ -34,7 +34,7 @@ public function __construct(FormDataCollectorInterface $dataCollector) /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ // High priority in order to be called as soon as possible diff --git a/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php b/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php index b9cc334256174..49d4b78f440d7 100644 --- a/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php @@ -30,7 +30,7 @@ class ValidationListener implements EventSubscriberInterface /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [FormEvents::POST_SUBMIT => 'validateForm']; } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 0d9766e2958a9..700bdefc963fd 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -366,7 +366,7 @@ public function onKernelResponse(ResponseEvent $event) } } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::CONTROLLER => 'onKernelController', diff --git a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php index 1ece493f4e708..7cd22f059dad7 100644 --- a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php @@ -26,7 +26,7 @@ class TraceableEventDispatcher extends BaseTraceableEventDispatcher /** * {@inheritdoc} */ - protected function beforeDispatch(string $eventName, object $event) + protected function beforeDispatch(string $eventName, object $event): void { switch ($eventName) { case KernelEvents::REQUEST: @@ -60,7 +60,7 @@ protected function beforeDispatch(string $eventName, object $event) /** * {@inheritdoc} */ - protected function afterDispatch(string $eventName, object $event) + protected function afterDispatch(string $eventName, object $event): void { switch ($eventName) { case KernelEvents::CONTROLLER_ARGUMENTS: diff --git a/src/Symfony/Component/HttpKernel/EventListener/DisallowRobotsIndexingListener.php b/src/Symfony/Component/HttpKernel/EventListener/DisallowRobotsIndexingListener.php index 6607e49e999e8..ca60878baf5ec 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DisallowRobotsIndexingListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DisallowRobotsIndexingListener.php @@ -34,7 +34,7 @@ public function onResponse(ResponseEvent $event): void /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::RESPONSE => ['onResponse', -255], diff --git a/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php b/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php index 30908a4f45652..3a3eff28fc8ef 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php @@ -51,7 +51,7 @@ public function configure() }); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { if (!class_exists(ConsoleEvents::class)) { return []; diff --git a/src/Symfony/Component/HttpKernel/EventListener/LocaleAwareListener.php b/src/Symfony/Component/HttpKernel/EventListener/LocaleAwareListener.php index b93c4b0f03b46..f6b50c7265c3c 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/LocaleAwareListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/LocaleAwareListener.php @@ -56,7 +56,7 @@ public function onKernelFinishRequest(FinishRequestEvent $event): void $this->setLocale($parentRequest->getLocale(), $parentRequest->getDefaultLocale()); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ // must be registered after the Locale listener diff --git a/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php b/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php index cbb3922a19a46..21d1c1dd575ca 100644 --- a/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php +++ b/src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php @@ -50,7 +50,7 @@ public function onMessage(MessageEvent $event): void } } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ // should be the last one to allow header changes by other listeners first diff --git a/src/Symfony/Component/Mailer/EventListener/MessageListener.php b/src/Symfony/Component/Mailer/EventListener/MessageListener.php index f300f6370a2e6..4dfcf9896ddee 100644 --- a/src/Symfony/Component/Mailer/EventListener/MessageListener.php +++ b/src/Symfony/Component/Mailer/EventListener/MessageListener.php @@ -73,7 +73,7 @@ private function renderMessage(Message $message): void $this->renderer->render($message); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ MessageEvent::class => 'onMessage', diff --git a/src/Symfony/Component/Mailer/EventListener/MessageLoggerListener.php b/src/Symfony/Component/Mailer/EventListener/MessageLoggerListener.php index 093bf2bb9e5ac..d75dde909a4ea 100644 --- a/src/Symfony/Component/Mailer/EventListener/MessageLoggerListener.php +++ b/src/Symfony/Component/Mailer/EventListener/MessageLoggerListener.php @@ -48,7 +48,7 @@ public function getEvents(): MessageEvents return $this->events; } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ MessageEvent::class => ['onMessage', -255], diff --git a/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php b/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php index 2e431e654a7fd..47255e4333b01 100644 --- a/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php +++ b/src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php @@ -76,7 +76,7 @@ public function onMessageFailed(WorkerMessageFailedEvent $event) $this->messageBus->dispatch($envelope); } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ WorkerMessageFailedEvent::class => ['onMessageFailed', -100], diff --git a/src/Symfony/Component/Security/Http/Firewall.php b/src/Symfony/Component/Security/Http/Firewall.php index b239911b8b677..d33b3cf157fa4 100644 --- a/src/Symfony/Component/Security/Http/Firewall.php +++ b/src/Symfony/Component/Security/Http/Firewall.php @@ -97,7 +97,7 @@ public function onKernelFinishRequest(FinishRequestEvent $event) /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ KernelEvents::REQUEST => ['onKernelRequest', 8], diff --git a/src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php b/src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php index 95a9590cef4b2..f7a8f66861917 100644 --- a/src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php +++ b/src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php @@ -46,7 +46,7 @@ public function onEnter(Event $event) } } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'workflow.leave' => ['onLeave'], diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 9827500a1c704..67858a9a3b7e8 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -4,6 +4,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\Event\Event; use Symfony\Component\Workflow\Event\GuardEvent; @@ -572,7 +574,7 @@ public function testGetEnabledTransitionsWithSameNameTransition() } } -class EventDispatcherMock implements \Symfony\Component\EventDispatcher\EventDispatcherInterface +class EventDispatcherMock implements EventDispatcherInterface { public $dispatchedEvents = []; @@ -583,19 +585,19 @@ public function dispatch($event, string $eventName = null): object return $event; } - public function addListener($eventName, $listener, $priority = 0) + public function addListener($eventName, $listener, $priority = 0): void { } - public function addSubscriber(\Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber) + public function addSubscriber(EventSubscriberInterface $subscriber): void { } - public function removeListener($eventName, $listener) + public function removeListener($eventName, $listener): void { } - public function removeSubscriber(\Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber) + public function removeSubscriber(EventSubscriberInterface $subscriber): void { }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: