diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-02-02 07:35:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-02 07:35:22 +0100 |
commit | 54c2802c56d5d5ab6c8729667ce5aadf3d19c9cb (patch) | |
tree | 23c67b17b5ae7f4b00011797e9f5c73ede6a63f4 | |
parent | 467b17a0bf1b01df4410914438f8c73a7c99ba55 (diff) | |
parent | 8d0a280d131bb230a5ca902c1f1d636d54210ac0 (diff) |
Merge pull request #11510 from nextcloud/techdebt/noid/prepare-coding-standard-update
fix(CS): Prepare coding standard update
-rw-r--r-- | .php-cs-fixer.dist.php | 2 | ||||
-rw-r--r-- | lib/Activity/Provider/Call.php | 2 | ||||
-rw-r--r-- | lib/Activity/Provider/Invitation.php | 2 | ||||
-rw-r--r-- | lib/Chat/SystemMessage/Listener.php | 2 | ||||
-rw-r--r-- | lib/Collaboration/Resources/ConversationProvider.php | 2 | ||||
-rw-r--r-- | lib/Controller/ChatController.php | 4 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 9 | ||||
-rw-r--r-- | lib/Flow/Operation.php | 4 | ||||
-rw-r--r-- | lib/Manager.php | 2 | ||||
-rw-r--r-- | lib/Middleware/InjectionMiddleware.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version13000Date20210625232111.php | 4 | ||||
-rw-r--r-- | lib/Migration/Version18000Date20231024141626.php | 2 | ||||
-rw-r--r-- | lib/Service/BreakoutRoomService.php | 28 | ||||
-rw-r--r-- | lib/Service/RecordingService.php | 4 | ||||
-rw-r--r-- | lib/Service/RoomService.php | 10 | ||||
-rw-r--r-- | lib/Share/RoomShareProvider.php | 2 | ||||
-rw-r--r-- | tests/php/Recording/BackendNotifierTest.php | 2 | ||||
-rw-r--r-- | tests/php/bootstrap.php | 2 |
18 files changed, 42 insertions, 43 deletions
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 60ba8432c..67bcaf346 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -2,7 +2,7 @@ declare(strict_types=1); -require_once './vendor/autoload.php'; +require_once './vendor-bin/csfixer/vendor/autoload.php'; use Nextcloud\CodingStandard\Config; diff --git a/lib/Activity/Provider/Call.php b/lib/Activity/Provider/Call.php index a850f5948..59e5006f7 100644 --- a/lib/Activity/Provider/Call.php +++ b/lib/Activity/Provider/Call.php @@ -35,7 +35,7 @@ class Call extends Base { * @throws \InvalidArgumentException * @since 11.0.0 */ - public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent { + public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { $event = $this->preParse($event); if ($event->getSubject() === 'call') { diff --git a/lib/Activity/Provider/Invitation.php b/lib/Activity/Provider/Invitation.php index bf870c734..bd75646ca 100644 --- a/lib/Activity/Provider/Invitation.php +++ b/lib/Activity/Provider/Invitation.php @@ -35,7 +35,7 @@ class Invitation extends Base { * @throws \InvalidArgumentException * @since 11.0.0 */ - public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent { + public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { $event = $this->preParse($event); if ($event->getSubject() === 'invitation') { diff --git a/lib/Chat/SystemMessage/Listener.php b/lib/Chat/SystemMessage/Listener.php index 8bc0a07ff..52513ba74 100644 --- a/lib/Chat/SystemMessage/Listener.php +++ b/lib/Chat/SystemMessage/Listener.php @@ -426,7 +426,7 @@ class Listener implements IEventListener { } } - protected function sendSystemMessage(Room $room, string $message, array $parameters = [], Participant $participant = null, bool $shouldSkipLastMessageUpdate = false, bool $silent = false, bool $forceSystemAsActor = false): IComment { + protected function sendSystemMessage(Room $room, string $message, array $parameters = [], ?Participant $participant = null, bool $shouldSkipLastMessageUpdate = false, bool $silent = false, bool $forceSystemAsActor = false): IComment { if ($participant instanceof Participant) { $actorType = $participant->getAttendee()->getActorType(); $actorId = $participant->getAttendee()->getActorId(); diff --git a/lib/Collaboration/Resources/ConversationProvider.php b/lib/Collaboration/Resources/ConversationProvider.php index 89022c2ea..72d08be83 100644 --- a/lib/Collaboration/Resources/ConversationProvider.php +++ b/lib/Collaboration/Resources/ConversationProvider.php @@ -75,7 +75,7 @@ class ConversationProvider implements IProvider { } } - public function canAccessResource(IResource $resource, IUser $user = null): bool { + public function canAccessResource(IResource $resource, ?IUser $user = null): bool { $userId = $user instanceof IUser ? $user->getUID() : null; if ($userId === null) { throw new ResourceException('Guests are not supported at the moment'); diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index f62d76f64..829b8778e 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -103,7 +103,7 @@ class ChatController extends AEnvironmentAwareController { private ParticipantService $participantService, private SessionService $sessionService, protected AttachmentService $attachmentService, - protected avatarService $avatarService, + protected AvatarService $avatarService, protected ReminderService $reminderService, private GuestManager $guestManager, private MessageParser $messageParser, @@ -150,7 +150,7 @@ class ChatController extends AEnvironmentAwareController { /** * @return DataResponse<Http::STATUS_CREATED, ?TalkChatMessageWithParent, array{X-Chat-Last-Common-Read?: numeric-string}> */ - protected function parseCommentToResponse(IComment $comment, Message $parentMessage = null): DataResponse { + protected function parseCommentToResponse(IComment $comment, ?Message $parentMessage = null): DataResponse { $chatMessage = $this->messageParser->createMessage($this->room, $this->participant, $comment, $this->l); $this->messageParser->parseMessage($chatMessage); diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index e29e2ed5b..6f5818275 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -28,7 +28,6 @@ declare(strict_types=1); namespace OCA\Talk\Controller; -use InvalidArgumentException; use OCA\Talk\Config; use OCA\Talk\Events\AAttendeeRemovedEvent; use OCA\Talk\Events\BeforeRoomsFetchEvent; @@ -282,7 +281,7 @@ class RoomController extends AEnvironmentAwareController { public function getBreakoutRooms(): DataResponse { try { $rooms = $this->breakoutRoomService->getBreakoutRooms($this->room, $this->participant); - } catch (InvalidArgumentException $e) { + } catch (\InvalidArgumentException $e) { return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST); } @@ -534,7 +533,7 @@ class RoomController extends AEnvironmentAwareController { $this->formatRoom($room, $this->participantService->getParticipant($room, $currentUser->getUID(), false)), Http::STATUS_CREATED ); - } catch (InvalidArgumentException $e) { + } catch (\InvalidArgumentException $e) { // Same current and target user return new DataResponse([], Http::STATUS_FORBIDDEN); } catch (RoomNotFoundException $e) { @@ -642,7 +641,7 @@ class RoomController extends AEnvironmentAwareController { // Create the room try { $room = $this->roomService->createConversation($roomType, $roomName, $currentUser, $objectType, $objectId); - } catch (InvalidArgumentException $e) { + } catch (\InvalidArgumentException $e) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -852,7 +851,7 @@ class RoomController extends AEnvironmentAwareController { try { $breakoutRooms = $this->breakoutRoomService->getBreakoutRooms($this->room, $this->participant); - } catch (InvalidArgumentException $e) { + } catch (\InvalidArgumentException $e) { return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST); } diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index cd3680803..caf0753a6 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -88,7 +88,7 @@ class Operation implements IOperation { * @since 9.1 */ public function validateOperation(string $name, array $checks, string $operation): void { - list($mode, $token) = $this->parseOperationConfig($operation); + [$mode, $token] = $this->parseOperationConfig($operation); $this->validateOperationConfig($mode, $token, $this->getUser()->getUID()); } @@ -96,7 +96,7 @@ class Operation implements IOperation { $flows = $ruleMatcher->getFlows(false); foreach ($flows as $flow) { try { - list($mode, $token) = $this->parseOperationConfig($flow['operation']); + [$mode, $token] = $this->parseOperationConfig($flow['operation']); $uid = $flow['scope_actor_id']; $this->validateOperationConfig($mode, $token, $uid); diff --git a/lib/Manager.php b/lib/Manager.php index e8adc5f6b..581f8fcca 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -273,7 +273,7 @@ class Manager { * @param int|null $offset * @return Room[] */ - public function searchRoomsByToken(string $searchToken = '', int $limit = null, int $offset = null): array { + public function searchRoomsByToken(string $searchToken = '', ?int $limit = null, ?int $offset = null): array { $query = $this->db->getQueryBuilder(); $helper = new SelectHelper(); $helper->selectRoomsTable($query); diff --git a/lib/Middleware/InjectionMiddleware.php b/lib/Middleware/InjectionMiddleware.php index df5b27688..66b04e123 100644 --- a/lib/Middleware/InjectionMiddleware.php +++ b/lib/Middleware/InjectionMiddleware.php @@ -309,7 +309,7 @@ class InjectionMiddleware extends Middleware { $protection = $attribute->newInstance(); $action = $protection->getAction(); - if ('talkRoomToken' === $action) { + if ($action === 'talkRoomToken') { try { $this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), $action); } catch (MaxDelayReached $e) { diff --git a/lib/Migration/Version13000Date20210625232111.php b/lib/Migration/Version13000Date20210625232111.php index c630d7029..83d863a87 100644 --- a/lib/Migration/Version13000Date20210625232111.php +++ b/lib/Migration/Version13000Date20210625232111.php @@ -68,8 +68,8 @@ class Version13000Date20210625232111 extends SimpleMigrationStep { ]); } - /** Removed in {@see \OCA\Talk\Migration\Version18000Date20231024141626} */ - /** Recreated in {@see \OCA\Talk\Migration\Version18000Date20231024141627} */ + /** Removed in {@see Version18000Date20231024141626} */ + /** Recreated in {@see Version18000Date20231024141627} */ // if (!$schema->hasTable('talk_invitations')) { // $table = $schema->createTable('talk_invitations'); // $table->addColumn('id', Types::BIGINT, [ diff --git a/lib/Migration/Version18000Date20231024141626.php b/lib/Migration/Version18000Date20231024141626.php index a9a7325b7..0992dffa6 100644 --- a/lib/Migration/Version18000Date20231024141626.php +++ b/lib/Migration/Version18000Date20231024141626.php @@ -43,7 +43,7 @@ class Version18000Date20231024141626 extends SimpleMigrationStep { $schema = $schemaClosure(); if ($schema->hasTable('talk_invitations')) { - /** Recreated in {@see \OCA\Talk\Migration\Version18000Date20231024141627} */ + /** Recreated in {@see Version18000Date20231024141627} */ $schema->dropTable('talk_invitations'); return $schema; } diff --git a/lib/Service/BreakoutRoomService.php b/lib/Service/BreakoutRoomService.php index c4765459d..238b61203 100644 --- a/lib/Service/BreakoutRoomService.php +++ b/lib/Service/BreakoutRoomService.php @@ -229,7 +229,7 @@ class BreakoutRoomService { if ($attendee->getActorType() === Attendee::ACTOR_USERS && in_array($attendee->getActorId(), $userIds, true)) { if ($participant->hasModeratorPermissions()) { // Can not remove moderators with this method - throw new \InvalidArgumentException('moderator'); + throw new InvalidArgumentException('moderator'); } $removals[] = [ @@ -357,7 +357,7 @@ class BreakoutRoomService { */ public function broadcastChatMessage(Room $parent, Participant $participant, string $message): array { if ($parent->getBreakoutRoomMode() === BreakoutRoom::MODE_NOT_CONFIGURED) { - throw new \InvalidArgumentException('mode'); + throw new InvalidArgumentException('mode'); } $breakoutRooms = $this->manager->getMultipleRoomsByObject(BreakoutRoom::PARENT_OBJECT_TYPE, $parent->getToken()); @@ -391,18 +391,18 @@ class BreakoutRoomService { protected function setAssistanceRequest(Room $breakoutRoom, int $status): void { if ($breakoutRoom->getObjectType() !== BreakoutRoom::PARENT_OBJECT_TYPE) { - throw new \InvalidArgumentException('room'); + throw new InvalidArgumentException('room'); } if ($breakoutRoom->getLobbyState() !== Webinary::LOBBY_NONE) { - throw new \InvalidArgumentException('room'); + throw new InvalidArgumentException('room'); } if (!in_array($status, [ BreakoutRoom::STATUS_ASSISTANCE_RESET, BreakoutRoom::STATUS_ASSISTANCE_REQUESTED, ], true)) { - throw new \InvalidArgumentException('status'); + throw new InvalidArgumentException('status'); } $this->roomService->setBreakoutRoomStatus($breakoutRoom, $status); @@ -415,7 +415,7 @@ class BreakoutRoomService { */ public function startBreakoutRooms(Room $parent): array { if ($parent->getBreakoutRoomMode() === BreakoutRoom::MODE_NOT_CONFIGURED) { - throw new \InvalidArgumentException('mode'); + throw new InvalidArgumentException('mode'); } $breakoutRooms = $this->manager->getMultipleRoomsByObject(BreakoutRoom::PARENT_OBJECT_TYPE, $parent->getToken(), true); @@ -434,7 +434,7 @@ class BreakoutRoomService { */ public function stopBreakoutRooms(Room $parent): array { if ($parent->getBreakoutRoomMode() === BreakoutRoom::MODE_NOT_CONFIGURED) { - throw new \InvalidArgumentException('mode'); + throw new InvalidArgumentException('mode'); } $this->roomService->setBreakoutRoomStatus($parent, BreakoutRoom::STATUS_STOPPED); @@ -453,16 +453,16 @@ class BreakoutRoomService { public function switchBreakoutRoom(Room $parent, Participant $participant, string $targetToken): Room { if ($parent->getBreakoutRoomMode() !== BreakoutRoom::MODE_FREE) { - throw new \InvalidArgumentException('mode'); + throw new InvalidArgumentException('mode'); } if ($parent->getBreakoutRoomStatus() !== BreakoutRoom::STATUS_STARTED) { - throw new \InvalidArgumentException('status'); + throw new InvalidArgumentException('status'); } if ($participant->hasModeratorPermissions()) { // Moderators don't switch, they are part of all breakout rooms - throw new \InvalidArgumentException('moderator'); + throw new InvalidArgumentException('moderator'); } $attendee = $participant->getAttendee(); @@ -478,7 +478,7 @@ class BreakoutRoomService { } if ($target === null) { - throw new \InvalidArgumentException('target'); + throw new InvalidArgumentException('target'); } foreach ($breakoutRooms as $breakoutRoom) { @@ -525,11 +525,11 @@ class BreakoutRoomService { */ public function getBreakoutRooms(Room $parent, Participant $participant): array { if ($parent->getBreakoutRoomMode() === BreakoutRoom::MODE_NOT_CONFIGURED) { - throw new \InvalidArgumentException('mode'); + throw new InvalidArgumentException('mode'); } if (!$participant->hasModeratorPermissions() && $parent->getBreakoutRoomStatus() !== BreakoutRoom::STATUS_STARTED) { - throw new \InvalidArgumentException('status'); + throw new InvalidArgumentException('status'); } $breakoutRooms = $this->manager->getMultipleRoomsByObject(BreakoutRoom::PARENT_OBJECT_TYPE, $parent->getToken(), true); @@ -574,7 +574,7 @@ class BreakoutRoomService { ); if ($throwOnModerator && $participant->hasModeratorPermissions()) { - throw new \InvalidArgumentException('moderator'); + throw new InvalidArgumentException('moderator'); } $this->participantService->removeAttendee($breakoutRoom, $participant, AAttendeeRemovedEvent::REASON_REMOVED); diff --git a/lib/Service/RecordingService.php b/lib/Service/RecordingService.php index 999514cc9..dd6f52858 100644 --- a/lib/Service/RecordingService.php +++ b/lib/Service/RecordingService.php @@ -287,7 +287,7 @@ class RecordingService { $userFolder = $this->rootFolder->getUserFolder($owner); $recordingRootFolderName = $this->config->getRecordingFolder($owner); try { - /** @var \OCP\Files\Folder */ + /** @var Folder */ $recordingRootFolder = $userFolder->get($recordingRootFolderName); if ($recordingRootFolder->isShared()) { $this->logger->error('Talk attachment folder for user {userId} is set to a shared folder. Resetting to their root.', [ @@ -297,7 +297,7 @@ class RecordingService { $this->serverConfig->setUserValue($owner, 'spreed', 'attachment_folder', '/'); } } catch (NotFoundException $e) { - /** @var \OCP\Files\Folder */ + /** @var Folder */ $recordingRootFolder = $userFolder->newFolder($recordingRootFolderName); } try { diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index cadffa2b8..1173d359a 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -280,7 +280,7 @@ class RoomService { /** * @psalm-param RecordingService::CONSENT_REQUIRED_* $recordingConsent - * @throws \InvalidArgumentException When the room has an active call or the value is invalid + * @throws InvalidArgumentException When the room has an active call or the value is invalid */ public function setRecordingConsent(Room $room, int $recordingConsent, bool $allowUpdatingBreakoutRooms = false): void { $oldRecordingConsent = $room->getRecordingConsent(); @@ -435,8 +435,8 @@ class RoomService { * @param integer $status 0 none|1 video|2 audio * @param Participant|null $participant the Participant that changed the * state, null for the current user - * @throws \InvalidArgumentException When the status is invalid, not Room::RECORDING_* - * @throws \InvalidArgumentException When trying to start + * @throws InvalidArgumentException When the status is invalid, not Room::RECORDING_* + * @throws InvalidArgumentException When trying to start */ public function setCallRecording(Room $room, int $status = Room::RECORDING_NONE, ?Participant $participant = null): void { if (!$this->config->isRecordingEnabled() && $status !== Room::RECORDING_NONE) { @@ -728,11 +728,11 @@ class RoomService { } /** - * @throws \InvalidArgumentException When the room is a breakout room + * @throws InvalidArgumentException When the room is a breakout room */ public function setMessageExpiration(Room $room, int $seconds): void { if ($room->getObjectType() === BreakoutRoom::PARENT_OBJECT_TYPE) { - throw new \InvalidArgumentException('room'); + throw new InvalidArgumentException('room'); } $oldExpiration = $room->getMessageExpiration(); diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php index 5919900c3..caf249b13 100644 --- a/lib/Share/RoomShareProvider.php +++ b/lib/Share/RoomShareProvider.php @@ -1091,7 +1091,7 @@ class RoomShareProvider implements IShareProvider { * @param string $roomToken * @param string|null $user */ - public function deleteInRoom(string $roomToken, string $user = null): void { + public function deleteInRoom(string $roomToken, ?string $user = null): void { $this->cleanSharesByIdCache(); //First delete all custom room shares for the original shares to be removed diff --git a/tests/php/Recording/BackendNotifierTest.php b/tests/php/Recording/BackendNotifierTest.php index 5aefd4d9a..56874dfb2 100644 --- a/tests/php/Recording/BackendNotifierTest.php +++ b/tests/php/Recording/BackendNotifierTest.php @@ -75,7 +75,7 @@ class BackendNotifierTest extends TestCase { private ?ISecureRandom $secureRandom = null; /** @var IURLGenerator|MockObject */ private $urlGenerator; - private ?\OCA\Talk\Tests\php\Recording\CustomBackendNotifier $backendNotifier = null; + private ?CustomBackendNotifier $backendNotifier = null; /** @var ParticipantService|MockObject */ private $participantService; diff --git a/tests/php/bootstrap.php b/tests/php/bootstrap.php index 71e40d9c8..f5e21224f 100644 --- a/tests/php/bootstrap.php +++ b/tests/php/bootstrap.php @@ -28,4 +28,4 @@ require_once __DIR__.'/../../../../lib/base.php'; if (!class_exists('\PHPUnit\Framework\TestCase')) { require_once('PHPUnit/Autoload.php'); } -OC_Hook::clear(); +\OC_Hook::clear(); |