psalm --alter --issues=MissingClosureReturnType,MismatchingDocblockReturnType,MissingReturnType,InvalidReturnType,MissingParamType

Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
Vitor Mattos 2021-10-05 14:31:59 -03:00
Родитель 251d68513b
Коммит a2e57ab980
16 изменённых файлов: 52 добавлений и 39 удалений

Просмотреть файл

@ -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());

Просмотреть файл

@ -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());

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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())

Просмотреть файл

@ -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');

Просмотреть файл

@ -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);

Просмотреть файл

@ -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));

Просмотреть файл

@ -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 */

Просмотреть файл

@ -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();

Просмотреть файл

@ -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());

Просмотреть файл

@ -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);

Просмотреть файл

@ -246,8 +246,12 @@ class HostedSignalingServerService {
/**
* @throws HostedSignalingServerAPIException
*
* @return (\ArrayAccess|array|mixed)[]|\ArrayAccess
*
* @psalm-return list<created: mixed, owner: <array>, status: mixed, signaling: <array>>
*/
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);

Просмотреть файл

@ -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 */

Просмотреть файл

@ -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;
}