diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-11-25 11:19:47 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-06-20 10:55:20 +0200 |
commit | 9725d0032944ebe5a73d59781a66742c5d1ae404 (patch) | |
tree | d7f90b66e49297e276241ed3960716cddfbad49a /apps/comments/lib/Notification | |
parent | 5063bf37ed3e68041adb9a96f430a87d59106491 (diff) | |
download | nextcloud-server-9725d0032944ebe5a73d59781a66742c5d1ae404.tar.gz nextcloud-server-9725d0032944ebe5a73d59781a66742c5d1ae404.zip |
Cleanup comments code
- Fix various psalm issues
- Add as much typing as possible while preserving stable API
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/comments/lib/Notification')
-rw-r--r-- | apps/comments/lib/Notification/Listener.php | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/apps/comments/lib/Notification/Listener.php b/apps/comments/lib/Notification/Listener.php index d1662f84266..bbea310ef7e 100644 --- a/apps/comments/lib/Notification/Listener.php +++ b/apps/comments/lib/Notification/Listener.php @@ -27,15 +27,12 @@ use OCP\Comments\CommentsEvent; use OCP\Comments\IComment; use OCP\IUserManager; use OCP\Notification\IManager; +use OCP\Notification\INotification; class Listener { - protected IManager $notificationManager; protected IUserManager $userManager; - /** - * Listener constructor. - */ public function __construct( IManager $notificationManager, IUserManager $userManager @@ -44,10 +41,7 @@ class Listener { $this->userManager = $userManager; } - /** - * @param CommentsEvent $event - */ - public function evaluate(CommentsEvent $event) { + public function evaluate(CommentsEvent $event): void { $comment = $event->getComment(); $mentions = $this->extractMentions($comment->getMentions()); @@ -77,12 +71,9 @@ class Listener { } /** - * creates a notification instance and fills it with comment data - * - * @param IComment $comment - * @return \OCP\Notification\INotification + * Creates a notification instance and fills it with comment data */ - public function instantiateNotification(IComment $comment) { + public function instantiateNotification(IComment $comment): INotification { $notification = $this->notificationManager->createNotification(); $notification ->setApp('comments') @@ -94,12 +85,12 @@ class Listener { } /** - * flattens the mention array returned from comments to a list of user ids. + * Flattens the mention array returned from comments to a list of user ids. * * @param array $mentions - * @return string[] containing the mentions, e.g. ['alice', 'bob'] + * @return list<string> containing the mentions, e.g. ['alice', 'bob'] */ - public function extractMentions(array $mentions) { + public function extractMentions(array $mentions): array { if (empty($mentions)) { return []; } |