diff options
212 files changed, 482 insertions, 528 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 0d6768971..22074e938 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -443,4 +443,3 @@ return [ ], ], ]; - diff --git a/lib/Activity/Listener.php b/lib/Activity/Listener.php index 53c4c13c9..6a17d78f6 100644 --- a/lib/Activity/Listener.php +++ b/lib/Activity/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -64,14 +65,14 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function(ModifyParticipantEvent $event) { + $listener = static function (ModifyParticipantEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->setActive($event->getRoom()); }; $dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, $listener); - $listener = static function(RoomEvent $event) { + $listener = static function (RoomEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->generateCallActivity($event->getRoom()); @@ -81,7 +82,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) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->generateInvitationActivity($event->getRoom(), $event->getParticipants()); diff --git a/lib/Activity/Provider/Base.php b/lib/Activity/Provider/Base.php index 857cc9a54..1aa7c7b03 100644 --- a/lib/Activity/Provider/Base.php +++ b/lib/Activity/Provider/Base.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/lib/Activity/Provider/Call.php b/lib/Activity/Provider/Call.php index b67f694d4..3a134ccd0 100644 --- a/lib/Activity/Provider/Call.php +++ b/lib/Activity/Provider/Call.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -146,5 +147,4 @@ class Call extends Base { 'params' => $params, ]; } - } diff --git a/lib/Activity/Provider/Invitation.php b/lib/Activity/Provider/Invitation.php index 251f21ef6..33ff9becf 100644 --- a/lib/Activity/Provider/Invitation.php +++ b/lib/Activity/Provider/Invitation.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -59,5 +60,4 @@ class Invitation extends Base { return $event; } - } diff --git a/lib/Activity/Setting.php b/lib/Activity/Setting.php index df20ba047..e913f4e15 100644 --- a/lib/Activity/Setting.php +++ b/lib/Activity/Setting.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Activity; - use OCP\Activity\ISetting; use OCP\IL10N; @@ -93,4 +93,3 @@ class Setting implements ISetting { return false; } } - diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index fcdff6582..3b2e7e856 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @author Joachim Bauch <mail@joachim-bauch.de> @@ -62,10 +63,8 @@ use OCP\Security\CSP\AddContentSecurityPolicyEvent; use OCP\Security\FeaturePolicy\AddFeaturePolicyEvent; use OCP\Settings\IManager; - class Application extends App { - - const APP_ID = 'spreed'; + public const APP_ID = 'spreed'; public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); @@ -139,7 +138,7 @@ class Application extends App { } protected function registerNavigationLink(IServerContainer $server): void { - $server->getNavigationManager()->add(function() use ($server) { + $server->getNavigationManager()->add(function () use ($server) { /** @var Config $config */ $config = $server->query(Config::class); $user = $server->getUserSession()->getUser(); @@ -155,7 +154,7 @@ class Application extends App { } protected function registerRoomActivityHooks(IEventDispatcher $dispatcher): void { - $listener = function(ChatEvent $event) { + $listener = function (ChatEvent $event) { $room = $event->getRoom(); /** @var ITimeFactory $timeFactory */ $timeFactory = $this->getContainer()->query(ITimeFactory::class); @@ -167,7 +166,7 @@ class Application extends App { } protected function registerChatHooks(IEventDispatcher $dispatcher): void { - $listener = function(RoomEvent $event) { + $listener = function (RoomEvent $event) { /** @var ChatManager $chatManager */ $chatManager = $this->getContainer()->query(ChatManager::class); $chatManager->deleteMessages($event->getRoom()); diff --git a/lib/BackgroundJob/ExpireSignalingMessage.php b/lib/BackgroundJob/ExpireSignalingMessage.php index f5661d690..656875d08 100644 --- a/lib/BackgroundJob/ExpireSignalingMessage.php +++ b/lib/BackgroundJob/ExpireSignalingMessage.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/lib/BackgroundJob/RemoveEmptyRooms.php b/lib/BackgroundJob/RemoveEmptyRooms.php index 592a59a8e..3802a12af 100644 --- a/lib/BackgroundJob/RemoveEmptyRooms.php +++ b/lib/BackgroundJob/RemoveEmptyRooms.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> diff --git a/lib/BackgroundJob/ResetAssignedSignalingServer.php b/lib/BackgroundJob/ResetAssignedSignalingServer.php index f62882c63..2f657a748 100644 --- a/lib/BackgroundJob/ResetAssignedSignalingServer.php +++ b/lib/BackgroundJob/ResetAssignedSignalingServer.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020, Joas Schilling <coding@schilljs.com> diff --git a/lib/Capabilities.php b/lib/Capabilities.php index caa5f86c3..5e2f15f6d 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com> diff --git a/lib/Chat/AutoComplete/SearchPlugin.php b/lib/Chat/AutoComplete/SearchPlugin.php index 64d74172a..c429fee4f 100644 --- a/lib/Chat/AutoComplete/SearchPlugin.php +++ b/lib/Chat/AutoComplete/SearchPlugin.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Chat\AutoComplete; - use OCA\Talk\Files\Util; use OCA\Talk\GuestManager; use OCA\Talk\Room; diff --git a/lib/Chat/AutoComplete/Sorter.php b/lib/Chat/AutoComplete/Sorter.php index 2d35d5f49..e9994e19c 100644 --- a/lib/Chat/AutoComplete/Sorter.php +++ b/lib/Chat/AutoComplete/Sorter.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Chat\AutoComplete; - use OCA\Talk\Chat\CommentsManager; use OCP\Collaboration\AutoComplete\ISorter; @@ -62,9 +62,9 @@ class Sorter implements ISorter { $context['itemId'], 'comment', $type, - array_map(function($suggestion) { + array_map(function ($suggestion) { return $suggestion['value']['shareWith']; - }, $byType)); + }, $byType)); $search = $context['search']; @@ -75,7 +75,7 @@ class Sorter implements ISorter { if (stripos($b['label'], $search) !== 0) { return -1; } - } else if (stripos($b['label'], $search) === 0) { + } elseif (stripos($b['label'], $search) === 0) { return 1; } } diff --git a/lib/Chat/Changelog/Listener.php b/lib/Chat/Changelog/Listener.php index 8ce066b27..c89e9fda0 100644 --- a/lib/Chat/Changelog/Listener.php +++ b/lib/Chat/Changelog/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -27,9 +28,8 @@ use OCA\Talk\Events\UserEvent; use OCP\EventDispatcher\IEventDispatcher; class Listener { - public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(RoomController::EVENT_BEFORE_ROOMS_GET, static function(UserEvent $event) { + $dispatcher->addListener(RoomController::EVENT_BEFORE_ROOMS_GET, static function (UserEvent $event) { $userId = $event->getUserId(); /** @var Listener $listener */ diff --git a/lib/Chat/Changelog/Manager.php b/lib/Chat/Changelog/Manager.php index 6b3371289..04b45fbcf 100644 --- a/lib/Chat/Changelog/Manager.php +++ b/lib/Chat/Changelog/Manager.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Chat\Changelog; - use OCA\Talk\Chat\ChatManager; use OCA\Talk\Manager as RoomManager; use OCP\AppFramework\Utility\ITimeFactory; diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index aa704f5ef..56568af6f 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -45,7 +46,6 @@ use OCP\IUser; * pending notifications are removed if the messages are deleted. */ class ChatManager { - public const EVENT_BEFORE_SYSTEM_MESSAGE_SEND = self::class . '::preSendSystemMessage'; public const EVENT_AFTER_SYSTEM_MESSAGE_SEND = self::class . '::postSendSystemMessage'; public const EVENT_BEFORE_MESSAGE_SEND = self::class . '::preSendMessage'; diff --git a/lib/Chat/Command/Executor.php b/lib/Chat/Command/Executor.php index 636a3c5e6..b61acde23 100644 --- a/lib/Chat/Command/Executor.php +++ b/lib/Chat/Command/Executor.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Chat\Command; - use OCA\Talk\Chat\ChatManager; use OCA\Talk\Events\CommandEvent; use OCA\Talk\Model\Command; @@ -35,7 +35,6 @@ use OCP\IL10N; use OCP\ILogger; class Executor { - public const EVENT_APP_EXECUTE = self::class . '::execApp'; public const PLACEHOLDER_ROOM = '{ROOM}'; @@ -87,9 +86,9 @@ class Executor { if ($command->getApp() === '' && $command->getCommand() === 'help') { $output = $this->execHelp($room, $message, $arguments); - } else if ($command->getApp() !== '') { + } elseif ($command->getApp() !== '') { $output = $this->execApp($room, $message, $command, $arguments); - } else { + } else { $output = $this->execShell($room, $message, $command, $arguments); } diff --git a/lib/Chat/Command/Listener.php b/lib/Chat/Command/Listener.php index cb370dbf6..165141e16 100644 --- a/lib/Chat/Command/Listener.php +++ b/lib/Chat/Command/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Chat\Command; - use OCA\Talk\Chat\ChatManager; use OCA\Talk\Events\ChatParticipantEvent; use OCA\Talk\Model\Command; @@ -44,7 +44,7 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(ChatManager::EVENT_BEFORE_MESSAGE_SEND, static function(ChatParticipantEvent $event) { + $dispatcher->addListener(ChatManager::EVENT_BEFORE_MESSAGE_SEND, static function (ChatParticipantEvent $event) { $message = $event->getComment(); $participant = $event->getParticipant(); diff --git a/lib/Chat/Command/ShellExecutor.php b/lib/Chat/Command/ShellExecutor.php index 40515c708..605732384 100644 --- a/lib/Chat/Command/ShellExecutor.php +++ b/lib/Chat/Command/ShellExecutor.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,9 +23,7 @@ declare(strict_types=1); namespace OCA\Talk\Chat\Command; - class ShellExecutor { - public const PLACEHOLDER_ROOM = '{ROOM}'; public const PLACEHOLDER_USER = '{USER}'; public const PLACEHOLDER_ARGUMENTS = '{ARGUMENTS}'; diff --git a/lib/Chat/CommentsManager.php b/lib/Chat/CommentsManager.php index ee6df07f2..287299d29 100644 --- a/lib/Chat/CommentsManager.php +++ b/lib/Chat/CommentsManager.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Chat; - use OC\Comments\Comment; use OC\Comments\Manager; use OCP\AppFramework\Utility\ITimeFactory; diff --git a/lib/Chat/MessageParser.php b/lib/Chat/MessageParser.php index ba46c718b..176be751e 100644 --- a/lib/Chat/MessageParser.php +++ b/lib/Chat/MessageParser.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -23,7 +24,6 @@ declare(strict_types=1); namespace OCA\Talk\Chat; -use OCA\Talk\Events\ChatEvent; use OCA\Talk\Events\ChatMessageEvent; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\GuestManager; @@ -40,7 +40,6 @@ use OCP\IUserManager; * Helper class to get a rich message from a plain text message. */ class MessageParser { - public const EVENT_MESSAGE_PARSE = self::class . '::parseMessage'; /** @var IEventDispatcher */ @@ -83,7 +82,7 @@ class MessageParser { if ($comment->getActorType() === 'users') { $user = $this->userManager->get($comment->getActorId()); $displayName = $user instanceof IUser ? $user->getDisplayName() : $comment->getActorId(); - } else if ($comment->getActorType() === 'guests') { + } elseif ($comment->getActorType() === 'guests') { if (isset($guestNames[$comment->getActorId()])) { $displayName = $this->guestNames[$comment->getActorId()]; } else { @@ -93,7 +92,7 @@ class MessageParser { } $this->guestNames[$comment->getActorId()] = $displayName; } - } else if ($comment->getActorType() === 'bots') { + } elseif ($comment->getActorType() === 'bots') { $displayName = $comment->getActorId() . '-bot'; } diff --git a/lib/Chat/Notifier.php b/lib/Chat/Notifier.php index 467e5e2f7..f381a55bb 100644 --- a/lib/Chat/Notifier.php +++ b/lib/Chat/Notifier.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -207,7 +208,6 @@ class Notifier { * @param string $userId */ public function markMentionNotificationsRead(Room $chat, ?string $userId): void { - if ($userId === null || $userId === '') { return; } diff --git a/lib/Chat/Parser/Changelog.php b/lib/Chat/Parser/Changelog.php index 12e515adc..2f6621848 100644 --- a/lib/Chat/Parser/Changelog.php +++ b/lib/Chat/Parser/Changelog.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -31,7 +32,6 @@ class Changelog { * @throws \OutOfBoundsException */ public function parseMessage(Message $chatMessage): void { - if ($chatMessage->getActorType() !== 'guests' || $chatMessage->getActorId() !== 'changelog') { throw new \OutOfBoundsException('Not a changelog'); diff --git a/lib/Chat/Parser/Command.php b/lib/Chat/Parser/Command.php index f680469aa..4e093c269 100644 --- a/lib/Chat/Parser/Command.php +++ b/lib/Chat/Parser/Command.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> diff --git a/lib/Chat/Parser/Listener.php b/lib/Chat/Parser/Listener.php index fbda032e6..2cb2fac3a 100644 --- a/lib/Chat/Parser/Listener.php +++ b/lib/Chat/Parser/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -28,9 +29,8 @@ use OCA\Talk\Events\ChatMessageEvent; use OCP\EventDispatcher\IEventDispatcher; class Listener { - public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function(ChatMessageEvent $event) { + $dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function (ChatMessageEvent $event) { $message = $event->getMessage(); if ($message->getMessageType() !== 'comment') { @@ -42,7 +42,7 @@ class Listener { $parser->parseMessage($message); }, -100); - $dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function(ChatMessageEvent $event) { + $dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function (ChatMessageEvent $event) { $message = $event->getMessage(); if ($message->getMessageType() !== 'comment') { @@ -59,7 +59,7 @@ class Listener { } }, -75); - $dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function(ChatMessageEvent $event) { + $dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function (ChatMessageEvent $event) { $message = $event->getMessage(); if ($message->getMessageType() !== 'system') { @@ -77,7 +77,7 @@ class Listener { } }); - $dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function(ChatMessageEvent $event) { + $dispatcher->addListener(MessageParser::EVENT_MESSAGE_PARSE, static function (ChatMessageEvent $event) { $chatMessage = $event->getMessage(); if ($chatMessage->getMessageType() !== 'command') { diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index be3972ff5..222ac8d9c 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -22,13 +23,10 @@ declare(strict_types=1); namespace OCA\Talk\Chat\Parser; - -use OCA\Talk\Chat\ChatManager; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\GuestManager; use OCA\Talk\Model\Message; use OCA\Talk\Participant; -use OCA\Talk\Room; use OCA\Talk\Share\RoomShareProvider; use OCP\Comments\IComment; use OCP\Files\IRootFolder; @@ -106,71 +104,71 @@ class SystemMessage { if ($currentUserIsActor) { $parsedMessage = $this->l->t('You created the conversation'); } - } else if ($message === 'conversation_renamed') { + } elseif ($message === 'conversation_renamed') { $parsedMessage = $this->l->t('{actor} renamed the conversation from "%1$s" to "%2$s"', [$parameters['oldName'], $parameters['newName']]); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You renamed the conversation from "%1$s" to "%2$s"', [$parameters['oldName'], $parameters['newName']]); } - } else if ($message === 'call_started') { + } elseif ($message === 'call_started') { $parsedMessage = $this->l->t('{actor} started a call'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You started a call'); } - } else if ($message === 'call_joined') { + } elseif ($message === 'call_joined') { $parsedMessage = $this->l->t('{actor} joined the call'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You joined the call'); } - } else if ($message === 'call_left') { + } elseif ($message === 'call_left') { $parsedMessage = $this->l->t('{actor} left the call'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You left the call'); } - } else if ($message === 'call_ended') { + } elseif ($message === 'call_ended') { [$parsedMessage, $parsedParameters] = $this->parseCall($parameters); - } else if ($message === 'read_only_off') { + } elseif ($message === 'read_only_off') { $parsedMessage = $this->l->t('{actor} unlocked the conversation'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You unlocked the conversation'); } - } else if ($message === 'read_only') { + } elseif ($message === 'read_only') { $parsedMessage = $this->l->t('{actor} locked the conversation'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You locked the conversation'); } - } else if ($message === 'lobby_timer_reached') { + } elseif ($message === 'lobby_timer_reached') { $parsedMessage = $this->l->t('The conversation is now open to everyone'); - } else if ($message === 'lobby_none') { + } elseif ($message === 'lobby_none') { $parsedMessage = $this->l->t('{actor} opened the conversation to everyone'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You opened the conversation to everyone'); } - } else if ($message === 'lobby_non_moderators') { + } elseif ($message === 'lobby_non_moderators') { $parsedMessage = $this->l->t('{actor} restricted the conversation to moderators'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You restricted the conversation to moderators'); } - } else if ($message === 'guests_allowed') { + } elseif ($message === 'guests_allowed') { $parsedMessage = $this->l->t('{actor} allowed guests'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You allowed guests'); } - } else if ($message === 'guests_disallowed') { + } elseif ($message === 'guests_disallowed') { $parsedMessage = $this->l->t('{actor} disallowed guests'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You disallowed guests'); } - } else if ($message === 'password_set') { + } elseif ($message === 'password_set') { $parsedMessage = $this->l->t('{actor} set a password'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You set a password'); } - } else if ($message === 'password_removed') { + } elseif ($message === 'password_removed') { $parsedMessage = $this->l->t('{actor} removed the password'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You removed the password'); } - } else if ($message === 'user_added') { + } elseif ($message === 'user_added') { $parsedParameters['user'] = $this->getUser($parameters['user']); $parsedMessage = $this->l->t('{actor} added {user}'); if ($parsedParameters['user']['id'] === $parsedParameters['actor']['id']) { @@ -179,12 +177,12 @@ class SystemMessage { } else { $parsedMessage = $this->l->t('{actor} joined the conversation'); } - } else if ($currentUserIsActor) { + } elseif ($currentUserIsActor) { $parsedMessage = $this->l->t('You added {user}'); - } else if (!$participant->isGuest() && $participant->getUser() === $parsedParameters['user']['id']) { + } elseif (!$participant->isGuest() && $participant->getUser() === $parsedParameters['user']['id']) { $parsedMessage = $this->l->t('{actor} added you'); } - } else if ($message === 'user_removed') { + } elseif ($message === 'user_removed') { $parsedParameters['user'] = $this->getUser($parameters['user']); if ($parsedParameters['user']['id'] === $parsedParameters['actor']['id']) { if ($currentUserIsActor) { @@ -196,43 +194,43 @@ class SystemMessage { $parsedMessage = $this->l->t('{actor} removed {user}'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You removed {user}'); - } else if (!$participant->isGuest() && $participant->getUser() === $parsedParameters['user']['id']) { + } elseif (!$participant->isGuest() && $participant->getUser() === $parsedParameters['user']['id']) { $parsedMessage = $this->l->t('{actor} removed you'); } } - } else if ($message === 'moderator_promoted') { + } elseif ($message === 'moderator_promoted') { $parsedParameters['user'] = $this->getUser($parameters['user']); $parsedMessage = $this->l->t('{actor} promoted {user} to moderator'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You promoted {user} to moderator'); - } else if (!$participant->isGuest() && $participant->getUser() === $parsedParameters['user']['id']) { + } elseif (!$participant->isGuest() && $participant->getUser() === $parsedParameters['user']['id']) { $parsedMessage = $this->l->t('{actor} promoted you to moderator'); } - } else if ($message === 'moderator_demoted') { + } elseif ($message === 'moderator_demoted') { $parsedParameters['user'] = $this->getUser($parameters['user']); $parsedMessage = $this->l->t('{actor} demoted {user} from moderator'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You demoted {user} from moderator'); - } else if (!$participant->isGuest() && $participant->getUser() === $parsedParameters['user']['id']) { + } elseif (!$participant->isGuest() && $participant->getUser() === $parsedParameters['user']['id']) { $parsedMessage = $this->l->t('{actor} demoted you from moderator'); } - } else if ($message === 'guest_moderator_promoted') { + } elseif ($message === 'guest_moderator_promoted') { $parsedParameters['user'] = $this->getGuest($parameters['session']); $parsedMessage = $this->l->t('{actor} promoted {user} to moderator'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You promoted {user} to moderator'); - } else if ($participant->isGuest() && $participant->getSessionId() === $parsedParameters['user']['id']) { + } elseif ($participant->isGuest() && $participant->getSessionId() === $parsedParameters['user']['id']) { $parsedMessage = $this->l->t('{actor} promoted you to moderator'); } - } else if ($message === 'guest_moderator_demoted') { + } elseif ($message === 'guest_moderator_demoted') { $parsedParameters['user'] = $this->getGuest($parameters['session']); $parsedMessage = $this->l->t('{actor} demoted {user} from moderator'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You demoted {user} from moderator'); - } else if ($participant->isGuest() && $participant->getSessionId() === $parsedParameters['user']['id']) { + } elseif ($participant->isGuest() && $participant->getSessionId() === $parsedParameters['user']['id']) { $parsedMessage = $this->l->t('{actor} demoted you from moderator'); } - } else if ($message === 'file_shared') { + } elseif ($message === 'file_shared') { try { $parsedParameters['file'] = $this->getFileFromShare($participant, $parameters['share']); $parsedMessage = '{file}'; diff --git a/lib/Chat/Parser/UserMention.php b/lib/Chat/Parser/UserMention.php index a4a1d5901..38a20a2de 100644 --- a/lib/Chat/Parser/UserMention.php +++ b/lib/Chat/Parser/UserMention.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -114,7 +115,7 @@ class UserMention { 'name' => $chatMessage->getRoom()->getDisplayName($chatMessage->getParticipant()->getUser()), 'call-type' => $this->getRoomType($chatMessage->getRoom()), ]; - } else if ($mention['type'] === 'guest') { + } elseif ($mention['type'] === 'guest') { try { $displayName = $this->guestManager->getNameBySessionHash(substr($mention['id'], strlen('guest/'))); } catch (ParticipantNotFoundException $e) { diff --git a/lib/Chat/SystemMessage/Listener.php b/lib/Chat/SystemMessage/Listener.php index 2fa0ce69f..de0ecc480 100644 --- a/lib/Chat/SystemMessage/Listener.php +++ b/lib/Chat/SystemMessage/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Chat\SystemMessage; - use OCA\Talk\Chat\ChatManager; use OCA\Talk\Events\AddParticipantsEvent; use OCA\Talk\Events\ModifyLobbyEvent; @@ -65,7 +65,7 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, static function(ModifyParticipantEvent $event) { + $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, static function (ModifyParticipantEvent $event) { $room = $event->getRoom(); /** @var self $listener */ $listener = \OC::$server->query(self::class); @@ -76,7 +76,7 @@ class Listener { $listener->sendSystemMessage($room, 'call_started'); } }); - $dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, static function(ModifyParticipantEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, static function (ModifyParticipantEvent $event) { $room = $event->getRoom(); if ($event->getParticipant()->getInCallFlags() === Participant::FLAG_DISCONNECTED) { @@ -90,14 +90,14 @@ class Listener { $listener->sendSystemMessage($room, 'call_left', [], $event->getParticipant()); }); - $dispatcher->addListener(Room::EVENT_AFTER_ROOM_CREATE, static function(RoomEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_ROOM_CREATE, static function (RoomEvent $event) { $room = $event->getRoom(); /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'conversation_created'); }); - $dispatcher->addListener(Room::EVENT_AFTER_NAME_SET, static function(ModifyRoomEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_NAME_SET, static function (ModifyRoomEvent $event) { if ($event->getOldValue() === '' || $event->getNewValue() === '') { return; @@ -112,7 +112,7 @@ class Listener { 'oldName' => $event->getOldValue(), ]); }); - $dispatcher->addListener(Room::EVENT_AFTER_PASSWORD_SET, static function(ModifyRoomEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_PASSWORD_SET, static function (ModifyRoomEvent $event) { $room = $event->getRoom(); /** @var self $listener */ $listener = \OC::$server->query(self::class); @@ -123,20 +123,20 @@ class Listener { $listener->sendSystemMessage($room, 'password_removed'); } }); - $dispatcher->addListener(Room::EVENT_AFTER_TYPE_SET, static function(ModifyRoomEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_TYPE_SET, static function (ModifyRoomEvent $event) { $room = $event->getRoom(); if ($event->getNewValue() === Room::PUBLIC_CALL) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'guests_allowed'); - } else if ($event->getNewValue() === Room::GROUP_CALL) { + } elseif ($event->getNewValue() === Room::GROUP_CALL) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'guests_disallowed'); } }); - $dispatcher->addListener(Room::EVENT_AFTER_READONLY_SET, static function(ModifyRoomEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_READONLY_SET, static function (ModifyRoomEvent $event) { $room = $event->getRoom(); if ($room->getType() === Room::CHANGELOG_CONVERSATION) { @@ -148,11 +148,11 @@ class Listener { if ($event->getNewValue() === Room::READ_ONLY) { $listener->sendSystemMessage($room, 'read_only'); - } else if ($event->getNewValue() === Room::READ_WRITE) { + } elseif ($event->getNewValue() === Room::READ_WRITE) { $listener->sendSystemMessage($room, 'read_only_off'); } }); - $dispatcher->addListener(Room::EVENT_AFTER_LOBBY_STATE_SET, static function(ModifyLobbyEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_LOBBY_STATE_SET, static function (ModifyLobbyEvent $event) { if ($event->getNewValue() === $event->getOldValue()) { return; } @@ -164,14 +164,14 @@ class Listener { if ($event->isTimerReached()) { $listener->sendSystemMessage($room, 'lobby_timer_reached'); - } else if ($event->getNewValue() === Webinary::LOBBY_NONE) { + } elseif ($event->getNewValue() === Webinary::LOBBY_NONE) { $listener->sendSystemMessage($room, 'lobby_none'); - } else if ($event->getNewValue() === Webinary::LOBBY_NON_MODERATORS) { + } elseif ($event->getNewValue() === Webinary::LOBBY_NON_MODERATORS) { $listener->sendSystemMessage($room, 'lobby_non_moderators'); } }); - $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, static function(AddParticipantsEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, static function (AddParticipantsEvent $event) { $participants = $event->getParticipants(); $user = \OC::$server->getUserSession()->getUser(); $userId = $user instanceof IUser ? $user->getUID() : null; @@ -192,7 +192,7 @@ class Listener { } } }); - $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, static function(RemoveUserEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, static function (RemoveUserEvent $event) { $room = $event->getRoom(); if ($room->getType() === Room::ONE_TO_ONE_CALL) { @@ -203,28 +203,28 @@ class Listener { $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'user_removed', ['user' => $event->getUser()->getUID()]); }); - $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, static function(ModifyParticipantEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, static function (ModifyParticipantEvent $event) { $room = $event->getRoom(); if ($event->getNewValue() === Participant::MODERATOR) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'moderator_promoted', ['user' => $event->getParticipant()->getUser()]); - } else if ($event->getNewValue() === Participant::USER) { + } elseif ($event->getNewValue() === Participant::USER) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'moderator_demoted', ['user' => $event->getParticipant()->getUser()]); - } else if ($event->getNewValue() === Participant::GUEST_MODERATOR) { + } elseif ($event->getNewValue() === Participant::GUEST_MODERATOR) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'guest_moderator_promoted', ['session' => sha1($event->getParticipant()->getSessionId())]); - } else if ($event->getNewValue() === Participant::GUEST) { + } elseif ($event->getNewValue() === Participant::GUEST) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'guest_moderator_demoted', ['session' => sha1($event->getParticipant()->getSessionId())]); } }); - $listener = function(GenericEvent $event) { + $listener = function (GenericEvent $event) { /** @var IShare $share */ $share = $event->getSubject(); diff --git a/lib/Collaboration/Collaborators/Listener.php b/lib/Collaboration/Collaborators/Listener.php index 57bd52952..b5b2136ef 100644 --- a/lib/Collaboration/Collaborators/Listener.php +++ b/lib/Collaboration/Collaborators/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @author Joachim Bauch <mail@joachim-bauch.de> @@ -57,8 +58,7 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - - $dispatcher->addListener(IManager::class . '::filterResults', static function(AutoCompleteEvent $event) { + $dispatcher->addListener(IManager::class . '::filterResults', static function (AutoCompleteEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); diff --git a/lib/Collaboration/Collaborators/RoomPlugin.php b/lib/Collaboration/Collaborators/RoomPlugin.php index 3a55f7dfd..6d33922f0 100644 --- a/lib/Collaboration/Collaborators/RoomPlugin.php +++ b/lib/Collaboration/Collaborators/RoomPlugin.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -91,5 +92,4 @@ class RoomPlugin implements ISearchPlugin { ] ]; } - } diff --git a/lib/Collaboration/Resources/ConversationProvider.php b/lib/Collaboration/Resources/ConversationProvider.php index d1dde2909..98d48dd26 100644 --- a/lib/Collaboration/Resources/ConversationProvider.php +++ b/lib/Collaboration/Resources/ConversationProvider.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -59,9 +60,9 @@ class ConversationProvider implements IProvider { $iconURL = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('spreed', 'app-dark.svg')); /** * Disabled for now, because it would show a square avatar - if ($room->getType() === Room::ONE_TO_ONE_CALL) { - $iconURL = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => 'admin', 'size' => 32]); - } + * if ($room->getType() === Room::ONE_TO_ONE_CALL) { + * $iconURL = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => 'admin', 'size' => 32]); + * } */ return [ diff --git a/lib/Collaboration/Resources/Listener.php b/lib/Collaboration/Resources/Listener.php index 55f600c12..6005aa413 100644 --- a/lib/Collaboration/Resources/Listener.php +++ b/lib/Collaboration/Resources/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Collaboration\Resources; -use OCA\Talk\Events\AddEmailEvent; use OCA\Talk\Events\AddParticipantsEvent; use OCA\Talk\Events\RemoveParticipantEvent; use OCA\Talk\Events\RemoveUserEvent; @@ -36,7 +36,7 @@ use OCP\IUserManager; class Listener { public static function register(IEventDispatcher $dispatcher): void { - $listener = static function(RoomEvent $event) { + $listener = static function (RoomEvent $event) { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); @@ -50,7 +50,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DELETE, $listener); - $listener = static function(AddParticipantsEvent $event) { + $listener = static function (AddParticipantsEvent $event) { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); @@ -74,7 +74,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, $listener); - $listener = static function(RemoveUserEvent $event) { + $listener = static function (RemoveUserEvent $event) { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); @@ -88,7 +88,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, $listener); - $listener = static function(RemoveParticipantEvent $event) { + $listener = static function (RemoveParticipantEvent $event) { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); @@ -106,7 +106,7 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_REMOVE, $listener); - $listener = static function(RoomEvent $event) { + $listener = static function (RoomEvent $event) { $room = $event->getRoom(); /** @var IManager $manager */ $resourceManager = \OC::$server->query(IManager::class); diff --git a/lib/Command/Command/Add.php b/lib/Command/Command/Add.php index cd2d24642..e7060106e 100644 --- a/lib/Command/Command/Add.php +++ b/lib/Command/Command/Add.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -29,7 +30,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Add extends Base { - use TRenderCommand; /** @var CommandService */ @@ -115,6 +115,5 @@ class Add extends Base { $output->writeln(''); $output->writeln("<comment>If you think your command makes sense for other users as well, feel free to share it in the following github issue:\n https://github.com/nextcloud/spreed/issues/1566</comment>"); - } } diff --git a/lib/Command/Command/AddSamples.php b/lib/Command/Command/AddSamples.php index 6e601ac37..bbbd06b7e 100644 --- a/lib/Command/Command/AddSamples.php +++ b/lib/Command/Command/AddSamples.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -32,7 +33,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class AddSamples extends Base { - use TRenderCommand; /** @var CommandService */ @@ -73,7 +73,7 @@ class AddSamples extends Base { $chmod = fileperms($appPath . '/sample-commands/calc.sh'); if (!($chmod & 0x0040 || $chmod & 0x0008 || $chmod & 0x0001)) { $output->writeln('<error>sample-commands/calc.sh is not executable</error>'); - } else if (!shell_exec('which bc')) { + } elseif (!shell_exec('which bc')) { $output->writeln('<error>Can not add calculator command, because Basic calculator package (bc - https://www.gnu.org/software/bc/) is missing</error>'); } else { $this->installCommand( diff --git a/lib/Command/Command/Delete.php b/lib/Command/Command/Delete.php index ecf549d65..d1ec44730 100644 --- a/lib/Command/Command/Delete.php +++ b/lib/Command/Command/Delete.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Command/Command/ListCommand.php b/lib/Command/Command/ListCommand.php index af45de3ac..4fe019538 100644 --- a/lib/Command/Command/ListCommand.php +++ b/lib/Command/Command/ListCommand.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -29,7 +30,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ListCommand extends Base { - use TRenderCommand; /** @var CommandService */ diff --git a/lib/Command/Command/TRenderCommand.php b/lib/Command/Command/TRenderCommand.php index b70c34ec3..99fa57be5 100644 --- a/lib/Command/Command/TRenderCommand.php +++ b/lib/Command/Command/TRenderCommand.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -25,13 +26,11 @@ namespace OCA\Talk\Command\Command; use OCA\Talk\Model\Command; use OC\Core\Command\Base; use Symfony\Component\Console\Helper\Table; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; trait TRenderCommand { - protected function renderCommands(string $outputFormat, OutputInterface $output, array $commands, bool $showHelp = false): void { - $result = array_map(function(Command $command) { + $result = array_map(function (Command $command) { return $command->asArray(); }, $commands); diff --git a/lib/Command/Command/Update.php b/lib/Command/Command/Update.php index f0f807319..6dc12aaf4 100644 --- a/lib/Command/Command/Update.php +++ b/lib/Command/Command/Update.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -30,7 +31,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Update extends Base { - use TRenderCommand; /** @var CommandService */ diff --git a/lib/Command/Room/Add.php b/lib/Command/Room/Add.php index d213beb1e..c48755aa4 100644 --- a/lib/Command/Room/Add.php +++ b/lib/Command/Room/Add.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Daniel Rudolf <nextcloud.com@daniel-rudolf.de> diff --git a/lib/Command/Room/Create.php b/lib/Command/Room/Create.php index f2003e45d..bc708d838 100644 --- a/lib/Command/Room/Create.php +++ b/lib/Command/Room/Create.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Daniel Rudolf <nextcloud.com@daniel-rudolf.de> diff --git a/lib/Command/Room/Delete.php b/lib/Command/Room/Delete.php index d065cc469..986ca67a4 100644 --- a/lib/Command/Room/Delete.php +++ b/lib/Command/Room/Delete.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Daniel Rudolf <nextcloud.com@daniel-rudolf.de> diff --git a/lib/Command/Room/Demote.php b/lib/Command/Room/Demote.php index 008030811..9bdb607db 100644 --- a/lib/Command/Room/Demote.php +++ b/lib/Command/Room/Demote.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Daniel Rudolf <nextcloud.com@daniel-rudolf.de> diff --git a/lib/Command/Room/Promote.php b/lib/Command/Room/Promote.php index c55315343..44b378c74 100644 --- a/lib/Command/Room/Promote.php +++ b/lib/Command/Room/Promote.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Daniel Rudolf <nextcloud.com@daniel-rudolf.de> diff --git a/lib/Command/Room/Remove.php b/lib/Command/Room/Remove.php index 0c0f77012..aeb7313a6 100644 --- a/lib/Command/Room/Remove.php +++ b/lib/Command/Room/Remove.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Daniel Rudolf <nextcloud.com@daniel-rudolf.de> diff --git a/lib/Command/Room/TRoomCommand.php b/lib/Command/Room/TRoomCommand.php index 1b65d8d0d..1baf70793 100644 --- a/lib/Command/Room/TRoomCommand.php +++ b/lib/Command/Room/TRoomCommand.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Daniel Rudolf <nextcloud.com@daniel-rudolf.de> @@ -32,8 +33,7 @@ use OCA\Talk\Participant; use OCA\Talk\Room; use OCP\IUser; -trait TRoomCommand -{ +trait TRoomCommand { /** * @param Room $room * @param string $name diff --git a/lib/Command/Room/Update.php b/lib/Command/Room/Update.php index 500e898a8..a75dd6a7f 100644 --- a/lib/Command/Room/Update.php +++ b/lib/Command/Room/Update.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Daniel Rudolf <nextcloud.com@daniel-rudolf.de> diff --git a/lib/Command/Signaling/Add.php b/lib/Command/Signaling/Add.php index 2b421d030..735d45f13 100644 --- a/lib/Command/Signaling/Add.php +++ b/lib/Command/Signaling/Add.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> diff --git a/lib/Command/Signaling/Delete.php b/lib/Command/Signaling/Delete.php index 4404c5df9..4dc6aaa87 100644 --- a/lib/Command/Signaling/Delete.php +++ b/lib/Command/Signaling/Delete.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> @@ -64,7 +65,7 @@ class Delete extends Base { } $count = count($signaling['servers']); // remove all occurrences of $server - $servers = array_filter($signaling['servers'], function($s) use ($server) { + $servers = array_filter($signaling['servers'], function ($s) use ($server) { return $s['server'] !== $server; }); $signaling['servers'] = array_values($servers); // reindex diff --git a/lib/Command/Signaling/ListCommand.php b/lib/Command/Signaling/ListCommand.php index 4ea7bd599..d0f3382f8 100644 --- a/lib/Command/Signaling/ListCommand.php +++ b/lib/Command/Signaling/ListCommand.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> @@ -27,7 +28,6 @@ namespace OCA\Talk\Command\Signaling; use OCP\IConfig; use OC\Core\Command\Base; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ListCommand extends Base { diff --git a/lib/Command/Stun/Add.php b/lib/Command/Stun/Add.php index c12439fff..be6d9993a 100644 --- a/lib/Command/Stun/Add.php +++ b/lib/Command/Stun/Add.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> diff --git a/lib/Command/Stun/Delete.php b/lib/Command/Stun/Delete.php index 46f7aaf0a..2128dffba 100644 --- a/lib/Command/Stun/Delete.php +++ b/lib/Command/Stun/Delete.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> @@ -61,7 +62,7 @@ class Delete extends Base { } $count = count($servers); // remove all occurrences of $server - $servers = array_filter($servers, function($s) use ($server) { + $servers = array_filter($servers, function ($s) use ($server) { return $s !== $server; }); $servers = array_values($servers); // reindex diff --git a/lib/Command/Stun/ListCommand.php b/lib/Command/Stun/ListCommand.php index ecd4e5b81..f5a8a2438 100644 --- a/lib/Command/Stun/ListCommand.php +++ b/lib/Command/Stun/ListCommand.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> @@ -27,7 +28,6 @@ namespace OCA\Talk\Command\Stun; use OCP\IConfig; use OC\Core\Command\Base; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ListCommand extends Base { diff --git a/lib/Command/Turn/Add.php b/lib/Command/Turn/Add.php index fb993f900..83326fc0b 100644 --- a/lib/Command/Turn/Add.php +++ b/lib/Command/Turn/Add.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> diff --git a/lib/Command/Turn/Delete.php b/lib/Command/Turn/Delete.php index cb6d5bec4..2f09a2940 100644 --- a/lib/Command/Turn/Delete.php +++ b/lib/Command/Turn/Delete.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> @@ -68,7 +69,7 @@ class Delete extends Base { $count = count($servers); // remove all occurrences which math $server and $protocols - $servers = array_filter($servers, function($s) use ($server, $protocols) { + $servers = array_filter($servers, function ($s) use ($server, $protocols) { return $s['server'] !== $server || $s['protocols'] !== $protocols; }); $servers = array_values($servers); // reindex diff --git a/lib/Command/Turn/ListCommand.php b/lib/Command/Turn/ListCommand.php index fd26595d5..a9bf3633c 100644 --- a/lib/Command/Turn/ListCommand.php +++ b/lib/Command/Turn/ListCommand.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Denis Mosolov <denismosolov@gmail.com> @@ -27,7 +28,6 @@ namespace OCA\Talk\Command\Turn; use OCP\IConfig; use OC\Core\Command\Base; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ListCommand extends Base { diff --git a/lib/Config.php b/lib/Config.php index 0b68998f3..3bef58717 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @author Joachim Bauch <mail@joachim-bauch.de> @@ -29,7 +30,6 @@ use OCP\IUser; use OCP\Security\ISecureRandom; class Config { - public const SIGNALING_INTERNAL = 'internal'; public const SIGNALING_EXTERNAL = 'external'; public const SIGNALING_CLUSTER_CONVERSATION = 'conversation_cluster'; @@ -154,7 +154,7 @@ class Config { } if (!$this->config->getSystemValueBool('has_internet_connection', true)) { - $servers = array_filter($servers, static function($server) { + $servers = array_filter($servers, static function ($server) { return $server !== 'stun.nextcloud.com:443'; }); } @@ -227,12 +227,12 @@ class Config { $username = $timestamp . ':' . $rnd; $password = base64_encode(hash_hmac('sha1', $username, $server['secret'], true)); - return array( + return [ 'server' => $server['server'], 'username' => $username, 'password' => $password, 'protocols' => $server['protocols'], - ); + ]; } public function getSignalingMode(): string { @@ -349,5 +349,4 @@ class Config { $hash = hash_hmac('sha256', $data, $secret); return hash_equals($hash, substr($ticket, $lastColon + 1)); } - } diff --git a/lib/ContactsMenu/Providers/CallProvider.php b/lib/ContactsMenu/Providers/CallProvider.php index 569fa2bec..307923db2 100644 --- a/lib/ContactsMenu/Providers/CallProvider.php +++ b/lib/ContactsMenu/Providers/CallProvider.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright 2017 Ivan Sein <ivan@nextcloud.com> @@ -72,7 +73,7 @@ class CallProvider implements IProvider { } $user = $this->userManager->get($uid); - if(!$user instanceof IUser) { + if (!$user instanceof IUser) { // No valid user object return; } @@ -88,5 +89,4 @@ class CallProvider implements IProvider { $action = $this->actionFactory->newLinkAction($iconUrl, $talkAction, $callUrl); $entry->addAction($action); } - } diff --git a/lib/Controller/AEnvironmentAwareController.php b/lib/Controller/AEnvironmentAwareController.php index 7b03d32e7..ecb71b0ea 100644 --- a/lib/Controller/AEnvironmentAwareController.php +++ b/lib/Controller/AEnvironmentAwareController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> @@ -62,5 +63,4 @@ abstract class AEnvironmentAwareController extends OCSController { public function getParticipant(): ?Participant { return $this->participant; } - } diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index 9a08f3cd1..2603922e5 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> @@ -116,5 +117,4 @@ class CallController extends AEnvironmentAwareController { return new DataResponse(); } - } diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index d0bf74ee5..1f4afbe2b 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -128,7 +129,6 @@ class ChatController extends AEnvironmentAwareController { * found". */ public function sendMessage(string $message, string $actorDisplayName = '', string $referenceId = '', int $replyTo = 0): DataResponse { - if ($this->userId === null) { $actorType = 'guests'; $sessionId = $this->session->getSessionForRoom($this->room->getToken()); @@ -360,10 +360,10 @@ class ChatController extends AEnvironmentAwareController { * So when you are still there, it will just have a wrong read * marker for the time until your next request starts, while it will * not update the value, when you actually left the chat already. - if ($setReadMarker === 1 && $lookIntoFuture) { - $this->participant->setLastReadMessage((int) $newLastKnown->getId()); - } - */ + * if ($setReadMarker === 1 && $lookIntoFuture) { + * $this->participant->setLastReadMessage((int) $newLastKnown->getId()); + * } + */ } return $response; diff --git a/lib/Controller/CommandController.php b/lib/Controller/CommandController.php index a64e2bc52..ab6696c59 100644 --- a/lib/Controller/CommandController.php +++ b/lib/Controller/CommandController.php @@ -52,7 +52,7 @@ class CommandController extends OCSController { public function index(): DataResponse { $commands = $this->commandService->findAll(); - $result = array_map(function(Command $command) { + $result = array_map(function (Command $command) { return $command->asArray(); }, $commands); diff --git a/lib/Controller/FilesIntegrationController.php b/lib/Controller/FilesIntegrationController.php index acfbda5e5..1bd20f6de 100644 --- a/lib/Controller/FilesIntegrationController.php +++ b/lib/Controller/FilesIntegrationController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -263,5 +264,4 @@ class FilesIntegrationController extends OCSController { $file = array_shift($fileById); return $file->getName(); } - } diff --git a/lib/Controller/GuestController.php b/lib/Controller/GuestController.php index d98e4a7ef..468fb28b1 100644 --- a/lib/Controller/GuestController.php +++ b/lib/Controller/GuestController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -68,5 +69,4 @@ class GuestController extends AEnvironmentAwareController { return new DataResponse(); } - } diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index e7174b249..b75843c55 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> @@ -44,7 +45,6 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; -use OCP\Files\NotPermittedException; use OCP\ICacheFactory; use OCP\IConfig; use OCP\IInitialStateService; @@ -54,10 +54,8 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserSession; use OCP\Notification\IManager as INotificationManager; -use OCP\Util; class PageController extends Controller { - use TInitialState; /** @var string|null */ diff --git a/lib/Controller/PublicShareAuthController.php b/lib/Controller/PublicShareAuthController.php index 9221c860a..ac89f226d 100644 --- a/lib/Controller/PublicShareAuthController.php +++ b/lib/Controller/PublicShareAuthController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 6eee773a2..ccf2bcc5a 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> @@ -57,7 +58,6 @@ use OCP\IGroupManager; use OCP\IConfig; class RoomController extends AEnvironmentAwareController { - public const EVENT_BEFORE_ROOMS_GET = self::class . '::preGetRooms'; /** @var string|null */ @@ -277,7 +277,7 @@ class RoomController extends AEnvironmentAwareController { if ($roomData['notificationLevel'] === Participant::NOTIFY_DEFAULT) { if ($currentParticipant->isGuest()) { $roomData['notificationLevel'] = Participant::NOTIFY_NEVER; - } else if ($room->getType() === Room::ONE_TO_ONE_CALL) { + } elseif ($room->getType() === Room::ONE_TO_ONE_CALL) { $roomData['notificationLevel'] = Participant::NOTIFY_ALWAYS; } else { $adminSetting = (int) $this->config->getAppValue('spreed', 'default_group_notification', Participant::NOTIFY_DEFAULT); @@ -320,7 +320,7 @@ class RoomController extends AEnvironmentAwareController { $cleanGuests = false; $participantList = []; $participants = $room->getParticipants(); - uasort($participants, function(Participant $participant1, Participant $participant2) { + uasort($participants, function (Participant $participant1, Participant $participant2) { return $participant2->getLastPing() - $participant1->getLastPing(); }); @@ -448,7 +448,7 @@ class RoomController extends AEnvironmentAwareController { if ($roomData['notificationLevel'] === Participant::NOTIFY_DEFAULT) { if ($currentParticipant->isGuest()) { $roomData['notificationLevel'] = Participant::NOTIFY_NEVER; - } else if ($room->getType() === Room::ONE_TO_ONE_CALL) { + } elseif ($room->getType() === Room::ONE_TO_ONE_CALL) { $roomData['notificationLevel'] = Participant::NOTIFY_ALWAYS; } else { $adminSetting = (int) $this->config->getAppValue('spreed', 'default_group_notification', Participant::NOTIFY_DEFAULT); @@ -542,7 +542,6 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function createRoom(int $roomType, string $invite = '', string $roomName = '', string $source = ''): DataResponse { - if ($roomType !== Room::ONE_TO_ONE_CALL) { /** @var IUser $user */ $user = $this->userManager->get($this->userId); @@ -780,7 +779,6 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function setNotificationLevel(int $level): DataResponse { - if (!$this->participant->setNotificationLevel($level)) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -899,7 +897,7 @@ class RoomController extends AEnvironmentAwareController { $this->room->addUsers([ 'userId' => $newUser->getUID(), ]); - } else if ($source === 'groups') { + } elseif ($source === 'groups') { $group = $this->groupManager->get($newParticipant); if (!$group instanceof IGroup) { return new DataResponse([], Http::STATUS_NOT_FOUND); @@ -921,7 +919,7 @@ class RoomController extends AEnvironmentAwareController { } \call_user_func_array([$this->room, 'addUsers'], $participantsToAdd); - } else if ($source === 'circles') { + } elseif ($source === 'circles') { if (!$this->appManager->isEnabledForUser('circles')) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -959,7 +957,7 @@ class RoomController extends AEnvironmentAwareController { } \call_user_func_array([$this->room, 'addUsers'], $participantsToAdd); - } else if ($source === 'emails') { + } elseif ($source === 'emails') { $data = []; if ($this->room->setType(Room::PUBLIC_CALL)) { $data = ['type' => $this->room->getType()]; @@ -1032,7 +1030,7 @@ class RoomController extends AEnvironmentAwareController { && $room->getNumberOfModerators() === 1) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } - } else if ($room->getType() !== Room::CHANGELOG_CONVERSATION && + } elseif ($room->getType() !== Room::CHANGELOG_CONVERSATION && $room->getNumberOfParticipants() === 1) { $room->deleteRoom(); return new DataResponse(); diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 8b96818dc..0b8a5d349 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com> diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php index 27b8d077e..4070f7297 100644 --- a/lib/Controller/SignalingController.php +++ b/lib/Controller/SignalingController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> @@ -39,9 +40,6 @@ use OCP\AppFramework\OCSController; use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\Http\Client\IClientService; -use OCP\ICache; -use OCP\ICacheFactory; -use OCP\IConfig; use OCP\IDBConnection; use OCP\IRequest; use OCP\IUser; @@ -216,7 +214,7 @@ class SignalingController extends OCSController { $response = []; $messages = json_decode($messages, true); - foreach($messages as $message) { + foreach ($messages as $message) { $ev = $message['ev']; switch ($ev) { case 'message': @@ -281,7 +279,7 @@ class SignalingController extends OCSController { // Query all messages and send them to the user $data = $this->messages->getAndDeleteMessages($sessionId); $messageCount = count($data); - $data = array_filter($data, function($message) { + $data = array_filter($data, function ($message) { return $message['data'] !== 'refresh-participant-list'; }); @@ -525,10 +523,10 @@ class SignalingController extends OCSController { if ($action === 'join') { $room->ping($userId, $sessionId, $this->timeFactory->getTime()); - } else if ($action === 'leave') { + } elseif ($action === 'leave') { if (!empty($userId)) { $room->leaveRoom($userId, $sessionId); - } else if ($participant instanceof Participant) { + } elseif ($participant instanceof Participant) { $room->removeParticipantBySession($participant, Room::PARTICIPANT_LEFT); } } @@ -589,5 +587,4 @@ class SignalingController extends OCSController { ]; return new DataResponse($response); } - } diff --git a/lib/Controller/WebinarController.php b/lib/Controller/WebinarController.php index 75456da6c..c3ac6e5d5 100644 --- a/lib/Controller/WebinarController.php +++ b/lib/Controller/WebinarController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Events/AddEmailEvent.php b/lib/Events/AddEmailEvent.php index 2e9f5d94b..88bcd0df4 100644 --- a/lib/Events/AddEmailEvent.php +++ b/lib/Events/AddEmailEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; class AddEmailEvent extends RoomEvent { diff --git a/lib/Events/AddParticipantsEvent.php b/lib/Events/AddParticipantsEvent.php index 7c5b3cdcd..5d214bfb2 100644 --- a/lib/Events/AddParticipantsEvent.php +++ b/lib/Events/AddParticipantsEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; class AddParticipantsEvent extends RoomEvent { diff --git a/lib/Events/ChatEvent.php b/lib/Events/ChatEvent.php index 44fc6615e..2a9e548e2 100644 --- a/lib/Events/ChatEvent.php +++ b/lib/Events/ChatEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; use OCP\Comments\IComment; diff --git a/lib/Events/ChatMessageEvent.php b/lib/Events/ChatMessageEvent.php index 24fa9c518..aad88b4f0 100644 --- a/lib/Events/ChatMessageEvent.php +++ b/lib/Events/ChatMessageEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Model\Message; class ChatMessageEvent extends ChatEvent { diff --git a/lib/Events/ChatParticipantEvent.php b/lib/Events/ChatParticipantEvent.php index dded42027..b18c38410 100644 --- a/lib/Events/ChatParticipantEvent.php +++ b/lib/Events/ChatParticipantEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Participant; use OCA\Talk\Room; use OCP\Comments\IComment; diff --git a/lib/Events/CommandEvent.php b/lib/Events/CommandEvent.php index 738362d47..7683dbd75 100644 --- a/lib/Events/CommandEvent.php +++ b/lib/Events/CommandEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Model\Command; use OCA\Talk\Room; use OCP\Comments\IComment; diff --git a/lib/Events/CreateRoomTokenEvent.php b/lib/Events/CreateRoomTokenEvent.php index 16ec78fba..b218789ae 100644 --- a/lib/Events/CreateRoomTokenEvent.php +++ b/lib/Events/CreateRoomTokenEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,8 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - -use OCA\Talk\Room; use OCP\EventDispatcher\Event; class CreateRoomTokenEvent extends Event { diff --git a/lib/Events/JoinRoomGuestEvent.php b/lib/Events/JoinRoomGuestEvent.php index 12fe728ff..f0fa8e0b0 100644 --- a/lib/Events/JoinRoomGuestEvent.php +++ b/lib/Events/JoinRoomGuestEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; class JoinRoomGuestEvent extends RoomEvent { @@ -63,5 +63,4 @@ class JoinRoomGuestEvent extends RoomEvent { public function getPassedPasswordProtection(): bool { return $this->passedPasswordProtection; } - } diff --git a/lib/Events/JoinRoomUserEvent.php b/lib/Events/JoinRoomUserEvent.php index ea50d3f91..32995d19c 100644 --- a/lib/Events/JoinRoomUserEvent.php +++ b/lib/Events/JoinRoomUserEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; use OCP\IUser; @@ -72,5 +72,4 @@ class JoinRoomUserEvent extends RoomEvent { public function getPassedPasswordProtection(): bool { return $this->passedPasswordProtection; } - } diff --git a/lib/Events/ModifyLobbyEvent.php b/lib/Events/ModifyLobbyEvent.php index 810109c3e..e4c3ef19d 100644 --- a/lib/Events/ModifyLobbyEvent.php +++ b/lib/Events/ModifyLobbyEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,9 +23,7 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; -use OCP\EventDispatcher\Event; class ModifyLobbyEvent extends ModifyRoomEvent { diff --git a/lib/Events/ModifyParticipantEvent.php b/lib/Events/ModifyParticipantEvent.php index 73717866b..777e78ffe 100644 --- a/lib/Events/ModifyParticipantEvent.php +++ b/lib/Events/ModifyParticipantEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Participant; use OCA\Talk\Room; diff --git a/lib/Events/ModifyRoomEvent.php b/lib/Events/ModifyRoomEvent.php index b3de5c41b..7925fdb56 100644 --- a/lib/Events/ModifyRoomEvent.php +++ b/lib/Events/ModifyRoomEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; class ModifyRoomEvent extends RoomEvent { diff --git a/lib/Events/ParticipantEvent.php b/lib/Events/ParticipantEvent.php index 897199a88..e72c8fdb5 100644 --- a/lib/Events/ParticipantEvent.php +++ b/lib/Events/ParticipantEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Participant; use OCA\Talk\Room; diff --git a/lib/Events/RemoveParticipantEvent.php b/lib/Events/RemoveParticipantEvent.php index ae0b1583e..09878a699 100644 --- a/lib/Events/RemoveParticipantEvent.php +++ b/lib/Events/RemoveParticipantEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Participant; use OCA\Talk\Room; diff --git a/lib/Events/RemoveUserEvent.php b/lib/Events/RemoveUserEvent.php index e1af64133..fae652d76 100644 --- a/lib/Events/RemoveUserEvent.php +++ b/lib/Events/RemoveUserEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Participant; use OCA\Talk\Room; use OCP\IUser; diff --git a/lib/Events/RoomEvent.php b/lib/Events/RoomEvent.php index 961325bbf..4c2bec9e9 100644 --- a/lib/Events/RoomEvent.php +++ b/lib/Events/RoomEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; use OCP\EventDispatcher\Event; diff --git a/lib/Events/SignalingEvent.php b/lib/Events/SignalingEvent.php index 615169ae1..aa25a91c7 100644 --- a/lib/Events/SignalingEvent.php +++ b/lib/Events/SignalingEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Participant; use OCA\Talk\Room; diff --git a/lib/Events/SignalingRoomPropertiesEvent.php b/lib/Events/SignalingRoomPropertiesEvent.php index e689be3f5..1be058990 100644 --- a/lib/Events/SignalingRoomPropertiesEvent.php +++ b/lib/Events/SignalingRoomPropertiesEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; class SignalingRoomPropertiesEvent extends RoomEvent { diff --git a/lib/Events/UserEvent.php b/lib/Events/UserEvent.php index 3ebcedd05..6fd00144b 100644 --- a/lib/Events/UserEvent.php +++ b/lib/Events/UserEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCP\EventDispatcher\Event; class UserEvent extends Event { diff --git a/lib/Events/VerifyRoomPasswordEvent.php b/lib/Events/VerifyRoomPasswordEvent.php index d7d2b6d13..f19946048 100644 --- a/lib/Events/VerifyRoomPasswordEvent.php +++ b/lib/Events/VerifyRoomPasswordEvent.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Events; - use OCA\Talk\Room; class VerifyRoomPasswordEvent extends RoomEvent { diff --git a/lib/Exceptions/ForbiddenException.php b/lib/Exceptions/ForbiddenException.php index 2713f2354..09fd2bb99 100644 --- a/lib/Exceptions/ForbiddenException.php +++ b/lib/Exceptions/ForbiddenException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -24,5 +25,4 @@ declare(strict_types=1); namespace OCA\Talk\Exceptions; class ForbiddenException extends \Exception { - } diff --git a/lib/Exceptions/InvalidPasswordException.php b/lib/Exceptions/InvalidPasswordException.php index 8ef68d89f..008134f12 100644 --- a/lib/Exceptions/InvalidPasswordException.php +++ b/lib/Exceptions/InvalidPasswordException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -24,5 +25,4 @@ declare(strict_types=1); namespace OCA\Talk\Exceptions; class InvalidPasswordException extends \Exception { - } diff --git a/lib/Exceptions/ParticipantNotFoundException.php b/lib/Exceptions/ParticipantNotFoundException.php index 52a5eb3c1..d3a7b1988 100644 --- a/lib/Exceptions/ParticipantNotFoundException.php +++ b/lib/Exceptions/ParticipantNotFoundException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -24,5 +25,4 @@ declare(strict_types=1); namespace OCA\Talk\Exceptions; class ParticipantNotFoundException extends \OutOfBoundsException { - } diff --git a/lib/Exceptions/RoomNotFoundException.php b/lib/Exceptions/RoomNotFoundException.php index fd584a186..df4230764 100644 --- a/lib/Exceptions/RoomNotFoundException.php +++ b/lib/Exceptions/RoomNotFoundException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> @@ -24,5 +25,4 @@ declare(strict_types=1); namespace OCA\Talk\Exceptions; class RoomNotFoundException extends \OutOfBoundsException { - } diff --git a/lib/Exceptions/UnauthorizedException.php b/lib/Exceptions/UnauthorizedException.php index e1123592d..f8ca2f70b 100644 --- a/lib/Exceptions/UnauthorizedException.php +++ b/lib/Exceptions/UnauthorizedException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -24,5 +25,4 @@ declare(strict_types=1); namespace OCA\Talk\Exceptions; class UnauthorizedException extends \Exception { - } diff --git a/lib/Files/Listener.php b/lib/Files/Listener.php index d7cb4e8db..bcec71a98 100644 --- a/lib/Files/Listener.php +++ b/lib/Files/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -61,7 +62,7 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function(JoinRoomUserEvent $event) { + $listener = static function (JoinRoomUserEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); @@ -74,14 +75,14 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_CONNECT, $listener); - $listener = static function(JoinRoomGuestEvent $event) { + $listener = static function (JoinRoomGuestEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); try { $listener->preventGuestsFromJoiningIfNotPubliclyAccessible($event->getRoom()); } catch (UnauthorizedException $e) { - $event->setCancelJoin( true); + $event->setCancelJoin(true); } }; $dispatcher->addListener(Room::EVENT_BEFORE_GUEST_CONNECT, $listener); @@ -171,5 +172,4 @@ class Listener { throw new UnauthorizedException('Guests are not allowed in this room'); } - } diff --git a/lib/Files/TemplateLoader.php b/lib/Files/TemplateLoader.php index 185e8cb13..99d63f8c4 100644 --- a/lib/Files/TemplateLoader.php +++ b/lib/Files/TemplateLoader.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -43,7 +44,6 @@ use OCP\Util; * Helper class to add the Talk UI to the sidebar of the Files app. */ class TemplateLoader implements IEventListener { - use TInitialState; /** @var IAppManager */ @@ -102,5 +102,4 @@ class TemplateLoader implements IEventListener { $this->publishInitialStateForGuest(); } } - } diff --git a/lib/Files/Util.php b/lib/Files/Util.php index 3789ca37e..1c3fe9a74 100644 --- a/lib/Files/Util.php +++ b/lib/Files/Util.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -116,7 +117,7 @@ class Util { return null; } - $nodes = array_filter($nodes, function($node) { + $nodes = array_filter($nodes, function ($node) { return $node->getType() === FileInfo::TYPE_FILE; }); @@ -244,7 +245,7 @@ class Util { return null; } - $nodes = array_filter($nodes, function(Node $node) { + $nodes = array_filter($nodes, function (Node $node) { return $node->getType() === FileInfo::TYPE_FILE; }); if (empty($nodes)) { @@ -263,5 +264,4 @@ class Util { return null; } - } diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index ae7ec8cd8..0c97e1669 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> @@ -127,7 +128,7 @@ class Operation implements IOperation { $entity = $ruleMatcher->getEntity(); $message = $this->prepareText($entity, $eventName); - if($message === '') { + if ($message === '') { continue; } @@ -154,10 +155,10 @@ class Operation implements IOperation { protected function prepareText(IEntity $entity, string $eventName) { $message = $eventName; - if($entity instanceof IDisplayText) { + if ($entity instanceof IDisplayText) { $message = trim($entity->getDisplayText(3)); } - if($entity instanceof IUrl && $message !== '') { + if ($entity instanceof IUrl && $message !== '') { $message .= ' ' . $entity->getUrl(); } return $message; @@ -190,7 +191,7 @@ class Operation implements IOperation { */ $opConfig = \json_decode($raw, true); - if(!is_array($opConfig) || empty($opConfig)) { + if (!is_array($opConfig) || empty($opConfig)) { throw new UnexpectedValueException('Cannot decode operation details'); } @@ -201,11 +202,11 @@ class Operation implements IOperation { } protected function validateOperationConfig(int $mode, string $token, string $uid): void { - if(!in_array($mode, self::MESSAGE_MODES)) { + if (!in_array($mode, self::MESSAGE_MODES)) { throw new UnexpectedValueException('Invalid mode'); } - if(empty($token)) { + if (empty($token)) { throw new UnexpectedValueException('Invalid token'); } @@ -215,7 +216,7 @@ class Operation implements IOperation { throw new UnexpectedValueException('Room not found', $e->getCode(), $e); } - if($mode === self::MESSAGE_MODES['ROOM_MENTION']) { + if ($mode === self::MESSAGE_MODES['ROOM_MENTION']) { try { $participant = $this->getParticipant($uid, $room); if (!$participant->hasModeratorPermissions(false)) { @@ -232,7 +233,7 @@ class Operation implements IOperation { */ protected function getUser(): IUser { $user = $this->session->getUser(); - if($user === null) { + if ($user === null) { throw new UnexpectedValueException('User not logged in'); } return $user; diff --git a/lib/GuestManager.php b/lib/GuestManager.php index e26ddaee8..2408ae27d 100644 --- a/lib/GuestManager.php +++ b/lib/GuestManager.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk; - use OCA\Talk\Events\AddEmailEvent; use OCA\Talk\Events\ModifyParticipantEvent; use OCA\Talk\Exceptions\ParticipantNotFoundException; @@ -38,7 +38,6 @@ use OCP\Mail\IMailer; use OCP\Util; class GuestManager { - public const EVENT_BEFORE_EMAIL_INVITE = self::class . '::preInviteByEmail'; public const EVENT_AFTER_EMAIL_INVITE = self::class . '::postInviteByEmail'; public const EVENT_AFTER_NAME_UPDATE = self::class . '::updateName'; diff --git a/lib/Listener.php b/lib/Listener.php index 047e55c99..c4235d945 100644 --- a/lib/Listener.php +++ b/lib/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @author Joachim Bauch <mail@joachim-bauch.de> @@ -22,8 +23,6 @@ declare(strict_types=1); namespace OCA\Talk; -use OCP\Collaboration\AutoComplete\AutoCompleteEvent; -use OCP\Collaboration\AutoComplete\IManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\IUser; use OCP\IUserManager; diff --git a/lib/Listener/CSPListener.php b/lib/Listener/CSPListener.php index a3ce99946..491a0d6fe 100644 --- a/lib/Listener/CSPListener.php +++ b/lib/Listener/CSPListener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> @@ -51,5 +52,4 @@ class CSPListener implements IEventListener { $event->addPolicy($csp); } - } diff --git a/lib/Listener/FeaturePolicyListener.php b/lib/Listener/FeaturePolicyListener.php index f80d6f1be..efae3de96 100644 --- a/lib/Listener/FeaturePolicyListener.php +++ b/lib/Listener/FeaturePolicyListener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> @@ -30,7 +31,6 @@ use OCP\EventDispatcher\IEventListener; use OCP\Security\FeaturePolicy\AddFeaturePolicyEvent; class FeaturePolicyListener implements IEventListener { - public function handle(Event $event): void { if (!($event instanceof AddFeaturePolicyEvent)) { return; @@ -41,5 +41,4 @@ class FeaturePolicyListener implements IEventListener { $policy->addAllowedMicrophoneDomain('\'self\''); $event->addPolicy($policy); } - } diff --git a/lib/Listener/RestrictStartingCalls.php b/lib/Listener/RestrictStartingCalls.php index f77ff3f4c..623e96538 100644 --- a/lib/Listener/RestrictStartingCalls.php +++ b/lib/Listener/RestrictStartingCalls.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Listener; - use OCA\Talk\Events\ModifyParticipantEvent; use OCA\Talk\Exceptions\ForbiddenException; use OCA\Talk\Room; @@ -39,7 +39,7 @@ class RestrictStartingCalls { } public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, static function(ModifyParticipantEvent $event) { + $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, static function (ModifyParticipantEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->checkStartCallPermissions($event); diff --git a/lib/Manager.php b/lib/Manager.php index e55e3f6f4..aa539299b 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk; - use OCA\Talk\Chat\Changelog; use OCA\Talk\Chat\CommentsManager; use OCA\Talk\Events\CreateRoomTokenEvent; @@ -44,7 +44,6 @@ use OCP\Security\IHasher; use OCP\Security\ISecureRandom; class Manager { - public const EVENT_TOKEN_GENERATE = self::class . '::generateNewToken'; /** @var IDBConnection */ @@ -826,7 +825,6 @@ class Manager { * @throws \OutOfBoundsException */ protected function generateNewToken(IQueryBuilder $query, int $entropy, string $chars): string { - $event = new CreateRoomTokenEvent($entropy, $chars); $this->dispatcher->dispatch(self::EVENT_TOKEN_GENERATE, $event); try { diff --git a/lib/Middleware/CanUseTalkMiddleware.php b/lib/Middleware/CanUseTalkMiddleware.php index 791c17cbb..4f420f88b 100644 --- a/lib/Middleware/CanUseTalkMiddleware.php +++ b/lib/Middleware/CanUseTalkMiddleware.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Middleware/Exceptions/CanNotUseTalkException.php b/lib/Middleware/Exceptions/CanNotUseTalkException.php index 9d9266c98..bc84baac3 100644 --- a/lib/Middleware/Exceptions/CanNotUseTalkException.php +++ b/lib/Middleware/Exceptions/CanNotUseTalkException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Middleware/Exceptions/LobbyException.php b/lib/Middleware/Exceptions/LobbyException.php index 990efbe93..5aa81b8f8 100644 --- a/lib/Middleware/Exceptions/LobbyException.php +++ b/lib/Middleware/Exceptions/LobbyException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Middleware/Exceptions/NotAModeratorException.php b/lib/Middleware/Exceptions/NotAModeratorException.php index 8abda311d..88c0f9bbc 100644 --- a/lib/Middleware/Exceptions/NotAModeratorException.php +++ b/lib/Middleware/Exceptions/NotAModeratorException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Middleware/Exceptions/ReadOnlyException.php b/lib/Middleware/Exceptions/ReadOnlyException.php index ac4f082bb..1c3627ebb 100644 --- a/lib/Middleware/Exceptions/ReadOnlyException.php +++ b/lib/Middleware/Exceptions/ReadOnlyException.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Middleware/InjectionMiddleware.php b/lib/Middleware/InjectionMiddleware.php index 15c6f67ec..9b7e89427 100644 --- a/lib/Middleware/InjectionMiddleware.php +++ b/lib/Middleware/InjectionMiddleware.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/ClearResourceAccessCache.php b/lib/Migration/ClearResourceAccessCache.php index 792c5a53c..03ce1db2a 100644 --- a/lib/Migration/ClearResourceAccessCache.php +++ b/lib/Migration/ClearResourceAccessCache.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Joas Schilling <coding@schilljs.com> @@ -31,7 +32,6 @@ use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; class ClearResourceAccessCache implements IRepairStep { - protected const INVALIDATIONS = 1; /** @var IConfig */ diff --git a/lib/Migration/FixNamespaceInDatabaseTables.php b/lib/Migration/FixNamespaceInDatabaseTables.php index 4d217a2af..4d098015c 100644 --- a/lib/Migration/FixNamespaceInDatabaseTables.php +++ b/lib/Migration/FixNamespaceInDatabaseTables.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Migration; - use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; diff --git a/lib/Migration/Version2000Date20170707093535.php b/lib/Migration/Version2000Date20170707093535.php index b235c5e23..cbbd0031c 100644 --- a/lib/Migration/Version2000Date20170707093535.php +++ b/lib/Migration/Version2000Date20170707093535.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -123,5 +124,4 @@ class Version2000Date20170707093535 extends SimpleMigrationStep { return $schema; } - } diff --git a/lib/Migration/Version2000Date20171026140256.php b/lib/Migration/Version2000Date20171026140256.php index 3bb642da3..5f8b61efa 100644 --- a/lib/Migration/Version2000Date20171026140256.php +++ b/lib/Migration/Version2000Date20171026140256.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -56,7 +57,6 @@ class Version2000Date20171026140256 extends SimpleMigrationStep { * @since 13.0.0 */ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; @@ -84,6 +84,5 @@ class Version2000Date20171026140256 extends SimpleMigrationStep { ->execute(); } $output->finishProgress(); - } } diff --git a/lib/Migration/Version2000Date20171026140257.php b/lib/Migration/Version2000Date20171026140257.php index fb22b242f..ff74b1d5a 100644 --- a/lib/Migration/Version2000Date20171026140257.php +++ b/lib/Migration/Version2000Date20171026140257.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -60,7 +61,6 @@ class Version2000Date20171026140257 extends SimpleMigrationStep { * @since 13.0.0 */ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; @@ -92,7 +92,6 @@ class Version2000Date20171026140257 extends SimpleMigrationStep { ->execute(); } $output->finishProgress(); - } /** diff --git a/lib/Migration/Version2001Date20170707115443.php b/lib/Migration/Version2001Date20170707115443.php index c0875a32a..f932133be 100644 --- a/lib/Migration/Version2001Date20170707115443.php +++ b/lib/Migration/Version2001Date20170707115443.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -78,7 +79,6 @@ class Version2001Date20170707115443 extends SimpleMigrationStep { * @since 13.0.0 */ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; diff --git a/lib/Migration/Version2001Date20170913104501.php b/lib/Migration/Version2001Date20170913104501.php index 226bcd163..dd85e30e0 100644 --- a/lib/Migration/Version2001Date20170913104501.php +++ b/lib/Migration/Version2001Date20170913104501.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -69,5 +70,4 @@ class Version2001Date20170913104501 extends SimpleMigrationStep { return $schema; } - } diff --git a/lib/Migration/Version2001Date20170921145301.php b/lib/Migration/Version2001Date20170921145301.php index 718be15cb..f366a6040 100644 --- a/lib/Migration/Version2001Date20170921145301.php +++ b/lib/Migration/Version2001Date20170921145301.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -50,5 +51,4 @@ class Version2001Date20170921145301 extends SimpleMigrationStep { return $schema; } - } diff --git a/lib/Migration/Version2001Date20170929092606.php b/lib/Migration/Version2001Date20170929092606.php index 048743909..0e8618299 100644 --- a/lib/Migration/Version2001Date20170929092606.php +++ b/lib/Migration/Version2001Date20170929092606.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version2001Date20171009132424.php b/lib/Migration/Version2001Date20171009132424.php index a4b5b4ade..d1f6e7257 100644 --- a/lib/Migration/Version2001Date20171009132424.php +++ b/lib/Migration/Version2001Date20171009132424.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -54,5 +55,4 @@ class Version2001Date20171009132424 extends SimpleMigrationStep { return $schema; } - } diff --git a/lib/Migration/Version2001Date20171026134605.php b/lib/Migration/Version2001Date20171026134605.php index e4a7cfda0..bd40b396d 100644 --- a/lib/Migration/Version2001Date20171026134605.php +++ b/lib/Migration/Version2001Date20171026134605.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -158,7 +159,6 @@ class Version2001Date20171026134605 extends SimpleMigrationStep { * @since 13.0.0 */ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; @@ -210,7 +210,6 @@ class Version2001Date20171026134605 extends SimpleMigrationStep { * @param int[] $roomIdMap */ protected function copyParticipants(array $roomIdMap): void { - $insert = $this->connection->getQueryBuilder(); if (!$this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) { $insert->insert('talk_participants') @@ -256,14 +255,12 @@ class Version2001Date20171026134605 extends SimpleMigrationStep { $insert->execute(); } $result->closeCursor(); - } /** * @param int[] $roomIdMap */ protected function fixNotifications(array $roomIdMap): void { - $update = $this->connection->getQueryBuilder(); $update->update('notifications') ->set('object_id', $update->createParameter('newId')) @@ -301,14 +298,12 @@ class Version2001Date20171026134605 extends SimpleMigrationStep { $update->execute(); } $result->closeCursor(); - } /** * @param int[] $roomIdMap */ protected function fixActivities(array $roomIdMap): void { - $update = $this->connection->getQueryBuilder(); $update->update('activity') ->set('object_id', $update->createParameter('newId')) @@ -363,14 +358,12 @@ class Version2001Date20171026134605 extends SimpleMigrationStep { $update->execute(); } $result->closeCursor(); - } /** * @param int[] $roomIdMap */ protected function fixActivityMails(array $roomIdMap): void { - $update = $this->connection->getQueryBuilder(); $update->update('activity_mq') ->set('amq_subjectparams', $update->createParameter('subjectParams')) diff --git a/lib/Migration/Version2001Date20171026141336.php b/lib/Migration/Version2001Date20171026141336.php index edb9f2b3c..0ffebe0f9 100644 --- a/lib/Migration/Version2001Date20171026141336.php +++ b/lib/Migration/Version2001Date20171026141336.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version2001Date20171031102049.php b/lib/Migration/Version2001Date20171031102049.php index 1d06d1c2b..067ff2826 100644 --- a/lib/Migration/Version2001Date20171031102049.php +++ b/lib/Migration/Version2001Date20171031102049.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -49,5 +50,4 @@ class Version2001Date20171031102049 extends SimpleMigrationStep { return $schema; } - } diff --git a/lib/Migration/Version2001Date20180103144447.php b/lib/Migration/Version2001Date20180103144447.php index 77ad48d39..0af9e898b 100644 --- a/lib/Migration/Version2001Date20180103144447.php +++ b/lib/Migration/Version2001Date20180103144447.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -116,7 +117,6 @@ class Version2001Date20180103144447 extends SimpleMigrationStep { * @since 13.0.0 */ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { - if (version_compare($this->config->getAppValue('spreed', 'installed_version', '0.0.0'), '2.0.0', '<')) { // Migrations only work after 2.0.0 return; @@ -155,6 +155,5 @@ class Version2001Date20180103144447 extends SimpleMigrationStep { ->set('in_call', 'incall'); $update->execute(); } - } } diff --git a/lib/Migration/Version2001Date20180103150836.php b/lib/Migration/Version2001Date20180103150836.php index b579af9b1..852977b99 100644 --- a/lib/Migration/Version2001Date20180103150836.php +++ b/lib/Migration/Version2001Date20180103150836.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version3002Date20180319104030.php b/lib/Migration/Version3002Date20180319104030.php index ab446d193..35d1228c4 100644 --- a/lib/Migration/Version3002Date20180319104030.php +++ b/lib/Migration/Version3002Date20180319104030.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version3003Date20180707222130.php b/lib/Migration/Version3003Date20180707222130.php index c850720a9..187ffe291 100644 --- a/lib/Migration/Version3003Date20180707222130.php +++ b/lib/Migration/Version3003Date20180707222130.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Mario Danic <mario@lovelyhq.com> diff --git a/lib/Migration/Version3003Date20180718112436.php b/lib/Migration/Version3003Date20180718112436.php index c4694fab7..dacb4481e 100644 --- a/lib/Migration/Version3003Date20180718112436.php +++ b/lib/Migration/Version3003Date20180718112436.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -75,7 +76,7 @@ class Version3003Date20180718112436 extends SimpleMigrationStep { ->where($update->expr()->eq('id', $update->createParameter('room'))); $query = $this->connection->getQueryBuilder(); - $query->select( 'object_id') + $query->select('object_id') ->selectAlias($query->createFunction('MAX(' . $query->getColumnName('creation_timestamp') . ')'), 'last_activity') ->from('comments') ->where($query->expr()->eq('object_type', $query->createNamedParameter('chat'))) diff --git a/lib/Migration/Version3003Date20180718133519.php b/lib/Migration/Version3003Date20180718133519.php index 6ce1c2e38..3a195cc4c 100644 --- a/lib/Migration/Version3003Date20180718133519.php +++ b/lib/Migration/Version3003Date20180718133519.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version3003Date20180720162342.php b/lib/Migration/Version3003Date20180720162342.php index a1b893c73..d6706a85e 100644 --- a/lib/Migration/Version3003Date20180720162342.php +++ b/lib/Migration/Version3003Date20180720162342.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * diff --git a/lib/Migration/Version3003Date20180722152733.php b/lib/Migration/Version3003Date20180722152733.php index dafd3c592..8edb2de34 100644 --- a/lib/Migration/Version3003Date20180722152733.php +++ b/lib/Migration/Version3003Date20180722152733.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joachim Bauch <bauch@struktur.de> @@ -23,7 +24,6 @@ declare(strict_types=1); */ namespace OCA\Talk\Migration; -use Doctrine\DBAL\Types\Type; use OCP\DB\ISchemaWrapper; use OCP\Migration\SimpleMigrationStep; use OCP\Migration\IOutput; diff --git a/lib/Migration/Version3003Date20180722152849.php b/lib/Migration/Version3003Date20180722152849.php index faf8acfbc..3bd92746a 100644 --- a/lib/Migration/Version3003Date20180722152849.php +++ b/lib/Migration/Version3003Date20180722152849.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joachim Bauch <bauch@struktur.de> diff --git a/lib/Migration/Version3003Date20180730080327.php b/lib/Migration/Version3003Date20180730080327.php index ab1c73afa..3860d631f 100644 --- a/lib/Migration/Version3003Date20180730080327.php +++ b/lib/Migration/Version3003Date20180730080327.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version4099Date20181001123058.php b/lib/Migration/Version4099Date20181001123058.php index 90108afd7..4aaac033d 100644 --- a/lib/Migration/Version4099Date20181001123058.php +++ b/lib/Migration/Version4099Date20181001123058.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version5099Date20190121102337.php b/lib/Migration/Version5099Date20190121102337.php index dcf88c82e..50b4055ec 100644 --- a/lib/Migration/Version5099Date20190121102337.php +++ b/lib/Migration/Version5099Date20190121102337.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version5099Date20190319134820.php b/lib/Migration/Version5099Date20190319134820.php index cd7819ec9..3501d7977 100644 --- a/lib/Migration/Version5099Date20190319134820.php +++ b/lib/Migration/Version5099Date20190319134820.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Joas Schilling <coding@schilljs.com> @@ -54,5 +55,4 @@ class Version5099Date20190319134820 extends SimpleMigrationStep { return $schema; } - } diff --git a/lib/Migration/Version7000Date20190717141457.php b/lib/Migration/Version7000Date20190717141457.php index 9645bdbdf..2f415264f 100644 --- a/lib/Migration/Version7000Date20190717141457.php +++ b/lib/Migration/Version7000Date20190717141457.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version7000Date20190724121136.php b/lib/Migration/Version7000Date20190724121136.php index 74a268fa6..beb972b79 100644 --- a/lib/Migration/Version7000Date20190724121136.php +++ b/lib/Migration/Version7000Date20190724121136.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> diff --git a/lib/Migration/Version8000Date20200331144101.php b/lib/Migration/Version8000Date20200331144101.php index b98da8824..0b3cca860 100644 --- a/lib/Migration/Version8000Date20200331144101.php +++ b/lib/Migration/Version8000Date20200331144101.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020, Joas Schilling <coding@schilljs.com> @@ -30,7 +31,6 @@ use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version8000Date20200331144101 extends SimpleMigrationStep { - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version8000Date20200402124456.php b/lib/Migration/Version8000Date20200402124456.php index adff00243..b274b716b 100644 --- a/lib/Migration/Version8000Date20200402124456.php +++ b/lib/Migration/Version8000Date20200402124456.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020, Joas Schilling <coding@schilljs.com> @@ -30,7 +31,6 @@ use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version8000Date20200402124456 extends SimpleMigrationStep { - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version8000Date20200407073807.php b/lib/Migration/Version8000Date20200407073807.php index 284e81ea6..30eb81d82 100644 --- a/lib/Migration/Version8000Date20200407073807.php +++ b/lib/Migration/Version8000Date20200407073807.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -31,7 +32,6 @@ use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version8000Date20200407073807 extends SimpleMigrationStep { - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version8000Date20200407115318.php b/lib/Migration/Version8000Date20200407115318.php index a41fbce13..59fa05e44 100644 --- a/lib/Migration/Version8000Date20200407115318.php +++ b/lib/Migration/Version8000Date20200407115318.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020, Joas Schilling <coding@schilljs.com> diff --git a/lib/Model/Command.php b/lib/Model/Command.php index 8734ea812..b00a51070 100644 --- a/lib/Model/Command.php +++ b/lib/Model/Command.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -39,7 +40,6 @@ use OCP\AppFramework\Db\Entity; * @method int getEnabled() */ class Command extends Entity { - public const RESPONSE_NONE = 0; public const RESPONSE_USER = 1; public const RESPONSE_ALL = 2; diff --git a/lib/Model/CommandMapper.php b/lib/Model/CommandMapper.php index b10755259..877ce8203 100644 --- a/lib/Model/CommandMapper.php +++ b/lib/Model/CommandMapper.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> diff --git a/lib/Model/Message.php b/lib/Model/Message.php index eadb38206..6d54f04c5 100644 --- a/lib/Model/Message.php +++ b/lib/Model/Message.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,12 +23,10 @@ declare(strict_types=1); namespace OCA\Talk\Model; - use OCA\Talk\Participant; use OCA\Talk\Room; use OCP\Comments\IComment; use OCP\IL10N; -use OCP\IUser; class Message { diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php index 9f1a38e29..765a35f3c 100644 --- a/lib/Notification/Listener.php +++ b/lib/Notification/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -58,7 +59,7 @@ class Listener { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function(AddParticipantsEvent $event) { + $listener = static function (AddParticipantsEvent $event) { $room = $event->getRoom(); if ($room->getObjectType() === 'file') { @@ -71,28 +72,28 @@ class Listener { }; $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, $listener); - $listener = static function(JoinRoomUserEvent $event) { + $listener = static function (JoinRoomUserEvent $event) { /** @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) { /** @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) { /** @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) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->markCallNotificationsRead($event->getRoom()); @@ -211,8 +212,8 @@ class Listener { $this->notificationManager->markProcessed($notification); $notification->setSubject('call', [ - 'callee' => $actorId, - ]) + 'callee' => $actorId, + ]) ->setDateTime($dateTime); } catch (\InvalidArgumentException $e) { $this->logger->logException($e, ['app' => 'spreed']); diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 53627fd0a..c336103e6 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Notification; - use OCA\Talk\Chat\CommentsManager; use OCA\Talk\Chat\MessageParser; use OCA\Talk\Config; @@ -256,9 +256,9 @@ class Notifier implements INotifier { if ($notification->getSubject() === 'chat') { if ($room->getType() === Room::ONE_TO_ONE_CALL) { $subject = $l->t('{user} sent you a private message'); - } else if ($richSubjectUser) { + } elseif ($richSubjectUser) { $subject = $l->t('{user} sent a message in conversation {call}'); - } else if (!$isGuest) { + } elseif (!$isGuest) { $subject = $l->t('A deleted user sent a message in conversation {call}'); } else { try { @@ -268,12 +268,12 @@ class Notifier implements INotifier { $subject = $l->t('A guest sent a message in conversation {call}'); } } - } else if ($notification->getSubject() === 'reply') { + } elseif ($notification->getSubject() === 'reply') { if ($room->getType() === Room::ONE_TO_ONE_CALL) { $subject = $l->t('{user} replied to your private message'); - } else if ($richSubjectUser) { + } elseif ($richSubjectUser) { $subject = $l->t('{user} replied to your message in conversation {call}'); - } else if (!$isGuest) { + } elseif (!$isGuest) { $subject = $l->t('A deleted user replied to your message in conversation {call}'); } else { try { @@ -283,11 +283,11 @@ class Notifier implements INotifier { $subject = $l->t('A guest replied to your message in conversation {call}'); } } - } else if ($room->getType() === Room::ONE_TO_ONE_CALL) { + } elseif ($room->getType() === Room::ONE_TO_ONE_CALL) { $subject = $l->t('{user} mentioned you in a private conversation'); - } else if ($richSubjectUser) { + } elseif ($richSubjectUser) { $subject = $l->t('{user} mentioned you in conversation {call}'); - } else if (!$isGuest) { + } elseif (!$isGuest) { $subject = $l->t('A deleted user mentioned you in conversation {call}'); } else { try { @@ -398,8 +398,7 @@ class Notifier implements INotifier { ], ] ); - - } else if (\in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + } elseif (\in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { $subject = $l->t('{user} invited you to a group conversation: {call}'); if ($room->hasSessionsInCall()) { $notification = $this->addActionButton($notification, $l->t('Join call')); @@ -478,8 +477,7 @@ class Notifier implements INotifier { } else { throw new AlreadyProcessedException(); } - - } else if (\in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + } elseif (\in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { if ($this->notificationManager->isPreparingPushNotification() || $room->hasSessionsInCall()) { $notification = $this->addActionButton($notification, $l->t('Join call')); $subject = $l->t('A group call has started in {call}'); @@ -500,7 +498,6 @@ class Notifier implements INotifier { ], ] ); - } else { throw new AlreadyProcessedException(); } @@ -555,13 +552,13 @@ class Notifier implements INotifier { $notification ->setParsedSubject(str_replace(['{email}', '{file}'], [$sharedWith, $file['name']], $subject)) ->setRichSubject($subject, [ - 'email' => [ - 'type' => 'email', - 'id' => $sharedWith, - 'name' => $sharedWith, - ], - 'file' => $file, - ] + 'email' => [ + 'type' => 'email', + 'id' => $sharedWith, + 'name' => $sharedWith, + ], + 'file' => $file, + ] ); } else { if ($callIsActive) { diff --git a/lib/Participant.php b/lib/Participant.php index fd43553c7..a8ea6c7d9 100644 --- a/lib/Participant.php +++ b/lib/Participant.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/lib/PublicShare/TemplateLoader.php b/lib/PublicShare/TemplateLoader.php index de5f55554..38a18f330 100644 --- a/lib/PublicShare/TemplateLoader.php +++ b/lib/PublicShare/TemplateLoader.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -43,7 +44,6 @@ use Symfony\Component\EventDispatcher\GenericEvent; * needed. */ class TemplateLoader { - use TInitialState; public function __construct(IInitialStateService $initialStateService, @@ -57,7 +57,7 @@ class TemplateLoader { } public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', static function(GenericEvent $event) { + $dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', static function (GenericEvent $event) { /** @var IShare $share */ $share = $event->getArgument('share'); /** @var self $templateLoader */ @@ -89,5 +89,4 @@ class TemplateLoader { $this->publishInitialStateForGuest(); } - } diff --git a/lib/PublicShareAuth/Listener.php b/lib/PublicShareAuth/Listener.php index 35a6cb7f4..a0518504f 100644 --- a/lib/PublicShareAuth/Listener.php +++ b/lib/PublicShareAuth/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -45,19 +46,18 @@ use OCP\EventDispatcher\IEventDispatcher; * different room events. */ class Listener { - public static function register(IEventDispatcher $dispatcher): void { - $listener = static function(JoinRoomUserEvent $event) { + $listener = static function (JoinRoomUserEvent $event) { 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) { self::preventExtraGuestsFromJoining($event->getRoom()); }; $dispatcher->addListener(Room::EVENT_BEFORE_GUEST_CONNECT, $listener); - $listener = static function(RoomEvent $event) { + $listener = static function (RoomEvent $event) { self::destroyRoomOnParticipantLeave($event->getRoom()); }; $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, $listener); @@ -130,5 +130,4 @@ class Listener { $room->deleteRoom(); } - } diff --git a/lib/PublicShareAuth/TemplateLoader.php b/lib/PublicShareAuth/TemplateLoader.php index 1e7e0ab58..1b96fe419 100644 --- a/lib/PublicShareAuth/TemplateLoader.php +++ b/lib/PublicShareAuth/TemplateLoader.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -41,7 +42,6 @@ use Symfony\Component\EventDispatcher\GenericEvent; * Talk UI as needed. */ class TemplateLoader { - use TInitialState; public function __construct(IInitialStateService $initialStateService, @@ -55,7 +55,7 @@ class TemplateLoader { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function(GenericEvent $event) { + $listener = static function (GenericEvent $event) { /** @var IShare $share */ $share = $event->getArgument('share'); /** @var self $templateLoader */ @@ -88,5 +88,4 @@ class TemplateLoader { $this->publishInitialStateForGuest(); } - } diff --git a/lib/Room.php b/lib/Room.php index 0791b6c67..d087a2112 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> @@ -461,7 +462,6 @@ class Room { * @return bool */ public function setActiveSince(\DateTime $since, bool $isGuest): bool { - if ($isGuest && $this->getType() === self::PUBLIC_CALL) { $query = $this->db->getQueryBuilder(); $query->update('talk_rooms') @@ -758,7 +758,6 @@ class Room { $query->execute(); $this->dispatcher->dispatch(self::EVENT_AFTER_USER_REMOVE, $event); - } /** diff --git a/lib/Service/CommandService.php b/lib/Service/CommandService.php index b7d147cd8..a6b732a6c 100644 --- a/lib/Service/CommandService.php +++ b/lib/Service/CommandService.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Service; - use OCA\Talk\Chat\Command\ShellExecutor; use OCA\Talk\Model\Command; use OCA\Talk\Model\CommandMapper; diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index f162ef652..751c187aa 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Settings\Admin; - use OCA\Talk\Config; use OCA\Talk\Model\Command; use OCA\Talk\Participant; @@ -83,7 +83,7 @@ class AdminSettings implements ISettings { protected function initCommands(): void { $commands = $this->commandService->findAll(); - $result = array_map(function(Command $command) { + $result = array_map(function (Command $command) { return $command->asArray(); }, $commands); @@ -124,5 +124,4 @@ class AdminSettings implements ISettings { public function getPriority(): int { return 0; } - } diff --git a/lib/Settings/Admin/Section.php b/lib/Settings/Admin/Section.php index 2d2de7ecb..167544471 100644 --- a/lib/Settings/Admin/Section.php +++ b/lib/Settings/Admin/Section.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Settings\Admin; - use OCP\IL10N; use OCP\IURLGenerator; use OCP\Settings\IIconSection; diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index d37fad4e4..59da32032 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net> @@ -24,7 +25,6 @@ declare(strict_types=1); namespace OCA\Talk\Settings; - use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\Settings\ISettings; diff --git a/lib/Share/Helper/DeletedShareAPIController.php b/lib/Share/Helper/DeletedShareAPIController.php index f09e276de..6f5254d58 100644 --- a/lib/Share/Helper/DeletedShareAPIController.php +++ b/lib/Share/Helper/DeletedShareAPIController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -26,8 +27,6 @@ namespace OCA\Talk\Share\Helper; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Manager; use OCA\Talk\Room; -use OCP\IUser; -use OCP\IUserManager; use OCP\Share\IShare; /** @@ -74,5 +73,4 @@ class DeletedShareAPIController { return $result; } - } diff --git a/lib/Share/Helper/ShareAPIController.php b/lib/Share/Helper/ShareAPIController.php index d45a98b4f..004b58768 100644 --- a/lib/Share/Helper/ShareAPIController.php +++ b/lib/Share/Helper/ShareAPIController.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -30,7 +31,6 @@ use OCA\Talk\Room; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IL10N; -use OCP\IUser; use OCP\IUserManager; use OCP\Share\IShare; @@ -174,5 +174,4 @@ class ShareAPIController { return true; } - } diff --git a/lib/Share/Listener.php b/lib/Share/Listener.php index 13575fc46..30f324145 100644 --- a/lib/Share/Listener.php +++ b/lib/Share/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com> @@ -30,7 +31,6 @@ use OCP\Share\IShare; use Symfony\Component\EventDispatcher\GenericEvent; class Listener { - public static function register(IEventDispatcher $dispatcher): void { $dispatcher->addListener('OCP\Share::preShare', [self::class, 'listenPreShare'], 1000); $dispatcher->addListener(VerifyMountPointEvent::class, [self::class, 'listenVerifyMountPointEvent'], 1000); diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php index 7878e771f..2f93ead11 100644 --- a/lib/Share/RoomShareProvider.php +++ b/lib/Share/RoomShareProvider.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -103,7 +104,7 @@ class RoomShareProvider implements IShareProvider { } public static function register(IEventDispatcher $dispatcher): void { - $listener = static function(ParticipantEvent $event) { + $listener = static function (ParticipantEvent $event) { $room = $event->getRoom(); if ($event->getParticipant()->getParticipantType() === Participant::USER_SELF_JOINED) { @@ -114,7 +115,7 @@ class RoomShareProvider implements IShareProvider { }; $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DISCONNECT, $listener); - $listener = static function(RemoveUserEvent $event) { + $listener = static function (RemoveUserEvent $event) { $room = $event->getRoom(); /** @var self $roomShareProvider */ @@ -123,7 +124,7 @@ class RoomShareProvider implements IShareProvider { }; $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, $listener); - $listener = static function(RoomEvent $event) { + $listener = static function (RoomEvent $event) { $room = $event->getRoom(); /** @var self $roomShareProvider */ @@ -414,7 +415,7 @@ class RoomShareProvider implements IShareProvider { 'permissions' => $qb->createNamedParameter(0), 'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()), ])->execute(); - } else if ($data['permissions'] !== 0) { + } elseif ($data['permissions'] !== 0) { // Already a userroom share. Update it. $qb = $this->dbConnection->getQueryBuilder(); $qb->update('share') @@ -795,7 +796,9 @@ class RoomShareProvider implements IShareProvider { $qb->andWhere($qb->expr()->eq('s.file_source', $qb->createNamedParameter($node->getId()))); } - $rooms = array_map(function(Room $room) { return $room->getToken(); }, $rooms); + $rooms = array_map(function (Room $room) { + return $room->getToken(); + }, $rooms); $qb->andWhere($qb->expr()->eq('s.share_type', $qb->createNamedParameter(IShare::TYPE_ROOM))) ->andWhere($qb->expr()->in('s.share_with', $qb->createNamedParameter( @@ -838,7 +841,7 @@ class RoomShareProvider implements IShareProvider { $pathSections = explode('/', $data['path'], 2); // FIXME: would not detect rare md5'd home storage case properly if ($pathSections[0] !== 'files' - && in_array(explode(':', $data['storage_string_id'], 2)[0], array('home', 'object'))) { + && in_array(explode(':', $data['storage_string_id'], 2)[0], ['home', 'object'])) { return false; } return true; @@ -948,7 +951,7 @@ class RoomShareProvider implements IShareProvider { $cursor = $qb->execute(); $users = []; - while($row = $cursor->fetch()) { + while ($row = $cursor->fetch()) { $type = (int)$row['share_type']; if ($type === IShare::TYPE_ROOM) { $roomToken = $row['share_with']; @@ -963,7 +966,7 @@ class RoomShareProvider implements IShareProvider { $users[$uid] = $users[$uid] ?? []; $users[$uid][$row['id']] = $row; } - } else if ($type === self::SHARE_TYPE_USERROOM && $currentAccess === true) { + } elseif ($type === self::SHARE_TYPE_USERROOM && $currentAccess === true) { $uid = $row['share_with']; $users[$uid] = $users[$uid] ?? []; $users[$uid][$row['id']] = $row; @@ -1070,7 +1073,7 @@ class RoomShareProvider implements IShareProvider { $cursor = $qb->execute(); $ids = []; - while($row = $cursor->fetch()) { + while ($row = $cursor->fetch()) { $ids[] = (int)$row['id']; } $cursor->closeCursor(); @@ -1107,7 +1110,7 @@ class RoomShareProvider implements IShareProvider { $cursor = $qb->execute(); $ids = []; - while($row = $cursor->fetch()) { + while ($row = $cursor->fetch()) { $ids[] = (int)$row['id']; } $cursor->closeCursor(); @@ -1144,7 +1147,7 @@ class RoomShareProvider implements IShareProvider { ); $cursor = $qb->execute(); - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $share = $this->createShareObject($data); yield $share; diff --git a/lib/Signaling/BackendNotifier.php b/lib/Signaling/BackendNotifier.php index 87d6a4558..718521821 100644 --- a/lib/Signaling/BackendNotifier.php +++ b/lib/Signaling/BackendNotifier.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joachim Bauch <bauch@struktur.de> @@ -100,7 +101,7 @@ class BackendNotifier { $url = $signaling['server'] . $url; if (strpos($url, 'wss://') === 0) { $url = 'https://' . substr($url, 6); - } else if (strpos($url, 'ws://') === 0) { + } elseif (strpos($url, 'ws://') === 0) { $url = 'http://' . substr($url, 5); } $body = json_encode($data); @@ -328,5 +329,4 @@ class BackendNotifier { ], ]); } - } diff --git a/lib/Signaling/Listener.php b/lib/Signaling/Listener.php index 6b1c8d0c3..3081a4c8d 100644 --- a/lib/Signaling/Listener.php +++ b/lib/Signaling/Listener.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -27,9 +28,7 @@ use OCA\Talk\Config; use OCA\Talk\Events\AddParticipantsEvent; use OCA\Talk\Events\ChatEvent; use OCA\Talk\Events\ChatParticipantEvent; -use OCA\Talk\Events\ModifyLobbyEvent; use OCA\Talk\Events\ModifyParticipantEvent; -use OCA\Talk\Events\ModifyRoomEvent; use OCA\Talk\Events\ParticipantEvent; use OCA\Talk\Events\RemoveParticipantEvent; use OCA\Talk\Events\RemoveUserEvent; @@ -40,7 +39,6 @@ use OCA\Talk\Room; use OCP\EventDispatcher\IEventDispatcher; class Listener { - public static function register(IEventDispatcher $dispatcher): void { self::registerInternalSignaling($dispatcher); self::registerExternalSignaling($dispatcher); @@ -53,7 +51,7 @@ class Listener { } protected static function registerInternalSignaling(IEventDispatcher $dispatcher): void { - $listener = static function(RoomEvent $event) { + $listener = static function (RoomEvent $event) { if (!self::isUsingInternalSignaling()) { return; } @@ -68,7 +66,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) { if (!self::isUsingInternalSignaling()) { return; } @@ -92,7 +90,7 @@ class Listener { $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_REMOVE, $listener); $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DISCONNECT, $listener); - $listener = static function(RoomEvent $event) { + $listener = static function (RoomEvent $event) { $room = $event->getRoom(); if (!self::isUsingInternalSignaling()) { return; @@ -112,7 +110,7 @@ class Listener { } protected static function registerExternalSignaling(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, static function(AddParticipantsEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, static function (AddParticipantsEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -122,7 +120,7 @@ class Listener { $notifier->roomInvited($event->getRoom(), $event->getParticipants()); }); - $listener = static function(RoomEvent $event) { + $listener = static function (RoomEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -141,7 +139,7 @@ class Listener { // "participantsModified" once the clients no longer expect a // "roomModified" message for participant type changes. $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, $listener); - $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, static function(ModifyParticipantEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, static function (ModifyParticipantEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -158,7 +156,7 @@ class Listener { } $notifier->participantsModified($event->getRoom(), $sessionIds); }); - $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DELETE, static function(RoomEvent $event) { + $dispatcher->addListener(Room::EVENT_BEFORE_ROOM_DELETE, static function (RoomEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -170,7 +168,7 @@ class Listener { $participants = $room->getParticipantsLegacy(); $notifier->roomDeleted($room, $participants); }); - $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, static function(RemoveUserEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, static function (RemoveUserEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -180,7 +178,7 @@ class Listener { $notifier->roomsDisinvited($event->getRoom(), [$event->getUser()->getUID()]); }); - $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_REMOVE, static function(RemoveParticipantEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_PARTICIPANT_REMOVE, static function (RemoveParticipantEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -191,7 +189,7 @@ class Listener { $notifier->roomSessionsRemoved($event->getRoom(), [$event->getParticipant()->getSessionId()]); }); - $listener = static function(ModifyParticipantEvent $event) { + $listener = static function (ModifyParticipantEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -208,7 +206,7 @@ class Listener { $dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, $listener); $dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, $listener); - $dispatcher->addListener(Room::EVENT_AFTER_GUESTS_CLEAN, static function(RoomEvent $event) { + $dispatcher->addListener(Room::EVENT_AFTER_GUESTS_CLEAN, static function (RoomEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -221,7 +219,7 @@ class Listener { $sessionIds = []; $notifier->participantsModified($event->getRoom(), $sessionIds); }); - $dispatcher->addListener(GuestManager::EVENT_AFTER_NAME_UPDATE, static function(ModifyParticipantEvent $event) { + $dispatcher->addListener(GuestManager::EVENT_AFTER_NAME_UPDATE, static function (ModifyParticipantEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -231,7 +229,7 @@ class Listener { $notifier->participantsModified($event->getRoom(), [$event->getParticipant()->getSessionId()]); }); - $dispatcher->addListener(ChatManager::EVENT_AFTER_MESSAGE_SEND , static function(ChatParticipantEvent $event) { + $dispatcher->addListener(ChatManager::EVENT_AFTER_MESSAGE_SEND , static function (ChatParticipantEvent $event) { if (self::isUsingInternalSignaling()) { return; } @@ -248,7 +246,7 @@ class Listener { ]; $notifier->sendRoomMessage($room, $message); }); - $dispatcher->addListener(ChatManager::EVENT_AFTER_SYSTEM_MESSAGE_SEND, static function(ChatEvent $event) { + $dispatcher->addListener(ChatManager::EVENT_AFTER_SYSTEM_MESSAGE_SEND, static function (ChatEvent $event) { if (self::isUsingInternalSignaling()) { return; } diff --git a/lib/Signaling/Manager.php b/lib/Signaling/Manager.php index f59e8868b..36486c78d 100644 --- a/lib/Signaling/Manager.php +++ b/lib/Signaling/Manager.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Signaling; - use OCA\Talk\Config; use OCA\Talk\Room; use OCP\ICache; diff --git a/lib/Signaling/Messages.php b/lib/Signaling/Messages.php index a1d8d144e..83407e144 100644 --- a/lib/Signaling/Messages.php +++ b/lib/Signaling/Messages.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk\Signaling; - use OCA\Talk\Room; use OCP\AppFramework\Utility\ITimeFactory; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/lib/TInitialState.php b/lib/TInitialState.php index ea24e17ca..5b689e53b 100644 --- a/lib/TInitialState.php +++ b/lib/TInitialState.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk; - use OC\HintException; use OC\User\NoUserException; use OCP\App\IAppManager; @@ -70,7 +70,6 @@ trait TInitialState { } protected function publishInitialStateForUser(IUser $user, IRootFolder $rootFolder, IAppManager $appManager): void { - $this->publishInitialStateShared(); $this->initialStateService->provideInitialState( @@ -103,7 +102,6 @@ trait TInitialState { } protected function publishInitialStateForGuest(): void { - $this->publishInitialStateShared(); $this->initialStateService->provideInitialState( diff --git a/lib/TalkSession.php b/lib/TalkSession.php index 669f1b75c..667001a2e 100644 --- a/lib/TalkSession.php +++ b/lib/TalkSession.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace OCA\Talk; - use OCP\ISession; class TalkSession { @@ -132,5 +132,4 @@ class TalkSession { $this->session->set($key, json_encode($values)); } - } diff --git a/lib/Webinary.php b/lib/Webinary.php index 7b15053f1..d29866b6a 100644 --- a/lib/Webinary.php +++ b/lib/Webinary.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,10 +23,7 @@ declare(strict_types=1); namespace OCA\Talk; - class Webinary { - public const LOBBY_NONE = 0; public const LOBBY_NON_MODERATORS = 1; - } diff --git a/sample-commands/hackernews.php b/sample-commands/hackernews.php index aae000202..3c341b3f0 100644 --- a/sample-commands/hackernews.php +++ b/sample-commands/hackernews.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -65,10 +66,10 @@ foreach ($stories as $storyId) { $page = 'news'; if ($mode === 'new') { $page = 'newest'; -} else if ($mode === 'best') { +} elseif ($mode === 'best') { $page = 'best'; } $response .= "Find more at https://news.ycombinator.com/$page"; -echo ($response); +echo($response); diff --git a/sample-commands/wikipedia.php b/sample-commands/wikipedia.php index 398f9d1a5..58bdd6720 100644 --- a/sample-commands/wikipedia.php +++ b/sample-commands/wikipedia.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -83,4 +84,4 @@ if ($maxArticles < $numArticles) { $response .= '* and ' . ($numArticles - $maxArticles) ." more articles found\n"; } -echo ($response); +echo($response); diff --git a/templates/index.php b/templates/index.php index e3d4ecd4a..b3949fe93 100644 --- a/templates/index.php +++ b/templates/index.php @@ -1,4 +1,5 @@ <?php + /** @var \OCP\IL10N $l */ /** @var array $_ */ diff --git a/tests/acceptance/features/bootstrap/ChatAncestorSetter.php b/tests/acceptance/features/bootstrap/ChatAncestorSetter.php index 6842f5aa8..2ded22ba9 100644 --- a/tests/acceptance/features/bootstrap/ChatAncestorSetter.php +++ b/tests/acceptance/features/bootstrap/ChatAncestorSetter.php @@ -21,7 +21,6 @@ * */ -use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; /** @@ -62,5 +61,4 @@ trait ChatAncestorSetter { private function setChatAncestorForActor($chatAncestor, Actor $actor) { $this->chatContext->setChatAncestorForActor($chatAncestor, $actor); } - } diff --git a/tests/acceptance/features/bootstrap/ChatContext.php b/tests/acceptance/features/bootstrap/ChatContext.php index 0f377c95b..7af0256d8 100644 --- a/tests/acceptance/features/bootstrap/ChatContext.php +++ b/tests/acceptance/features/bootstrap/ChatContext.php @@ -44,7 +44,7 @@ class ChatContext implements Context, ActorAwareInterface { * @BeforeScenario */ public function initializeChatAncestors() { - $this->chatAncestorsByActor = array(); + $this->chatAncestorsByActor = []; $this->chatAncestor = null; } @@ -461,5 +461,4 @@ class ChatContext implements Context, ActorAwareInterface { public function iSeeThatTheMessageContainsAFormattedFilePreview($number) { PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::formattedFilePreviewInChatMessage($this->chatAncestor, $number), 10)); } - } diff --git a/tests/acceptance/features/bootstrap/ConversationInfoContext.php b/tests/acceptance/features/bootstrap/ConversationInfoContext.php index 8fac25417..23381244d 100644 --- a/tests/acceptance/features/bootstrap/ConversationInfoContext.php +++ b/tests/acceptance/features/bootstrap/ConversationInfoContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class ConversationInfoContext implements Context, ActorAwareInterface { - use ActorAware; /** @@ -260,5 +259,4 @@ class ConversationInfoContext implements Context, ActorAwareInterface { $this->actor->find(self::roomModerationButton(), 10)->click(); } - } diff --git a/tests/acceptance/features/bootstrap/ConversationListContext.php b/tests/acceptance/features/bootstrap/ConversationListContext.php index 1d8e6d8d8..739ed42a6 100644 --- a/tests/acceptance/features/bootstrap/ConversationListContext.php +++ b/tests/acceptance/features/bootstrap/ConversationListContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class ConversationListContext implements Context, ActorAwareInterface { - use ActorAware; use ChatAncestorSetter; @@ -176,7 +175,7 @@ class ConversationListContext implements Context, ActorAwareInterface { // It is assumed that the search input is empty, so no backspace or // delete keys are sent to remove the previous content like done in the // Selenium2 driver for Mink. - $webDriverElement->postValue(array('value' => array($value))); + $webDriverElement->postValue(['value' => [$value]]); } /** @@ -275,5 +274,4 @@ class ConversationListContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::fail("The $conversation conversation is still active after $timeout seconds"); } } - } diff --git a/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php b/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php index caa638924..8c761a8bf 100644 --- a/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php @@ -25,7 +25,6 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; class FilesAppChatTabContext implements Context, ActorAwareInterface { - use ActorAware; use ChatAncestorSetter; @@ -97,5 +96,4 @@ class FilesAppChatTabContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::fail("The chat was not shown yet in the chat tab after $timeout seconds"); } } - } diff --git a/tests/acceptance/features/bootstrap/FilesAppRoomSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppRoomSharingContext.php index f64574ade..ee8b7f7ac 100644 --- a/tests/acceptance/features/bootstrap/FilesAppRoomSharingContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppRoomSharingContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class FilesAppRoomSharingContext implements Context, ActorAwareInterface { - use ActorAware; /** @@ -34,5 +33,4 @@ class FilesAppRoomSharingContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::assertEquals( $this->actor->find(FilesAppSharingContext::sharedByLabel(), 10)->getText(), "Shared with you and the conversation $conversationName by $sharedByName"); } - } diff --git a/tests/acceptance/features/bootstrap/ParticipantListContext.php b/tests/acceptance/features/bootstrap/ParticipantListContext.php index 1907223e4..bf3585866 100644 --- a/tests/acceptance/features/bootstrap/ParticipantListContext.php +++ b/tests/acceptance/features/bootstrap/ParticipantListContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class ParticipantListContext implements Context, ActorAwareInterface { - use ActorAware; /** @@ -91,7 +90,7 @@ class ParticipantListContext implements Context, ActorAwareInterface { * @Then I see that the number of participants shown in the list is :numberOfParticipants */ public function iSeeThatTheNumberOfParticipantsShownInTheListIs($numberOfParticipants) { - $numberOfParticipantsMatchCallback = function() use ($numberOfParticipants) { + $numberOfParticipantsMatchCallback = function () use ($numberOfParticipants) { try { return count($this->participantsListItems()) === intval($numberOfParticipants); } catch (NoSuchElementException $exception) { @@ -128,5 +127,4 @@ class ParticipantListContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::fail("Participant $participantName is still marked as a moderator after $timeout seconds but it should be a normal participant instead"); } } - } diff --git a/tests/acceptance/features/bootstrap/PublicConversationContext.php b/tests/acceptance/features/bootstrap/PublicConversationContext.php index e13c9fd47..db9200ac0 100644 --- a/tests/acceptance/features/bootstrap/PublicConversationContext.php +++ b/tests/acceptance/features/bootstrap/PublicConversationContext.php @@ -25,7 +25,6 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; class PublicConversationContext implements Context, ActorAwareInterface { - use ActorAware; use ChatAncestorSetter; @@ -135,5 +134,4 @@ class PublicConversationContext implements Context, ActorAwareInterface { // it needs to be checked too that the chat view is shown. $this->chatContext->iSeeThatTheChatIsShownInTheMainView(); } - } diff --git a/tests/acceptance/features/bootstrap/PublicSharePasswordRequestContext.php b/tests/acceptance/features/bootstrap/PublicSharePasswordRequestContext.php index ad344d3d5..f4253cf31 100644 --- a/tests/acceptance/features/bootstrap/PublicSharePasswordRequestContext.php +++ b/tests/acceptance/features/bootstrap/PublicSharePasswordRequestContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class PublicSharePasswordRequestContext implements Context, ActorAwareInterface { - use ActorAware; use ChatAncestorSetter; @@ -77,5 +76,4 @@ class PublicSharePasswordRequestContext implements Context, ActorAwareInterface } catch (NoSuchElementException $exception) { } } - } diff --git a/tests/acceptance/features/bootstrap/TalkAppContext.php b/tests/acceptance/features/bootstrap/TalkAppContext.php index 09f12076a..b583b4b3a 100644 --- a/tests/acceptance/features/bootstrap/TalkAppContext.php +++ b/tests/acceptance/features/bootstrap/TalkAppContext.php @@ -24,7 +24,6 @@ use Behat\Behat\Context\Context; class TalkAppContext implements Context, ActorAwareInterface { - use ActorAware; /** @@ -162,5 +161,4 @@ class TalkAppContext implements Context, ActorAwareInterface { $this->iOpenTheTalkApp(); $this->iSeeThatTheCurrentPageIsTheTalkApp(); } - } diff --git a/tests/acceptance/features/bootstrap/TalkPublicShareContext.php b/tests/acceptance/features/bootstrap/TalkPublicShareContext.php index a25f33786..540d0d506 100644 --- a/tests/acceptance/features/bootstrap/TalkPublicShareContext.php +++ b/tests/acceptance/features/bootstrap/TalkPublicShareContext.php @@ -22,7 +22,6 @@ */ class TalkPublicShareContext extends PublicShareContext { - use ChatAncestorSetter; /** @@ -73,5 +72,4 @@ class TalkPublicShareContext extends PublicShareContext { } catch (NoSuchElementException $exception) { } } - } diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index e7fda0f14..db78038ff 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -134,7 +134,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $rooms = $this->getDataFromResponse($this->response); - $rooms = array_filter($rooms, function($room) { + $rooms = array_filter($rooms, function ($room) { return $room['type'] !== 4; }); @@ -144,8 +144,8 @@ class FeatureContext implements Context, SnippetAcceptingContext { } Assert::assertCount(count($formData->getHash()), $rooms, 'Room count does not match'); - Assert::assertEquals($formData->getHash(), array_map(function($room, $expectedRoom) { - $participantNames = array_map(function($participant) { + Assert::assertEquals($formData->getHash(), array_map(function ($room, $expectedRoom) { + $participantNames = array_map(function ($participant) { return $participant['name']; }, $room['participants']); @@ -200,7 +200,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $rooms = $this->getDataFromResponse($this->response); - $rooms = array_filter($rooms, function($room) { + $rooms = array_filter($rooms, function ($room) { return $room['type'] !== 4; }); @@ -534,7 +534,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { public function userSetsLobbyStateForRoomTo($user, $identifier, $lobbyStateString, $statusCode) { if ($lobbyStateString === 'no lobby') { $lobbyState = 0; - } else if ($lobbyStateString === 'non moderators') { + } elseif ($lobbyStateString === 'non moderators') { $lobbyState = 1; } else { Assert::fail('Invalid lobby state'); @@ -776,7 +776,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $actual = $this->getDataFromResponse($this->response); $messages = []; - array_map(function(array $message) use (&$messages) { + array_map(function (array $message) use (&$messages) { // Filter out system messages if ($message['systemMessage'] === '') { $messages[] = $message; @@ -804,7 +804,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $messages[$i]['messageParameters'] = 'IGNORE'; } } - Assert::assertEquals($formData->getHash(), array_map(function($message) use($includeParents, $includeReferenceId) { + Assert::assertEquals($formData->getHash(), array_map(function ($message) use ($includeParents, $includeReferenceId) { $data = [ 'room' => self::$tokenToIdentifier[$message['token']], 'actorType' => $message['actorType'], @@ -838,7 +838,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { $this->assertStatusCode($this->response, $statusCode); $messages = $this->getDataFromResponse($this->response); - $messages = array_filter($messages, function(array $message) { + $messages = array_filter($messages, function (array $message) { return $message['systemMessage'] !== ''; }); @@ -854,7 +854,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { } Assert::assertCount(count($formData->getHash()), $messages, 'Message count does not match'); - Assert::assertEquals($formData->getHash(), array_map(function($message) { + Assert::assertEquals($formData->getHash(), array_map(function ($message) { return [ 'room' => self::$tokenToIdentifier[$message['token']], 'actorType' => (string) $message['actorType'], @@ -1176,13 +1176,13 @@ class FeatureContext implements Context, SnippetAcceptingContext { $options = ['cookies' => $this->getUserCookieJar($this->currentUser)]; if ($this->currentUser === 'admin') { $options['auth'] = ['admin', 'admin']; - } else if (strpos($this->currentUser, 'guest') !== 0) { + } elseif (strpos($this->currentUser, 'guest') !== 0) { $options['auth'] = [$this->currentUser, '123456']; } if ($body instanceof TableNode) { $fd = $body->getRowsHash(); $options['form_params'] = $fd; - } else if (is_array($body)) { + } elseif (is_array($body)) { $options['form_params'] = $body; } diff --git a/tests/integration/features/bootstrap/SharingContext.php b/tests/integration/features/bootstrap/SharingContext.php index b15223b5e..5d20b46f3 100644 --- a/tests/integration/features/bootstrap/SharingContext.php +++ b/tests/integration/features/bootstrap/SharingContext.php @@ -493,7 +493,7 @@ class SharingContext implements Context { public function transferingOwnershipFromTo(string $user1, string $user2) { $args = ['files:transfer-ownership', $user1, $user2]; - $args = array_map(function($arg) { + $args = array_map(function ($arg) { return escapeshellarg($arg); }, $args); $args[] = '--no-ansi'; @@ -576,7 +576,7 @@ class SharingContext implements Context { $returnedShare = (array) $returnedShare; $returnedShare = $returnedShare['element']; if (is_array($returnedShare)) { - usort($returnedShare, static function($share1, $share2) { + usort($returnedShare, static function ($share1, $share2) { return (int) $share1->id - (int) $share2->id; }); } @@ -712,7 +712,7 @@ class SharingContext implements Context { public function theResponseContainsAShareTypesFilesPropertyForWith(string $path, TableNode $table = null) { $response = json_decode($this->response->getBody()); - $fileForPath = array_filter($response->files, function($file) use ($path) { + $fileForPath = array_filter($response->files, function ($file) use ($path) { $filePath = $file->path . (substr($file->path, -1) === '/'? '': '/'); return ($filePath . $file->name) === $path; }); @@ -759,7 +759,7 @@ class SharingContext implements Context { if ($body instanceof TableNode) { foreach ($body->getRowsHash() as $key => $value) { - if ($key === 'expireDate' && $value !== 'invalid date'){ + if ($key === 'expireDate' && $value !== 'invalid date') { $value = date('Y-m-d', strtotime($value)); } $parameters[] = $key . '=' . $value; @@ -792,7 +792,7 @@ class SharingContext implements Context { ]; if ($body instanceof TableNode) { $fd = $body->getRowsHash(); - if (array_key_exists('expireDate', $fd)){ + if (array_key_exists('expireDate', $fd)) { $fd['expireDate'] = date('Y-m-d', strtotime($fd['expireDate'])); } $options['form_params'] = $fd; @@ -934,7 +934,7 @@ class SharingContext implements Context { * @param string $contentExpected * @param \SimpleXMLElement $returnedShare */ - private function assertFieldIsInReturnedShare(string $field, string $contentExpected, \SimpleXMLElement $returnedShare){ + private function assertFieldIsInReturnedShare(string $field, string $contentExpected, \SimpleXMLElement $returnedShare) { if ($contentExpected === 'IGNORE') { return; } @@ -943,17 +943,17 @@ class SharingContext implements Context { \PHPUnit\Framework\Assert::fail("$field was not found in response"); } - if ($field === 'expiration' && !empty($contentExpected)){ + if ($field === 'expiration' && !empty($contentExpected)) { $contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00"; } if ($contentExpected === 'A_NUMBER') { \PHPUnit\Framework\Assert::assertTrue(is_numeric((string)$returnedShare->$field), "Field '$field' is not a number: " . $returnedShare->$field); - } else if ($contentExpected === 'A_TOKEN') { + } elseif ($contentExpected === 'A_TOKEN') { // A token is composed by 15 characters from // ISecureRandom::CHAR_HUMAN_READABLE. \PHPUnit\Framework\Assert::assertRegExp('/^[abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789]{15}$/', (string)$returnedShare->$field, "Field '$field' is not a token"); - } else if (strpos($contentExpected, 'REGEXP ') === 0) { + } elseif (strpos($contentExpected, 'REGEXP ') === 0) { \PHPUnit\Framework\Assert::assertRegExp(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare->$field, "Field '$field' does not match"); } else { \PHPUnit\Framework\Assert::assertEquals($contentExpected, (string)$returnedShare->$field, "Field '$field' does not match"); @@ -1006,5 +1006,4 @@ class SharingContext implements Context { } return $sharees; } - } diff --git a/tests/integration/spreedcheats/lib/Controller/ApiController.php b/tests/integration/spreedcheats/lib/Controller/ApiController.php index b5537d59a..8a14f21e7 100644 --- a/tests/integration/spreedcheats/lib/Controller/ApiController.php +++ b/tests/integration/spreedcheats/lib/Controller/ApiController.php @@ -50,7 +50,6 @@ class ApiController extends OCSController { * @return DataResponse */ public function resetSpreed() { - $query = $this->db->getQueryBuilder(); $query->delete('talk_signaling')->execute(); diff --git a/tests/php/Activity/Provider/BaseTest.php b/tests/php/Activity/Provider/BaseTest.php index 9ed72bc2e..f38e8058a 100644 --- a/tests/php/Activity/Provider/BaseTest.php +++ b/tests/php/Activity/Provider/BaseTest.php @@ -21,14 +21,12 @@ namespace OCA\Talk\Tests\php\Activity\Provider; - use OCA\Talk\Activity\Provider\Base; use OCA\Talk\Config; use OCA\Talk\Manager; use OCA\Talk\Room; use OCP\Activity\IEvent; use OCP\Activity\IManager; -use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; diff --git a/tests/php/Activity/Provider/InvitationTest.php b/tests/php/Activity/Provider/InvitationTest.php index a06cd30d5..9f382c51f 100644 --- a/tests/php/Activity/Provider/InvitationTest.php +++ b/tests/php/Activity/Provider/InvitationTest.php @@ -21,7 +21,6 @@ namespace OCA\Talk\Tests\php\Activity\Provider; - use OCA\Talk\Activity\Provider\Invitation; use OCA\Talk\Config; use OCA\Talk\Exceptions\RoomNotFoundException; @@ -146,7 +145,7 @@ class InvitationTest extends TestCase { $l = $this->createMock(IL10N::class); $l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); @@ -221,5 +220,4 @@ class InvitationTest extends TestCase { $provider->parse($lang, $event); } - } diff --git a/tests/php/Activity/SettingTest.php b/tests/php/Activity/SettingTest.php index 5ec1356c9..730e0c5b3 100644 --- a/tests/php/Activity/SettingTest.php +++ b/tests/php/Activity/SettingTest.php @@ -26,7 +26,6 @@ use OCP\Activity\ISetting; use Test\TestCase; class SettingTest extends TestCase { - public function dataSettings() { return [ [Setting::class], diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index eea12ab44..4a47cc075 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com> diff --git a/tests/php/Chat/AutoComplete/SearchPluginTest.php b/tests/php/Chat/AutoComplete/SearchPluginTest.php index d1b753af5..67e094f2f 100644 --- a/tests/php/Chat/AutoComplete/SearchPluginTest.php +++ b/tests/php/Chat/AutoComplete/SearchPluginTest.php @@ -61,7 +61,7 @@ class SearchPluginTest extends \Test\TestCase { $this->l = $this->createMock(IL10N::class); $this->l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); } @@ -129,16 +129,16 @@ class SearchPluginTest extends \Test\TestCase { $plugin->expects($this->once()) ->method('searchUsers') ->with('fo', ['123', 'foo', 'bar'], $result) - ->willReturnCallback(function($search, $users, $result) { - array_map(function($user) { + ->willReturnCallback(function ($search, $users, $result) { + array_map(function ($user) { $this->assertIsString($user); }, $users); }); $plugin->expects($this->once()) ->method('searchGuests') ->with('fo', $this->anything(), $result) - ->willReturnCallback(function($search, $guests, $result) { - array_map(function($guest) { + ->willReturnCallback(function ($search, $guests, $result) { + array_map(function ($guest) { $this->assertIsString($guest); $this->assertSame(40, strlen($guest)); }, $guests); @@ -175,7 +175,7 @@ class SearchPluginTest extends \Test\TestCase { public function testSearchUsers($search, array $userIds, array $userNames, array $expected, array $expectedExact) { $result = $this->createMock(ISearchResult::class); - $userMap = array_map(function($userData) { + $userMap = array_map(function ($userData) { return [$userData['uid'], $this->createUserMock($userData)]; }, $userNames); @@ -190,7 +190,7 @@ class SearchPluginTest extends \Test\TestCase { $plugin = $this->getPlugin(['createResult']); $plugin->expects($this->any()) ->method('createResult') - ->willReturnCallback(function($type, $uid, $name) { + ->willReturnCallback(function ($type, $uid, $name) { return [$uid => $name]; }); @@ -229,7 +229,7 @@ class SearchPluginTest extends \Test\TestCase { $plugin = $this->getPlugin(['createGuestResult']); $plugin->expects($this->any()) ->method('createGuestResult') - ->willReturnCallback(function($hash, $name) { + ->willReturnCallback(function ($hash, $name) { return [$hash => $name]; }); diff --git a/tests/php/Chat/AutoComplete/SorterTest.php b/tests/php/Chat/AutoComplete/SorterTest.php index 84abcb6dd..2fffedd90 100644 --- a/tests/php/Chat/AutoComplete/SorterTest.php +++ b/tests/php/Chat/AutoComplete/SorterTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> diff --git a/tests/php/Chat/ChatManagerTest.php b/tests/php/Chat/ChatManagerTest.php index e531a1c2e..f6d220fbc 100644 --- a/tests/php/Chat/ChatManagerTest.php +++ b/tests/php/Chat/ChatManagerTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -315,7 +316,6 @@ class ChatManagerTest extends TestCase { } public function testDeleteMessages() { - $chat = $this->createMock(Room::class); $chat->expects($this->any()) ->method('getId') @@ -331,5 +331,4 @@ class ChatManagerTest extends TestCase { $this->chatManager->deleteMessages($chat); } - } diff --git a/tests/php/Chat/Command/ExecutorTest.php b/tests/php/Chat/Command/ExecutorTest.php index f797e61a4..e4ce4ea37 100644 --- a/tests/php/Chat/Command/ExecutorTest.php +++ b/tests/php/Chat/Command/ExecutorTest.php @@ -34,7 +34,6 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\GenericEvent; use Test\TestCase; class ExecutorTest extends TestCase { @@ -174,6 +173,5 @@ class ExecutorTest extends TestCase { ->willReturn($output); $this->assertSame($output, $this->executor->execShell($room, $message, $command, $arguments)); - } } diff --git a/tests/php/Chat/Command/ShellExecutorTest.php b/tests/php/Chat/Command/ShellExecutorTest.php index 41a258b84..7286c5a24 100644 --- a/tests/php/Chat/Command/ShellExecutorTest.php +++ b/tests/php/Chat/Command/ShellExecutorTest.php @@ -27,7 +27,6 @@ use OCA\Talk\Chat\Command\ShellExecutor; use Test\TestCase; class ShellExecutorTest extends TestCase { - public function dataExecShellRun(): array { return [ ['admin', 'token', 'echo {ARGUMENTS}', '$PATH', '$PATH'], @@ -71,7 +70,6 @@ class ShellExecutorTest extends TestCase { public function testExecShellRun(?string $actorId, string $roomToken, string $cmd, string $arguments, string $output): void { $executor = new ShellExecutor(); $this->assertSame($output, $executor->execShell($cmd, $arguments, $roomToken, $actorId)); - } public function dataExecShell(): array { diff --git a/tests/php/Chat/NotifierTest.php b/tests/php/Chat/NotifierTest.php index d382e0951..8c5827e4a 100644 --- a/tests/php/Chat/NotifierTest.php +++ b/tests/php/Chat/NotifierTest.php @@ -61,7 +61,7 @@ class NotifierTest extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->userManager ->method('userExists') - ->willReturnCallback(function($userId) { + ->willReturnCallback(function ($userId) { return $userId !== 'unknownUser'; }); @@ -84,7 +84,7 @@ class NotifierTest extends TestCase { $mentionMatches = []; preg_match_all('/@([a-zA-Z0-9]+)/', $message, $mentionMatches); - $mentions = array_map(function($mentionMatch) { + $mentions = array_map(function ($mentionMatch) { return [ 'type' => 'user', 'id' => $mentionMatch ]; }, $mentionMatches[1]); @@ -551,5 +551,4 @@ class NotifierTest extends TestCase { $this->notifier->removePendingNotificationsForRoom($room); } - } diff --git a/tests/php/Chat/Parser/SystemMessageTest.php b/tests/php/Chat/Parser/SystemMessageTest.php index 4c895c901..955cfaf3c 100644 --- a/tests/php/Chat/Parser/SystemMessageTest.php +++ b/tests/php/Chat/Parser/SystemMessageTest.php @@ -76,12 +76,12 @@ class SystemMessageTest extends TestCase { $this->l = $this->createMock(IL10N::class); $this->l->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { + ->will($this->returnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); })); $this->l->expects($this->any()) ->method('n') - ->will($this->returnCallback(function($singular, $plural, $count, $parameters = []) { + ->will($this->returnCallback(function ($singular, $plural, $count, $parameters = []) { $text = $count === 1 ? $singular : $plural; return vsprintf(str_replace('%n', $count, $text), $parameters); })); @@ -656,7 +656,6 @@ class SystemMessageTest extends TestCase { } public function testGetFileFromShareThrows() { - $this->shareProvider->expects($this->once()) ->method('getShareById') ->with('23') @@ -928,7 +927,7 @@ class SystemMessageTest extends TestCase { $parser->expects($this->any()) ->method('getUser') - ->willReturnCallback(function($user) { + ->willReturnCallback(function ($user) { return ['data' => $user]; }); diff --git a/tests/php/Chat/Parser/UserMentionTest.php b/tests/php/Chat/Parser/UserMentionTest.php index 2e9f7a8a3..a25c13641 100644 --- a/tests/php/Chat/Parser/UserMentionTest.php +++ b/tests/php/Chat/Parser/UserMentionTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @@ -377,7 +378,7 @@ class UserMentionTest extends \Test\TestCase { ->willThrowException(new ParticipantNotFoundException()); $this->l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); @@ -417,7 +418,7 @@ class UserMentionTest extends \Test\TestCase { ->willThrowException(new ParticipantNotFoundException()); $this->l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); @@ -457,7 +458,7 @@ class UserMentionTest extends \Test\TestCase { ->willReturn('Name'); $this->l->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); @@ -477,5 +478,4 @@ class UserMentionTest extends \Test\TestCase { $this->assertEquals('Mention to {mention-guest1}, and again {mention-guest1}', $chatMessage->getMessage()); $this->assertEquals($expectedMessageParameters, $chatMessage->getMessageParameters()); } - } diff --git a/tests/php/Collaboration/Collaborators/RoomPluginTest.php b/tests/php/Collaboration/Collaborators/RoomPluginTest.php index 4598fd1d5..424fbefcb 100644 --- a/tests/php/Collaboration/Collaborators/RoomPluginTest.php +++ b/tests/php/Collaboration/Collaborators/RoomPluginTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -241,7 +242,7 @@ class RoomPluginTest extends \Test\TestCase { ->method('addResultSet') ->with( $this->callback( - function(SearchResultType $searchResultType) { + function (SearchResultType $searchResultType) { return $searchResultType->getLabel() === 'rooms'; } ), @@ -253,5 +254,4 @@ class RoomPluginTest extends \Test\TestCase { $this->assertSame($expectedHasMoreResults, $hasMoreResults); } - } diff --git a/tests/php/Collaboration/Resources/ConversationProviderTest.php b/tests/php/Collaboration/Resources/ConversationProviderTest.php index a8c7c4211..c76c5a752 100644 --- a/tests/php/Collaboration/Resources/ConversationProviderTest.php +++ b/tests/php/Collaboration/Resources/ConversationProviderTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,14 +23,12 @@ declare(strict_types=1); namespace OCA\Talk\Tests\php\Collaboration\Resources; -use OCA\Talk\Collaboration\Collaborators\RoomPlugin; use OCA\Talk\Collaboration\Resources\ConversationProvider; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Manager; use OCA\Talk\Participant; use OCA\Talk\Room; -use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Resources\IResource; use OCP\Collaboration\Resources\ResourceException; use OCP\IURLGenerator; diff --git a/tests/php/Command/Signaling/AddTest.php b/tests/php/Command/Signaling/AddTest.php index c1abd4d24..d3038d24c 100644 --- a/tests/php/Command/Signaling/AddTest.php +++ b/tests/php/Command/Signaling/AddTest.php @@ -55,10 +55,10 @@ class AddTest extends TestCase { public function testServerEmptyString() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return ''; - } else if ($arg === 'secret') { + } elseif ($arg === 'secret') { return 'my-test-secret'; } throw new \Exception(); @@ -77,10 +77,10 @@ class AddTest extends TestCase { public function testSecretEmptyString() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'wss://signaling.test.com'; - } else if ($arg === 'secret') { + } elseif ($arg === 'secret') { return ''; } throw new \Exception(); @@ -99,10 +99,10 @@ class AddTest extends TestCase { public function testAddServerToEmptyList() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'wss://signaling.test.com'; - } else if ($arg === 'secret') { + } elseif ($arg === 'secret') { return 'my-test-secret'; } throw new \Exception(); @@ -138,10 +138,10 @@ class AddTest extends TestCase { public function testAddServerToNonEmptyList() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'wss://signaling2.test.com'; - } else if ($arg === 'secret') { + } elseif ($arg === 'secret') { return 'my-test-secret'; } throw new \Exception(); diff --git a/tests/php/Command/Turn/AddTest.php b/tests/php/Command/Turn/AddTest.php index 211a2fccc..3401add75 100644 --- a/tests/php/Command/Turn/AddTest.php +++ b/tests/php/Command/Turn/AddTest.php @@ -55,19 +55,19 @@ class AddTest extends TestCase { public function testServerEmptyString() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return ''; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -83,19 +83,19 @@ class AddTest extends TestCase { public function testSecretEmpty() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return ''; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -111,19 +111,19 @@ class AddTest extends TestCase { public function testGenerateSecret() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return null; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return true; } throw new \Exception(); @@ -161,19 +161,19 @@ class AddTest extends TestCase { public function testSecretAndGenerateSecretOptions() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return true; } throw new \Exception(); @@ -189,19 +189,19 @@ class AddTest extends TestCase { public function testInvalidProtocolsString() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'invalid-protocol'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -217,19 +217,19 @@ class AddTest extends TestCase { public function testAddServerToEmptyList() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -259,19 +259,19 @@ class AddTest extends TestCase { public function testAddServerToNonEmptyList() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn2.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret-2'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); @@ -312,19 +312,19 @@ class AddTest extends TestCase { public function testServerSanitization() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'https://turn.test.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); }); $this->input->method('getOption') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'secret') { return 'my-test-secret'; - } else if ($arg === 'generate-secret') { + } elseif ($arg === 'generate-secret') { return false; } throw new \Exception(); diff --git a/tests/php/Command/Turn/DeleteTest.php b/tests/php/Command/Turn/DeleteTest.php index ca795ff49..3617e3341 100644 --- a/tests/php/Command/Turn/DeleteTest.php +++ b/tests/php/Command/Turn/DeleteTest.php @@ -55,10 +55,10 @@ class DeleteTest extends TestCase { public function testDeleteIfEmpty() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn.example.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); @@ -83,10 +83,10 @@ class DeleteTest extends TestCase { public function testDelete() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn2.example.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); @@ -123,10 +123,10 @@ class DeleteTest extends TestCase { public function testNothingToDelete() { $this->input->method('getArgument') - ->willReturnCallback(function($arg) { + ->willReturnCallback(function ($arg) { if ($arg === 'server') { return 'turn4.example.com'; - } else if ($arg === 'protocols') { + } elseif ($arg === 'protocols') { return 'udp,tcp'; } throw new \Exception(); diff --git a/tests/php/ConfigTest.php b/tests/php/ConfigTest.php index c79be1e29..bda84ac5f 100644 --- a/tests/php/ConfigTest.php +++ b/tests/php/ConfigTest.php @@ -29,7 +29,6 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class ConfigTest extends TestCase { - public function testGetStunServer() { $servers = [ 'stun1.example.com:443', @@ -244,5 +243,4 @@ class ConfigTest extends TestCase { self::invokePrivate($helper, 'getWebSocketDomainForSignalingServer', [$url]) ); } - } diff --git a/tests/php/Controller/ChatControllerTest.php b/tests/php/Controller/ChatControllerTest.php index 6833125cc..6da163417 100644 --- a/tests/php/Controller/ChatControllerTest.php +++ b/tests/php/Controller/ChatControllerTest.php @@ -27,10 +27,7 @@ use OCA\Talk\Chat\AutoComplete\SearchPlugin; use OCA\Talk\Chat\ChatManager; use OCA\Talk\Chat\MessageParser; use OCA\Talk\Controller\ChatController; -use OCA\Talk\Exceptions\ParticipantNotFoundException; -use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\GuestManager; -use OCA\Talk\Manager; use OCA\Talk\Model\Message; use OCA\Talk\Participant; use OCA\Talk\Room; @@ -104,7 +101,7 @@ class ChatControllerTest extends TestCase { // Verifies that the difference of the given DateTime and now is at most // five seconds, and that it uses the UTC time zone. - $this->newMessageDateTimeConstraint = $this->callback(function(\DateTime $dateTime) { + $this->newMessageDateTimeConstraint = $this->callback(function (\DateTime $dateTime) { return abs((new \DateTime())->getTimestamp() - $dateTime->getTimestamp()) <= 5 && (new \DateTimeZone('UTC'))->getName() === $dateTime->getTimezone()->getName(); }); @@ -610,7 +607,7 @@ class ChatControllerTest extends TestCase { [$this->room, $participant, $comment2, $this->l], [$this->room, $participant, $comment1, $this->l] ) - ->willReturnCallback(function($room, $participant, IComment $comment, $l) use (&$i) { + ->willReturnCallback(function ($room, $participant, IComment $comment, $l) use (&$i) { $chatMessage = $this->createMock(Message::class); $chatMessage->expects($this->once()) ->method('getVisibility') @@ -676,7 +673,7 @@ class ChatControllerTest extends TestCase { [$this->room, $participant, $comment2, $this->l], [$this->room, $participant, $comment1, $this->l] ) - ->willReturnCallback(function($room, $participant, IComment $comment, $l) use (&$i) { + ->willReturnCallback(function ($room, $participant, IComment $comment, $l) use (&$i) { $chatMessage = $this->createMock(Message::class); $chatMessage->expects($this->once()) ->method('getVisibility') @@ -745,7 +742,7 @@ class ChatControllerTest extends TestCase { [$this->room, $participant, $comment2, $this->l], [$this->room, $participant, $comment1, $this->l] ) - ->willReturnCallback(function($room, $participant, IComment $comment, $l) use (&$i) { + ->willReturnCallback(function ($room, $participant, IComment $comment, $l) use (&$i) { $chatMessage = $this->createMock(Message::class); $chatMessage->expects($this->once()) ->method('getVisibility') @@ -822,7 +819,7 @@ class ChatControllerTest extends TestCase { [$this->room, $participant, $comment3, $this->l], [$this->room, $participant, $comment4, $this->l] ) - ->willReturnCallback(function($room, $participant, IComment $comment, $l) use (&$i) { + ->willReturnCallback(function ($room, $participant, IComment $comment, $l) use (&$i) { $chatMessage = $this->createMock(Message::class); $chatMessage->expects($this->once()) ->method('getVisibility') @@ -935,7 +932,7 @@ class ChatControllerTest extends TestCase { ]], [ ['id' => 'foo', 'label' => 'Foo Bar', 'source' => 'users'], ['id' => 'foobar', 'label' => 'FooBar', 'source' => 'users'], - ]], + ]], ]; } diff --git a/tests/php/Controller/SignalingControllerTest.php b/tests/php/Controller/SignalingControllerTest.php index 7e72e27c7..83a9bb0ec 100644 --- a/tests/php/Controller/SignalingControllerTest.php +++ b/tests/php/Controller/SignalingControllerTest.php @@ -44,10 +44,8 @@ use OCP\IUserManager; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\GenericEvent; class CustomInputSignalingController extends SignalingController { - private $inputStream; public function setInputStream($data) { @@ -57,7 +55,6 @@ class CustomInputSignalingController extends SignalingController { protected function getInputStream(): string { return $this->inputStream; } - } /** @@ -658,7 +655,7 @@ class SignalingControllerTest extends \Test\TestCase { } public function testBackendRoomSessionFromEvent() { - $this->dispatcher->addListener(SignalingController::EVENT_BACKEND_SIGNALING_ROOMS, static function(SignalingEvent $event) { + $this->dispatcher->addListener(SignalingController::EVENT_BACKEND_SIGNALING_ROOMS, static function (SignalingEvent $event) { $room = $event->getRoom(); $event->setSession([ 'foo' => 'bar', @@ -939,5 +936,4 @@ class SignalingControllerTest extends \Test\TestCase { $participant = $room->getParticipant($this->userId); $this->assertEquals($newSessionId, $participant->getSessionId()); } - } diff --git a/tests/php/Files/UtilTest.php b/tests/php/Files/UtilTest.php index 9e332144b..4b6eb2dac 100644 --- a/tests/php/Files/UtilTest.php +++ b/tests/php/Files/UtilTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -35,7 +36,6 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class UtilTest extends TestCase { - public function createNodeMock(string $type, bool $instanceOfGroupFolderStorage = false) { $node = $this->createMock(Node::class); $node->expects($this->once()) @@ -68,7 +68,7 @@ class UtilTest extends TestCase { ['28', 'admin6', [ $this->createNodeMock(FileInfo::TYPE_FOLDER), $this->createNodeMock(FileInfo::TYPE_FILE, true) - ], 1], + ], 1], ]; } @@ -81,7 +81,6 @@ class UtilTest extends TestCase { * @param bool|int $hasReturn */ public function testGetGroupFolderNode(string $fileId, string $userId, array $nodes, $return): void { - $userFolder = $this->createMock(Folder::class); $userFolder->expects($this->once()) ->method('getById') diff --git a/tests/php/Notification/NotifierTest.php b/tests/php/Notification/NotifierTest.php index 89eb5a114..9c74fd66c 100644 --- a/tests/php/Notification/NotifierTest.php +++ b/tests/php/Notification/NotifierTest.php @@ -121,7 +121,7 @@ class NotifierTest extends \Test\TestCase { $l = $this->createMock(IL10N::class); $l->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { + ->will($this->returnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); })); @@ -231,7 +231,7 @@ class NotifierTest extends \Test\TestCase { $l = $this->createMock(IL10N::class); $l->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { + ->will($this->returnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); })); @@ -589,7 +589,7 @@ class NotifierTest extends \Test\TestCase { $l = $this->createMock(IL10N::class); $l->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { + ->will($this->returnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); })); @@ -641,7 +641,7 @@ class NotifierTest extends \Test\TestCase { ->method('get') ->with($subjectParameters['userId']) ->willReturn($user); - } else if ($subjectParameters['userType'] === 'users' && $deletedUser) { + } elseif ($subjectParameters['userType'] === 'users' && $deletedUser) { $user->expects($this->never()) ->method('getDisplayName'); $this->userManager->expects($this->at(1)) @@ -774,7 +774,7 @@ class NotifierTest extends \Test\TestCase { if ($validRoom === null) { $this->manager->expects($this->never()) ->method('getRoomByToken'); - } else if ($validRoom === true) { + } elseif ($validRoom === true) { $room = $this->createMock(Room::class); $room->expects($this->never()) ->method('getType'); @@ -785,7 +785,7 @@ class NotifierTest extends \Test\TestCase { ->method('getRoomByToken') ->with('roomToken') ->willReturn($room); - } else if ($validRoom === false) { + } elseif ($validRoom === false) { $n->expects($this->exactly(2)) ->method('getObjectId') ->willReturn('roomToken'); diff --git a/tests/php/RoomTest.php b/tests/php/RoomTest.php index e240c0db2..e3a3a3846 100644 --- a/tests/php/RoomTest.php +++ b/tests/php/RoomTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Peter Edens <petere@conceiva.com> @@ -34,21 +35,19 @@ use OCP\Security\ISecureRandom; use Test\TestCase; class RoomTest extends TestCase { - public function testVerifyPassword() { $dispatcher = new EventDispatcher( new \Symfony\Component\EventDispatcher\EventDispatcher(), \OC::$server, $this->createMock(ILogger::class) ); - $dispatcher->addListener(Room::EVENT_PASSWORD_VERIFY, static function(VerifyRoomPasswordEvent $event) { + $dispatcher->addListener(Room::EVENT_PASSWORD_VERIFY, static function (VerifyRoomPasswordEvent $event) { $password = $event->getPassword(); if ($password === '1234') { $event->setIsPasswordValid(true); $event->setRedirectUrl(''); - } - else { + } else { $event->setIsPasswordValid(false); $event->setRedirectUrl('https://test'); } diff --git a/tests/php/Settings/Admin/AdminSettingsTest.php b/tests/php/Settings/Admin/AdminSettingsTest.php index c3594d182..f9122461e 100644 --- a/tests/php/Settings/Admin/AdminSettingsTest.php +++ b/tests/php/Settings/Admin/AdminSettingsTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/tests/php/Settings/Admin/SectionTest.php b/tests/php/Settings/Admin/SectionTest.php index cb664ddd1..a156cdcea 100644 --- a/tests/php/Settings/Admin/SectionTest.php +++ b/tests/php/Settings/Admin/SectionTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> diff --git a/tests/php/Signaling/BackendNotifierTest.php b/tests/php/Signaling/BackendNotifierTest.php index fda09243b..fcd990292 100644 --- a/tests/php/Signaling/BackendNotifierTest.php +++ b/tests/php/Signaling/BackendNotifierTest.php @@ -43,10 +43,8 @@ use OCP\IUserManager; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\GenericEvent; class CustomBackendNotifier extends BackendNotifier { - private $requests = []; public function getRequests(): array { @@ -63,7 +61,6 @@ class CustomBackendNotifier extends BackendNotifier { 'params' => $params, ]; } - } /** @@ -131,7 +128,7 @@ class BackendNotifierTest extends \Test\TestCase { $this->app->register(); $this->originalBackendNotifier = $this->app->getContainer()->query(BackendNotifier::class); - $this->app->getContainer()->registerService(BackendNotifier::class, function() { + $this->app->getContainer()->registerService(BackendNotifier::class, function () { return $this->controller; }); @@ -154,7 +151,7 @@ class BackendNotifierTest extends \Test\TestCase { public function tearDown(): void { $config = \OC::$server->getConfig(); $config->deleteAppValue('spreed', 'signaling_servers'); - $this->app->getContainer()->registerService(BackendNotifier::class, function() { + $this->app->getContainer()->registerService(BackendNotifier::class, function () { return $this->originalBackendNotifier; }); parent::tearDown(); @@ -196,7 +193,7 @@ class BackendNotifierTest extends \Test\TestCase { ]); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); @@ -235,7 +232,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->removeUser($testUser, Room::PARTICIPANT_REMOVED); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -263,7 +260,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setName('Test room'); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -288,7 +285,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setPassword('password'); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -313,7 +310,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setType(Room::GROUP_CALL); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -338,7 +335,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setReadOnly(Room::READ_ONLY); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -363,7 +360,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setLobby(Webinary::LOBBY_NON_MODERATORS, null); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -391,7 +388,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->deleteRoom(); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -415,7 +412,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->changeInCall($participant, Participant::FLAG_IN_CALL | Participant::FLAG_WITH_AUDIO | Participant::FLAG_WITH_VIDEO); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -449,7 +446,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->changeInCall($guestParticipant, Participant::FLAG_IN_CALL); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -486,7 +483,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->changeInCall($participant, Participant::FLAG_DISCONNECTED); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -515,7 +512,7 @@ class BackendNotifierTest extends \Test\TestCase { } public function testRoomPropertiesEvent(): void { - $listener = static function(SignalingRoomPropertiesEvent $event) { + $listener = static function (SignalingRoomPropertiesEvent $event) { $room = $event->getRoom(); $event->setProperty('foo', 'bar'); $event->setProperty('room', $room->getToken()); @@ -528,7 +525,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setName('Test room'); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); @@ -562,7 +559,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($participant, Participant::MODERATOR); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -596,7 +593,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($guestParticipant, Participant::GUEST_MODERATOR); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -638,7 +635,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($notJoinedParticipant, Participant::MODERATOR); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -675,7 +672,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($participant, Participant::USER); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -720,7 +717,7 @@ class BackendNotifierTest extends \Test\TestCase { $room->setParticipantType($guestParticipant, Participant::GUEST); $requests = $this->controller->getRequests(); - $bodies = array_map(function($request) use ($room) { + $bodies = array_map(function ($request) use ($room) { return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); }, $requests); $this->assertContains([ @@ -760,5 +757,4 @@ class BackendNotifierTest extends \Test\TestCase { ], ], $bodies); } - } diff --git a/tests/php/TalkSessionTest.php b/tests/php/TalkSessionTest.php index 38ed812e6..5f183760e 100644 --- a/tests/php/TalkSessionTest.php +++ b/tests/php/TalkSessionTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com> diff --git a/tests/php/bootstrap.php b/tests/php/bootstrap.php index 424fc6606..71e40d9c8 100644 --- a/tests/php/bootstrap.php +++ b/tests/php/bootstrap.php @@ -25,7 +25,7 @@ if (!defined('PHPUNIT_RUN')) { require_once __DIR__.'/../../../../lib/base.php'; \OC::$loader->addValidRoot(\OC::$SERVERROOT . '/tests'); \OC_App::loadApp('spreed'); -if(!class_exists('\PHPUnit\Framework\TestCase')) { +if (!class_exists('\PHPUnit\Framework\TestCase')) { require_once('PHPUnit/Autoload.php'); } OC_Hook::clear(); |