From a93fbd58ecdce22c2977e57e7d613e1091e278d3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 18 Nov 2024 11:31:43 +0100 Subject: [PATCH] fix(psalm): Adjust array types Signed-off-by: Joas Schilling --- lib/Controller/ChatController.php | 3 +++ lib/Dashboard/TalkWidget.php | 2 +- lib/Model/AttachmentMapper.php | 11 ++------ lib/Model/AttendeeMapper.php | 38 +++------------------------ lib/Model/BanMapper.php | 2 +- lib/Model/BotConversationMapper.php | 4 +-- lib/Model/BotServerMapper.php | 6 ++--- lib/Model/ConsentMapper.php | 8 +++--- lib/Model/InvitationMapper.php | 4 +-- lib/Model/PollMapper.php | 10 +++---- lib/Model/ProxyCacheMessageMapper.php | 2 +- lib/Model/ReminderMapper.php | 4 +-- lib/Model/RetryNotificationMapper.php | 4 +-- lib/Model/SessionMapper.php | 14 ++++------ lib/Model/VoteMapper.php | 13 +++------ 15 files changed, 39 insertions(+), 86 deletions(-) diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 3c0c10b3cd5a..5e26b0da37b3 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -85,6 +85,7 @@ * @psalm-import-type TalkChatMessage from ResponseDefinitions * @psalm-import-type TalkChatMessageWithParent from ResponseDefinitions * @psalm-import-type TalkChatReminder from ResponseDefinitions + * @psalm-import-type TalkRichObjectParameter from ResponseDefinitions * @psalm-import-type TalkRoom from ResponseDefinitions */ class ChatController extends AEnvironmentAwareController { @@ -289,8 +290,10 @@ public function shareObjectToChat(string $objectType, string $objectId, string $ return new DataResponse([], Http::STATUS_NOT_FOUND); } + /** @var TalkRichObjectParameter $data */ $data = $metaData !== '' ? json_decode($metaData, true) : []; if (!is_array($data)) { + /** @var TalkRichObjectParameter $data */ $data = []; } $data['type'] = $objectType; diff --git a/lib/Dashboard/TalkWidget.php b/lib/Dashboard/TalkWidget.php index 94cc52ebf07c..89478c584d2e 100644 --- a/lib/Dashboard/TalkWidget.php +++ b/lib/Dashboard/TalkWidget.php @@ -95,7 +95,7 @@ public function getWidgetOptions(): WidgetOptions { } /** - * @return \OCP\Dashboard\Model\WidgetButton[] + * @return list */ public function getWidgetButtons(string $userId): array { $buttons = []; diff --git a/lib/Model/AttachmentMapper.php b/lib/Model/AttachmentMapper.php index 2a56c0c4331b..1ef2b6ce133e 100644 --- a/lib/Model/AttachmentMapper.php +++ b/lib/Model/AttachmentMapper.php @@ -16,15 +16,12 @@ /** * @method Attachment mapRowToEntity(array $row) * @method Attachment findEntity(IQueryBuilder $query) - * @method Attachment[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class AttachmentMapper extends QBMapper { use TTransactional; - /** - * @param IDBConnection $db - */ public function __construct(IDBConnection $db) { parent::__construct($db, 'talk_attachments', Attachment::class); } @@ -42,11 +39,7 @@ public function createAttachmentFromRow(array $row): Attachment { } /** - * @param int $roomId - * @param string $objectType - * @param int $offset - * @param int $limit - * @return Attachment[] + * @return list * @throws \OCP\DB\Exception */ public function getAttachmentsByType(int $roomId, string $objectType, int $offset, int $limit): array { diff --git a/lib/Model/AttendeeMapper.php b/lib/Model/AttendeeMapper.php index 100f1a7a5b12..b3e73c5c5827 100644 --- a/lib/Model/AttendeeMapper.php +++ b/lib/Model/AttendeeMapper.php @@ -18,22 +18,15 @@ /** * @method Attendee mapRowToEntity(array $row) * @method Attendee findEntity(IQueryBuilder $query) - * @method Attendee[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class AttendeeMapper extends QBMapper { - /** - * @param IDBConnection $db - */ public function __construct(IDBConnection $db) { parent::__construct($db, 'talk_attendees', Attendee::class); } /** - * @param int $roomId - * @param string $actorType - * @param string $actorId - * @return Attendee * @throws DoesNotExistException */ public function findByActor(int $roomId, string $actorType, string $actorId): Attendee { @@ -48,11 +41,8 @@ public function findByActor(int $roomId, string $actorType, string $actorId): At } /** - * @param int $id - * @return Attendee * @throws DoesNotExistException * @throws MultipleObjectsReturnedException - * @throws DBException */ public function getById(int $id): Attendee { $query = $this->db->getQueryBuilder(); @@ -64,10 +54,6 @@ public function getById(int $id): Attendee { } /** - * @param int $id - * @param string $token - * @return Attendee - * @throws DBException * @throws DoesNotExistException * @throws MultipleObjectsReturnedException */ @@ -82,10 +68,7 @@ public function getByRemoteIdAndToken(int $id, string $token): Attendee { } /** - * @param int $roomId - * @param string $actorType - * @param int|null $lastJoinedCall - * @return Attendee[] + * @return list */ public function getActorsByType(int $roomId, string $actorType, ?int $lastJoinedCall = null): array { $query = $this->db->getQueryBuilder(); @@ -102,10 +85,7 @@ public function getActorsByType(int $roomId, string $actorType, ?int $lastJoined } /** - * @param int $roomId - * @param array $actorTypes - * @param int|null $lastJoinedCall - * @return Attendee[] + * @return list */ public function getActorsByTypes(int $roomId, array $actorTypes, ?int $lastJoinedCall = null): array { $query = $this->db->getQueryBuilder(); @@ -122,9 +102,7 @@ public function getActorsByTypes(int $roomId, array $actorTypes, ?int $lastJoine } /** - * @param int $roomId - * @param array $participantType - * @return Attendee[] + * @return list * @throws DBException */ public function getActorsByParticipantTypes(int $roomId, array $participantType): array { @@ -140,12 +118,6 @@ public function getActorsByParticipantTypes(int $roomId, array $participantType) return $this->findEntities($query); } - /** - * @param int $roomId - * @param string $actorType - * @param int|null $lastJoinedCall - * @return int - */ public function getActorsCountByType(int $roomId, string $actorType, ?int $lastJoinedCall = null): int { $query = $this->db->getQueryBuilder(); $query->select($query->func()->count('*', 'num_actors')) @@ -165,9 +137,7 @@ public function getActorsCountByType(int $roomId, string $actorType, ?int $lastJ } /** - * @param int $roomId * @param int[] $participantType - * @return int */ public function countActorsByParticipantType(int $roomId, array $participantType): int { $query = $this->db->getQueryBuilder(); diff --git a/lib/Model/BanMapper.php b/lib/Model/BanMapper.php index 52f52aff9f56..4662a87cc850 100644 --- a/lib/Model/BanMapper.php +++ b/lib/Model/BanMapper.php @@ -16,7 +16,7 @@ /** * @method Ban mapRowToEntity(array $row) * @method Ban findEntity(IQueryBuilder $query) - * @method Ban[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class BanMapper extends QBMapper { diff --git a/lib/Model/BotConversationMapper.php b/lib/Model/BotConversationMapper.php index 3274c52f24c0..445c9f2e1f73 100644 --- a/lib/Model/BotConversationMapper.php +++ b/lib/Model/BotConversationMapper.php @@ -16,7 +16,7 @@ /** * @method BotConversation mapRowToEntity(array $row) * @method BotConversation findEntity(IQueryBuilder $query) - * @method BotConversation[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class BotConversationMapper extends QBMapper { @@ -29,7 +29,7 @@ public function __construct( } /** - * @return BotConversation[] + * @return list */ public function findForToken(string $token): array { $query = $this->db->getQueryBuilder(); diff --git a/lib/Model/BotServerMapper.php b/lib/Model/BotServerMapper.php index eca6dfaaedf2..0db8508b0456 100644 --- a/lib/Model/BotServerMapper.php +++ b/lib/Model/BotServerMapper.php @@ -17,7 +17,7 @@ /** * @method BotServer mapRowToEntity(array $row) * @method BotServer findEntity(IQueryBuilder $query) - * @method BotServer[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class BotServerMapper extends QBMapper { @@ -84,7 +84,7 @@ public function deleteById(int $botId): int { } /** - * @return BotServer[] + * @return list */ public function findByIds(array $botIds): array { $query = $this->db->getQueryBuilder(); @@ -96,7 +96,7 @@ public function findByIds(array $botIds): array { } /** - * @return BotServer[] + * @return list */ public function getAllBots(): array { $query = $this->db->getQueryBuilder(); diff --git a/lib/Model/ConsentMapper.php b/lib/Model/ConsentMapper.php index cebbceba5735..474943e050ac 100644 --- a/lib/Model/ConsentMapper.php +++ b/lib/Model/ConsentMapper.php @@ -15,7 +15,7 @@ /** * @method Consent mapRowToEntity(array $row) * @method Consent findEntity(IQueryBuilder $query) - * @method Consent[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class ConsentMapper extends QBMapper { @@ -26,7 +26,7 @@ public function __construct( } /** - * @return Consent[] + * @return list */ public function findForToken(string $token): array { $query = $this->db->getQueryBuilder(); @@ -46,7 +46,7 @@ public function deleteByToken(string $token): int { } /** - * @return Consent[] + * @return list */ public function findForActor(string $actorType, string $actorId): array { $query = $this->db->getQueryBuilder(); @@ -68,7 +68,7 @@ public function deleteByActor(string $actorType, string $actorId): int { } /** - * @return Consent[] + * @return list */ public function findForTokenByActor(string $token, string $actorType, string $actorId): array { $query = $this->db->getQueryBuilder(); diff --git a/lib/Model/InvitationMapper.php b/lib/Model/InvitationMapper.php index b64a33f090ad..07b9197506c0 100644 --- a/lib/Model/InvitationMapper.php +++ b/lib/Model/InvitationMapper.php @@ -23,7 +23,7 @@ * * @method Invitation mapRowToEntity(array $row) * @method Invitation findEntity(IQueryBuilder $query) - * @method Invitation[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class InvitationMapper extends QBMapper { @@ -66,7 +66,7 @@ public function getByRemoteAndAccessToken( /** * @param IUser $user - * @return Invitation[] + * @return list */ public function getInvitationsForUser(IUser $user): array { $qb = $this->db->getQueryBuilder(); diff --git a/lib/Model/PollMapper.php b/lib/Model/PollMapper.php index ee59e9937a3c..38fd8c4c228c 100644 --- a/lib/Model/PollMapper.php +++ b/lib/Model/PollMapper.php @@ -17,18 +17,17 @@ use OCP\IDBConnection; /** + * @method Poll findEntity(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class PollMapper extends QBMapper { - /** - * @param IDBConnection $db - */ public function __construct(IDBConnection $db) { parent::__construct($db, 'talk_polls', Poll::class); } /** - * @return Poll[] + * @return list */ public function getDraftsByRoomId(int $roomId): array { $query = $this->db->getQueryBuilder(); @@ -43,11 +42,8 @@ public function getDraftsByRoomId(int $roomId): array { } /** - * @param int $pollId - * @return Poll * @throws DoesNotExistException * @throws MultipleObjectsReturnedException - * @throws Exception */ public function getByPollId(int $pollId): Poll { $query = $this->db->getQueryBuilder(); diff --git a/lib/Model/ProxyCacheMessageMapper.php b/lib/Model/ProxyCacheMessageMapper.php index 23480fbc5450..e60dc13498cd 100644 --- a/lib/Model/ProxyCacheMessageMapper.php +++ b/lib/Model/ProxyCacheMessageMapper.php @@ -19,7 +19,7 @@ /** * @method ProxyCacheMessage mapRowToEntity(array $row) * @method ProxyCacheMessage findEntity(IQueryBuilder $query) - * @method ProxyCacheMessage[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class ProxyCacheMessageMapper extends QBMapper { diff --git a/lib/Model/ReminderMapper.php b/lib/Model/ReminderMapper.php index 8fa97ceaf754..1864dbbb1608 100644 --- a/lib/Model/ReminderMapper.php +++ b/lib/Model/ReminderMapper.php @@ -17,7 +17,7 @@ /** * @method Reminder mapRowToEntity(array $row) * @method Reminder findEntity(IQueryBuilder $query) - * @method Reminder[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class ReminderMapper extends QBMapper { @@ -44,7 +44,7 @@ public function findForUserAndMessage(string $userId, string $token, int $messag } /** - * @return Reminder[] + * @return list */ public function findRemindersToExecute(\DateTime $dateTime): array { $query = $this->db->getQueryBuilder(); diff --git a/lib/Model/RetryNotificationMapper.php b/lib/Model/RetryNotificationMapper.php index 40b851dd0875..2a904361a2de 100644 --- a/lib/Model/RetryNotificationMapper.php +++ b/lib/Model/RetryNotificationMapper.php @@ -15,7 +15,7 @@ /** * @method RetryNotification mapRowToEntity(array $row) * @method RetryNotification findEntity(IQueryBuilder $query) - * @method RetryNotification[] findEntities(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class RetryNotificationMapper extends QBMapper { @@ -26,7 +26,7 @@ public function __construct( } /** - * @return RetryNotification[] + * @return list */ public function getAllDue(\DateTimeInterface $dueDateTime, ?int $limit = 500): array { $query = $this->db->getQueryBuilder(); diff --git a/lib/Model/SessionMapper.php b/lib/Model/SessionMapper.php index 553dd62088a4..78c445c8a093 100644 --- a/lib/Model/SessionMapper.php +++ b/lib/Model/SessionMapper.php @@ -9,26 +9,24 @@ namespace OCA\Talk\Model; use OCA\Talk\Participant; +use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; /** * @method Session mapRowToEntity(array $row) + * @method Session findEntity(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class SessionMapper extends QBMapper { - /** - * @param IDBConnection $db - */ public function __construct(IDBConnection $db) { parent::__construct($db, 'talk_sessions', Session::class); } /** - * @param string $sessionId - * @return Session - * @throws \OCP\AppFramework\Db\DoesNotExistException + * @throws DoesNotExistException */ public function findBySessionId(string $sessionId): Session { $query = $this->db->getQueryBuilder(); @@ -40,8 +38,7 @@ public function findBySessionId(string $sessionId): Session { } /** - * @param int $attendeeId - * @return Session[] + * @return list */ public function findByAttendeeId(int $attendeeId): array { $query = $this->db->getQueryBuilder(); @@ -53,7 +50,6 @@ public function findByAttendeeId(int $attendeeId): array { } /** - * @param int $attendeeId * @return int Number of deleted entities */ public function deleteByAttendeeId(int $attendeeId): int { diff --git a/lib/Model/VoteMapper.php b/lib/Model/VoteMapper.php index 24a587d0e5b7..08d0709c3575 100644 --- a/lib/Model/VoteMapper.php +++ b/lib/Model/VoteMapper.php @@ -14,19 +14,17 @@ use OCP\IDBConnection; /** + * @method Vote findEntity(IQueryBuilder $query) + * @method list findEntities(IQueryBuilder $query) * @template-extends QBMapper */ class VoteMapper extends QBMapper { - /** - * @param IDBConnection $db - */ public function __construct(IDBConnection $db) { parent::__construct($db, 'talk_poll_votes', Vote::class); } /** - * @param int $pollId - * @return Vote[] + * @return list */ public function findByPollId(int $pollId): array { $query = $this->db->getQueryBuilder(); @@ -38,10 +36,7 @@ public function findByPollId(int $pollId): array { } /** - * @param int $pollId - * @param string $actorType - * @param string $actorId - * @return Vote[] + * @return list */ public function findByPollIdForActor(int $pollId, string $actorType, string $actorId): array { $query = $this->db->getQueryBuilder();