From a2e57ab980a419d0f40cf4540b5387d40e65f51a Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Tue, 5 Oct 2021 14:31:59 -0300 Subject: [PATCH] Changes after run --alter psalm --alter --issues=MissingClosureReturnType,MismatchingDocblockReturnType,MissingReturnType,InvalidReturnType,MissingParamType Signed-off-by: Vitor Mattos --- lib/Activity/Listener.php | 6 +++--- lib/AppInfo/Application.php | 4 ++-- lib/Chat/SystemMessage/Listener.php | 4 ++-- lib/Collaboration/Resources/Listener.php | 10 +++++----- lib/Controller/SettingsController.php | 3 +++ lib/Federation/CloudFederationProviderTalk.php | 2 +- lib/Federation/FederationManager.php | 4 ++-- lib/Files/Listener.php | 4 ++-- lib/Flow/Operation.php | 2 +- lib/Migration/Version10000Date20201012144235.php | 3 ++- lib/Migration/Version7000Date20190724121136.php | 3 +++ lib/Notification/Listener.php | 10 +++++----- lib/PublicShareAuth/Listener.php | 8 ++++---- lib/Service/HostedSignalingServerService.php | 10 ++++++++-- lib/Share/RoomShareProvider.php | 6 +++--- lib/Signaling/Listener.php | 12 ++++++------ 16 files changed, 52 insertions(+), 39 deletions(-) diff --git a/lib/Activity/Listener.php b/lib/Activity/Listener.php index 108351690..65d98bbed 100644 --- a/lib/Activity/Listener.php +++ b/lib/Activity/Listener.php @@ -73,14 +73,14 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function (ModifyParticipantEvent $event) { + $listener = static function (ModifyParticipantEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->setActive($event->getRoom(), $event->getParticipant()); }; $dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, $listener); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->generateCallActivity($event->getRoom()); @@ -90,7 +90,7 @@ class Listener { $dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, $listener, -100); $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DISCONNECT, $listener, -100); - $listener = static function (AddParticipantsEvent $event) { + $listener = static function (AddParticipantsEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->generateInvitationActivity($event->getRoom(), $event->getParticipants()); diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index bc4174d94..5e1f6fed2 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -202,7 +202,7 @@ class Application extends App implements IBootstrap { } protected function registerRoomActivityHooks(IEventDispatcher $dispatcher): void { - $listener = function (ChatEvent $event) { + $listener = function (ChatEvent $event): void { $room = $event->getRoom(); /** @var ITimeFactory $timeFactory */ $timeFactory = $this->getContainer()->query(ITimeFactory::class); @@ -214,7 +214,7 @@ class Application extends App implements IBootstrap { } protected function registerChatHooks(IEventDispatcher $dispatcher): void { - $listener = function (RoomEvent $event) { + $listener = function (RoomEvent $event): void { /** @var ChatManager $chatManager */ $chatManager = $this->getContainer()->query(ChatManager::class); $chatManager->deleteMessages($event->getRoom()); diff --git a/lib/Chat/SystemMessage/Listener.php b/lib/Chat/SystemMessage/Listener.php index 810f2487c..67eb04c1c 100644 --- a/lib/Chat/SystemMessage/Listener.php +++ b/lib/Chat/SystemMessage/Listener.php @@ -306,7 +306,7 @@ class Listener implements IEventListener { $listener->sendSystemMessage($room, 'guest_moderator_demoted', ['session' => $attendee->getActorId()]); } }); - $listener = function (GenericEvent $event) { + $listener = function (GenericEvent $event): void { /** @var IShare $share */ $share = $event->getSubject(); @@ -406,7 +406,7 @@ class Listener implements IEventListener { ); } - protected function getUserId() { + protected function getUserId(): ?string { $user = $this->userSession->getUser(); return $user instanceof IUser ? $user->getUID() : null; } diff --git a/lib/Collaboration/Resources/Listener.php b/lib/Collaboration/Resources/Listener.php index ea1e51607..4701fb73f 100644 --- a/lib/Collaboration/Resources/Listener.php +++ b/lib/Collaboration/Resources/Listener.php @@ -37,7 +37,7 @@ use OCP\IUserManager; class Listener { public static function register(IEventDispatcher $dispatcher): void { - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); @@ -51,7 +51,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DELETE, $listener); - $listener = static function (AddParticipantsEvent $event) { + $listener = static function (AddParticipantsEvent $event): void { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); @@ -75,7 +75,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, $listener); - $listener = static function (RemoveUserEvent $event) { + $listener = static function (RemoveUserEvent $event): void { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); @@ -89,7 +89,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, $listener); - $listener = static function (RemoveParticipantEvent $event) { + $listener = static function (RemoveParticipantEvent $event): void { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); @@ -110,7 +110,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_REMOVE, $listener); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index ed8337211..26fdaf353 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -95,6 +95,9 @@ class SettingsController extends OCSController { return new DataResponse(); } + /** + * @param int|null|string $value + */ protected function validateUserSetting(string $setting, $value): bool { if ($setting === 'attachment_folder') { $userFolder = $this->rootFolder->getUserFolder($this->userId); diff --git a/lib/Federation/CloudFederationProviderTalk.php b/lib/Federation/CloudFederationProviderTalk.php index 3e89bda07..180edd9a2 100644 --- a/lib/Federation/CloudFederationProviderTalk.php +++ b/lib/Federation/CloudFederationProviderTalk.php @@ -229,7 +229,7 @@ class CloudFederationProviderTalk implements ICloudFederationProvider { return $attendee; } - private function notifyAboutNewShare(IUser $shareWith, string $shareId, string $sharedByFederatedId, string $sharedByName, string $roomName, string $roomToken, string $serverUrl) { + private function notifyAboutNewShare(IUser $shareWith, string $shareId, string $sharedByFederatedId, string $sharedByName, string $roomName, string $roomToken, string $serverUrl): void { $notification = $this->notificationManager->createNotification(); $notification->setApp(Application::APP_ID) ->setUser($shareWith->getUID()) diff --git a/lib/Federation/FederationManager.php b/lib/Federation/FederationManager.php index 691d83a6c..5c431b95c 100644 --- a/lib/Federation/FederationManager.php +++ b/lib/Federation/FederationManager.php @@ -111,7 +111,7 @@ class FederationManager { * @throws UnauthorizedException * @throws MultipleObjectsReturnedException */ - public function acceptRemoteRoomShare(IUser $user, int $shareId) { + public function acceptRemoteRoomShare(IUser $user, int $shareId): void { $invitation = $this->invitationMapper->getInvitationById($shareId); if ($invitation->getUserId() !== $user->getUID()) { throw new UnauthorizedException('invitation is for a different user'); @@ -140,7 +140,7 @@ class FederationManager { * @throws UnauthorizedException * @throws MultipleObjectsReturnedException */ - public function rejectRemoteRoomShare(IUser $user, int $shareId) { + public function rejectRemoteRoomShare(IUser $user, int $shareId): void { $invitation = $this->invitationMapper->getInvitationById($shareId); if ($invitation->getUserId() !== $user->getUID()) { throw new UnauthorizedException('invitation is for a different user'); diff --git a/lib/Files/Listener.php b/lib/Files/Listener.php index 42a5e6781..f4cd9784b 100644 --- a/lib/Files/Listener.php +++ b/lib/Files/Listener.php @@ -73,7 +73,7 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function (JoinRoomUserEvent $event) { + $listener = static function (JoinRoomUserEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); @@ -86,7 +86,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_CONNECT, $listener); - $listener = static function (JoinRoomGuestEvent $event) { + $listener = static function (JoinRoomGuestEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index 3e536b493..1ca641f9c 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -143,7 +143,7 @@ class Operation implements IOperation { } } - protected function prepareText(IEntity $entity, string $eventName) { + protected function prepareText(IEntity $entity, string $eventName): string { $message = $eventName; if ($entity instanceof IDisplayText) { $message = trim($entity->getDisplayText(3)); diff --git a/lib/Migration/Version10000Date20201012144235.php b/lib/Migration/Version10000Date20201012144235.php index 3705cbebd..fe9eea2e5 100644 --- a/lib/Migration/Version10000Date20201012144235.php +++ b/lib/Migration/Version10000Date20201012144235.php @@ -36,7 +36,8 @@ class Version10000Date20201012144235 extends SimpleMigrationStep { * @param IOutput $output * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options - * @return null|ISchemaWrapper + * + * @return ISchemaWrapper */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { /** @var ISchemaWrapper $schema */ diff --git a/lib/Migration/Version7000Date20190724121136.php b/lib/Migration/Version7000Date20190724121136.php index 9ad66ec99..20de3a34d 100644 --- a/lib/Migration/Version7000Date20190724121136.php +++ b/lib/Migration/Version7000Date20190724121136.php @@ -72,7 +72,10 @@ class Version7000Date20190724121136 extends SimpleMigrationStep { * @param IOutput $output * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options + * * @since 13.0.0 + * + * @return void */ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { $query = $this->connection->getQueryBuilder(); diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php index 1ba06641f..9c65e7549 100644 --- a/lib/Notification/Listener.php +++ b/lib/Notification/Listener.php @@ -69,7 +69,7 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function (AddParticipantsEvent $event) { + $listener = static function (AddParticipantsEvent $event): void { $room = $event->getRoom(); if ($room->getObjectType() === 'file') { @@ -82,28 +82,28 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, $listener); - $listener = static function (JoinRoomUserEvent $event) { + $listener = static function (JoinRoomUserEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->markInvitationRead($event->getRoom()); }; $dispatcher->addListener(Room::EVENT_AFTER_ROOM_CONNECT, $listener); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->checkCallNotifications($event->getRoom()); }; $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, $listener); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendCallNotifications($event->getRoom()); }; $dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, $listener); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->markCallNotificationsRead($event->getRoom()); diff --git a/lib/PublicShareAuth/Listener.php b/lib/PublicShareAuth/Listener.php index 3e29d18f6..d0148e5ef 100644 --- a/lib/PublicShareAuth/Listener.php +++ b/lib/PublicShareAuth/Listener.php @@ -49,22 +49,22 @@ use OCP\EventDispatcher\IEventDispatcher; */ class Listener { public static function register(IEventDispatcher $dispatcher): void { - $listener = static function (JoinRoomUserEvent $event) { + $listener = static function (JoinRoomUserEvent $event): void { self::preventExtraUsersFromJoining($event->getRoom(), $event->getUser()->getUID()); }; $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_CONNECT, $listener); - $listener = static function (JoinRoomGuestEvent $event) { + $listener = static function (JoinRoomGuestEvent $event): void { self::preventExtraGuestsFromJoining($event->getRoom()); }; $dispatcher->addListener(Room::EVENT_BEFORE_GUEST_CONNECT, $listener); - $listener = static function (AddParticipantsEvent $event) { + $listener = static function (AddParticipantsEvent $event): void { self::preventExtraUsersFromBeingAdded($event->getRoom(), $event->getParticipants()); }; $dispatcher->addListener(Room::EVENT_BEFORE_USERS_ADD, $listener); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { self::destroyRoomOnParticipantLeave($event->getRoom()); }; $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, $listener); diff --git a/lib/Service/HostedSignalingServerService.php b/lib/Service/HostedSignalingServerService.php index efb88cef5..83987ecd7 100644 --- a/lib/Service/HostedSignalingServerService.php +++ b/lib/Service/HostedSignalingServerService.php @@ -246,8 +246,12 @@ class HostedSignalingServerService { /** * @throws HostedSignalingServerAPIException + * + * @return (\ArrayAccess|array|mixed)[]|\ArrayAccess + * + * @psalm-return list, status: mixed, signaling: > */ - public function fetchAccountInfo(AccountId $accountId): array { + public function fetchAccountInfo(AccountId $accountId) { try { $nonce = $this->secureRandom->generate(32); $this->config->setAppValue('spreed', 'hosted-signaling-server-nonce', $nonce); @@ -400,8 +404,10 @@ class HostedSignalingServerService { /** * @throws HostedSignalingServerAPIException + * + * @return void */ - public function deleteAccount(AccountId $accountId) { + public function deleteAccount(AccountId $accountId): void { try { $nonce = $this->secureRandom->generate(32); $this->config->setAppValue('spreed', 'hosted-signaling-server-nonce', $nonce); diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php index e2958b1b7..0f0ec6f9d 100644 --- a/lib/Share/RoomShareProvider.php +++ b/lib/Share/RoomShareProvider.php @@ -115,7 +115,7 @@ class RoomShareProvider implements IShareProvider { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function (ParticipantEvent $event) { + $listener = static function (ParticipantEvent $event): void { $room = $event->getRoom(); if ($event->getParticipant()->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED) { @@ -126,7 +126,7 @@ class RoomShareProvider implements IShareProvider { }; $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DISCONNECT, $listener); - $listener = static function (RemoveUserEvent $event) { + $listener = static function (RemoveUserEvent $event): void { $room = $event->getRoom(); /** @var self $roomShareProvider */ @@ -135,7 +135,7 @@ class RoomShareProvider implements IShareProvider { }; $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, $listener); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { $room = $event->getRoom(); /** @var self $roomShareProvider */ diff --git a/lib/Signaling/Listener.php b/lib/Signaling/Listener.php index 59188abc0..1d481e9f4 100644 --- a/lib/Signaling/Listener.php +++ b/lib/Signaling/Listener.php @@ -53,7 +53,7 @@ class Listener { } protected static function registerInternalSignaling(IEventDispatcher $dispatcher): void { - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { if (!self::isUsingInternalSignaling()) { return; } @@ -69,7 +69,7 @@ class Listener { $dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, $listener); $dispatcher->addListener(GuestManager::EVENT_AFTER_NAME_UPDATE, $listener); - $listener = static function (ParticipantEvent $event) { + $listener = static function (ParticipantEvent $event): void { if (!self::isUsingInternalSignaling()) { return; } @@ -85,7 +85,7 @@ class Listener { $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DISCONNECT, $listener); $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_PUBLISHING_PERMISSIONS_SET, $listener); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { $room = $event->getRoom(); if (!self::isUsingInternalSignaling()) { return; @@ -109,7 +109,7 @@ class Listener { $notifier->roomInvited($event->getRoom(), $event->getParticipants()); }); - $listener = static function (RoomEvent $event) { + $listener = static function (RoomEvent $event): void { if (self::isUsingInternalSignaling()) { return; } @@ -132,7 +132,7 @@ class Listener { // "roomModified" message for participant type changes. $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, $listener); - $listener = static function (ModifyParticipantEvent $event) { + $listener = static function (ModifyParticipantEvent $event): void { if (self::isUsingInternalSignaling()) { return; } @@ -221,7 +221,7 @@ class Listener { } }); - $listener = static function (ModifyParticipantEvent $event) { + $listener = static function (ModifyParticipantEvent $event): void { if (self::isUsingInternalSignaling()) { return; }