aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-10-16 00:32:04 +0200
committerGitHub <noreply@github.com>2020-10-16 00:32:04 +0200
commit000c4b49f9ce15ec3b6a7aa44ad1516f350f396e (patch)
tree9483ab5365f7728720004c00e9b2e74632fadbfe
parent4bcf2ac63983e6ab7e2effaa1a988c0d75802b97 (diff)
parentb47a2730c095278708142cfb7ec42bc3c3468578 (diff)
downloadnextcloud-server-000c4b49f9ce15ec3b6a7aa44ad1516f350f396e.tar.gz
nextcloud-server-000c4b49f9ce15ec3b6a7aa44ad1516f350f396e.zip
Merge pull request #23481 from nextcloud/enhancement/psalm-typed-event-dispatcher
Add psalm types for the event dispatcher
-rw-r--r--lib/private/Authentication/Listeners/LoginFailedListener.php3
-rw-r--r--lib/private/Authentication/Listeners/RemoteWipeActivityListener.php3
-rw-r--r--lib/private/Authentication/Listeners/RemoteWipeEmailListener.php3
-rw-r--r--lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php3
-rw-r--r--lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php3
-rw-r--r--lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php3
-rw-r--r--lib/private/Authentication/Listeners/UserLoggedInListener.php3
-rw-r--r--lib/public/AppFramework/Bootstrap/IRegistrationContext.php5
-rw-r--r--lib/public/EventDispatcher/IEventDispatcher.php10
-rw-r--r--lib/public/EventDispatcher/IEventListener.php3
10 files changed, 37 insertions, 2 deletions
diff --git a/lib/private/Authentication/Listeners/LoginFailedListener.php b/lib/private/Authentication/Listeners/LoginFailedListener.php
index 72800ad509c..19f0b92c3a6 100644
--- a/lib/private/Authentication/Listeners/LoginFailedListener.php
+++ b/lib/private/Authentication/Listeners/LoginFailedListener.php
@@ -35,6 +35,9 @@ use OCP\EventDispatcher\IEventListener;
use OCP\IUserManager;
use OCP\Util;
+/**
+ * @template-implements IEventListener<\OC\Authentication\Events\LoginFailed>
+ */
class LoginFailedListener implements IEventListener {
/** @var IEventDispatcher */
diff --git a/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php b/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php
index b841f81555b..55009c317c4 100644
--- a/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php
+++ b/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php
@@ -35,6 +35,9 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use Psr\Log\LoggerInterface;
+/**
+ * @template-implements IEventListener<\OC\Authentication\Events\ARemoteWipeEvent>
+ */
class RemoteWipeActivityListener implements IEventListener {
/** @var IActvityManager */
diff --git a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php
index 52698855bd5..9ba2717c973 100644
--- a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php
+++ b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php
@@ -40,6 +40,9 @@ use OCP\Mail\IMessage;
use Psr\Log\LoggerInterface;
use function substr;
+/**
+ * @template-implements IEventListener<\OC\Authentication\Events\ARemoteWipeEvent>
+ */
class RemoteWipeEmailListener implements IEventListener {
/** @var IMailer */
diff --git a/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php b/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php
index 831107a05cd..965fb291fbf 100644
--- a/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php
+++ b/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php
@@ -35,6 +35,9 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Notification\IManager as INotificationManager;
+/**
+ * @template-implements IEventListener<\OC\Authentication\Events\ARemoteWipeEvent>
+ */
class RemoteWipeNotificationsListener implements IEventListener {
/** @var INotificationManager */
diff --git a/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php b/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php
index c8f2da82db6..057568f514e 100644
--- a/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php
+++ b/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php
@@ -31,6 +31,9 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\User\Events\UserDeletedEvent;
+/**
+ * @template-implements IEventListener<\OCP\User\Events\UserDeletedEvent>
+ */
class UserDeletedStoreCleanupListener implements IEventListener {
/** @var Registry */
diff --git a/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php b/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php
index e1199814da5..bb3a522556f 100644
--- a/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php
+++ b/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php
@@ -33,6 +33,9 @@ use OCP\User\Events\UserDeletedEvent;
use Psr\Log\LoggerInterface;
use Throwable;
+/**
+ * @template-implements IEventListener<\OCP\User\Events\UserDeletedEvent>
+ */
class UserDeletedTokenCleanupListener implements IEventListener {
/** @var Manager */
diff --git a/lib/private/Authentication/Listeners/UserLoggedInListener.php b/lib/private/Authentication/Listeners/UserLoggedInListener.php
index f3ab833734d..9d90f09b296 100644
--- a/lib/private/Authentication/Listeners/UserLoggedInListener.php
+++ b/lib/private/Authentication/Listeners/UserLoggedInListener.php
@@ -31,6 +31,9 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\User\Events\PostLoginEvent;
+/**
+ * @template-implements IEventListener<\OCP\User\Events\PostLoginEvent>
+ */
class UserLoggedInListener implements IEventListener {
/** @var Manager */
diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php
index b164fda5e62..aaf5ef00bfa 100644
--- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php
+++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php
@@ -113,10 +113,11 @@ interface IRegistrationContext {
*
* This is equivalent to calling IEventDispatcher::addServiceListener
*
+ * @template T of \OCP\EventDispatcher\Event
* @param string $event preferably the fully-qualified class name of the Event sub class to listen for
- * @psalm-param string|class-string<\OCP\EventDispatcher\Event> $event preferably the fully-qualified class name of the Event sub class to listen for
+ * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for
* @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
- * @psalm-param class-string<\OCP\EventDispatcher\IEventListener> $listener fully qualified class name that can be built by the DI container
+ * @psalm-param class-string<\OCP\EventDispatcher\IEventListener<T>> $listener fully qualified class name that can be built by the DI container
* @param int $priority
*
* @see IEventDispatcher::addServiceListener()
diff --git a/lib/public/EventDispatcher/IEventDispatcher.php b/lib/public/EventDispatcher/IEventDispatcher.php
index 997834ad7b5..471447e4b9f 100644
--- a/lib/public/EventDispatcher/IEventDispatcher.php
+++ b/lib/public/EventDispatcher/IEventDispatcher.php
@@ -35,7 +35,9 @@ namespace OCP\EventDispatcher;
interface IEventDispatcher {
/**
+ * @template T of \OCP\EventDispatcher\Event
* @param string $eventName preferably the fully-qualified class name of the Event sub class
+ * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class
* @param callable $listener the object that is invoked when a matching event is dispatched
* @param int $priority
*
@@ -44,7 +46,9 @@ interface IEventDispatcher {
public function addListener(string $eventName, callable $listener, int $priority = 0): void;
/**
+ * @template T of \OCP\EventDispatcher\Event
* @param string $eventName preferably the fully-qualified class name of the Event sub class
+ * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class
* @param callable $listener the object that is invoked when a matching event is dispatched
*
* @since 19.0.0
@@ -52,8 +56,11 @@ interface IEventDispatcher {
public function removeListener(string $eventName, callable $listener): void;
/**
+ * @template T of \OCP\EventDispatcher\Event
* @param string $eventName preferably the fully-qualified class name of the Event sub class to listen for
+ * @psalm-param string|class-string<T> $eventName preferably the fully-qualified class name of the Event sub class to listen for
* @param string $className fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
+ * @psalm-param class-string<\OCP\EventDispatcher\IEventListener<T>> $className fully qualified class name that can be built by the DI container
* @param int $priority
*
* @since 17.0.0
@@ -61,8 +68,11 @@ interface IEventDispatcher {
public function addServiceListener(string $eventName, string $className, int $priority = 0): void;
/**
+ * @template T of \OCP\EventDispatcher\Event
* @param string $eventName
+ * @psalm-param string|class-string<T> $eventName
* @param Event $event
+ * @psalm-param T $event
*
* @since 17.0.0
*/
diff --git a/lib/public/EventDispatcher/IEventListener.php b/lib/public/EventDispatcher/IEventListener.php
index 25906fa798e..fcf44133aff 100644
--- a/lib/public/EventDispatcher/IEventListener.php
+++ b/lib/public/EventDispatcher/IEventListener.php
@@ -28,11 +28,14 @@ namespace OCP\EventDispatcher;
/**
* @since 17.0.0
+ *
+ * @template T of Event
*/
interface IEventListener {
/**
* @param Event $event
+ * @psalm-param T $event
*
* @since 17.0.0
*/