diff options
-rw-r--r-- | apps/files_external/lib/Command/Applicable.php | 19 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Backends.php | 5 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Config.php | 7 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Create.php | 33 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Delete.php | 25 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Export.php | 2 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Import.php | 37 | ||||
-rw-r--r-- | apps/files_external/lib/Command/ListCommand.php | 31 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Notify.php | 23 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Option.php | 2 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Verify.php | 7 |
11 files changed, 52 insertions, 139 deletions
diff --git a/apps/files_external/lib/Command/Applicable.php b/apps/files_external/lib/Command/Applicable.php index 29d5459200e..a3708602dff 100644 --- a/apps/files_external/lib/Command/Applicable.php +++ b/apps/files_external/lib/Command/Applicable.php @@ -36,20 +36,9 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Applicable extends Base { - /** - * @var GlobalStoragesService - */ - protected $globalService; - - /** - * @var IUserManager - */ - private $userManager; - - /** - * @var IGroupManager - */ - private $groupManager; + protected GlobalStoragesService $globalService; + private IUserManager $userManager; + private IGroupManager $groupManager; public function __construct( GlobalStoragesService $globalService, @@ -62,7 +51,7 @@ class Applicable extends Base { $this->groupManager = $groupManager; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:applicable') ->setDescription('Manage applicable users and groups for a mount') diff --git a/apps/files_external/lib/Command/Backends.php b/apps/files_external/lib/Command/Backends.php index 60d035f997f..faf6209bd74 100644 --- a/apps/files_external/lib/Command/Backends.php +++ b/apps/files_external/lib/Command/Backends.php @@ -33,8 +33,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Backends extends Base { - /** @var BackendService */ - private $backendService; + private BackendService $backendService; public function __construct(BackendService $backendService ) { @@ -43,7 +42,7 @@ class Backends extends Base { $this->backendService = $backendService; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:backends') ->setDescription('Show available authentication and storage backends') diff --git a/apps/files_external/lib/Command/Config.php b/apps/files_external/lib/Command/Config.php index 5d0675b04bc..1107bfb4d42 100644 --- a/apps/files_external/lib/Command/Config.php +++ b/apps/files_external/lib/Command/Config.php @@ -33,17 +33,14 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Config extends Base { - /** - * @var GlobalStoragesService - */ - protected $globalService; + protected GlobalStoragesService $globalService; public function __construct(GlobalStoragesService $globalService) { parent::__construct(); $this->globalService = $globalService; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:config') ->setDescription('Manage backend configuration for a mount') diff --git a/apps/files_external/lib/Command/Create.php b/apps/files_external/lib/Command/Create.php index 99991b893cd..372fa4ef372 100644 --- a/apps/files_external/lib/Command/Create.php +++ b/apps/files_external/lib/Command/Create.php @@ -43,26 +43,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Create extends Base { - /** - * @var GlobalStoragesService - */ - private $globalService; - - /** - * @var UserStoragesService - */ - private $userService; - - /** - * @var IUserManager - */ - private $userManager; - - /** @var BackendService */ - private $backendService; - - /** @var IUserSession */ - private $userSession; + private GlobalStoragesService $globalService; + private UserStoragesService $userService; + private IUserManager $userManager; + private BackendService $backendService; + private IUserSession $userSession; public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, @@ -78,7 +63,7 @@ class Create extends Base { $this->backendService = $backendService; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:create') ->setDescription('Create a new mount configuration') @@ -187,7 +172,7 @@ class Create extends Base { return 0; } - private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend) { + private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend): bool { $params = array_merge($storageBackend->getParameters(), $authBackend->getParameters()); foreach ($params as $param) { /** @var DefinitionParameter $param */ @@ -201,7 +186,7 @@ class Create extends Base { return false; } - private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output) { + private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output): void { $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); $listInput = new ArrayInput([], $listCommand->getDefinition()); $listInput->setOption('output', $input->getOption('output')); @@ -209,7 +194,7 @@ class Create extends Base { $listCommand->listMounts($user, [$mount], $listInput, $output); } - protected function getStorageService($userId) { + protected function getStorageService(string $userId) { if (!empty($userId)) { $user = $this->userManager->get($userId); if (is_null($user)) { diff --git a/apps/files_external/lib/Command/Delete.php b/apps/files_external/lib/Command/Delete.php index a41161792b5..cf09e3907b7 100644 --- a/apps/files_external/lib/Command/Delete.php +++ b/apps/files_external/lib/Command/Delete.php @@ -37,25 +37,10 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; class Delete extends Base { - /** - * @var GlobalStoragesService - */ - protected $globalService; - - /** - * @var UserStoragesService - */ - protected $userService; - - /** - * @var IUserSession - */ - protected $userSession; - - /** - * @var IUserManager - */ - protected $userManager; + protected GlobalStoragesService $globalService; + protected UserStoragesService $userService; + protected IUserSession $userSession; + protected IUserManager $userManager; public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { parent::__construct(); @@ -65,7 +50,7 @@ class Delete extends Base { $this->userManager = $userManager; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:delete') ->setDescription('Delete an external mount') diff --git a/apps/files_external/lib/Command/Export.php b/apps/files_external/lib/Command/Export.php index 622c4b46078..98cfb683060 100644 --- a/apps/files_external/lib/Command/Export.php +++ b/apps/files_external/lib/Command/Export.php @@ -29,7 +29,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Export extends ListCommand { - protected function configure() { + protected function configure(): void { $this ->setName('files_external:export') ->setDescription('Export mount configurations') diff --git a/apps/files_external/lib/Command/Import.php b/apps/files_external/lib/Command/Import.php index 53ae0d7c5bf..eab7dd9a6be 100644 --- a/apps/files_external/lib/Command/Import.php +++ b/apps/files_external/lib/Command/Import.php @@ -40,31 +40,12 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Import extends Base { - /** - * @var GlobalStoragesService - */ - private $globalService; - - /** - * @var UserStoragesService - */ - private $userService; - - /** - * @var IUserSession - */ - private $userSession; - - /** - * @var IUserManager - */ - private $userManager; - - /** @var ImportLegacyStoragesService */ - private $importLegacyStorageService; - - /** @var BackendService */ - private $backendService; + private GlobalStoragesService $globalService; + private UserStoragesService $userService; + private IUserSession $userSession; + private IUserManager $userManager; + private ImportLegacyStoragesService $importLegacyStorageService; + private BackendService $backendService; public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, @@ -82,7 +63,7 @@ class Import extends Base { $this->backendService = $backendService; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:import') ->setDescription('Import mount configurations') @@ -189,7 +170,7 @@ class Import extends Base { return 0; } - private function parseData(array $data) { + private function parseData(array $data): StorageConfig { $mount = new StorageConfig($data['mount_id']); $mount->setMountPoint($data['mount_point']); $mount->setBackend($this->getBackendByClass($data['storage'])); @@ -202,7 +183,7 @@ class Import extends Base { return $mount; } - private function getBackendByClass($className) { + private function getBackendByClass(string $className) { $backends = $this->backendService->getBackends(); foreach ($backends as $backend) { if ($backend->getStorageClass() === $className) { diff --git a/apps/files_external/lib/Command/ListCommand.php b/apps/files_external/lib/Command/ListCommand.php index 461991c073b..b2a4baf366b 100644 --- a/apps/files_external/lib/Command/ListCommand.php +++ b/apps/files_external/lib/Command/ListCommand.php @@ -39,25 +39,10 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ListCommand extends Base { - /** - * @var GlobalStoragesService - */ - protected $globalService; - - /** - * @var UserStoragesService - */ - protected $userService; - - /** - * @var IUserSession - */ - protected $userSession; - - /** - * @var IUserManager - */ - protected $userManager; + protected GlobalStoragesService $globalService; + protected UserStoragesService $userService; + protected IUserSession $userSession; + protected IUserManager $userManager; public const ALL = -1; @@ -69,7 +54,7 @@ class ListCommand extends Base { $this->userManager = $userManager; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:list') ->setDescription('List configured admin or personal mounts') @@ -102,7 +87,7 @@ class ListCommand extends Base { $mounts = $this->globalService->getStorageForAllUsers(); $userId = self::ALL; } else { - $userId = $input->getArgument('user_id'); + $userId = (string)$input->getArgument('user_id'); $storageService = $this->getStorageService($userId); $mounts = $storageService->getAllStorages(); } @@ -114,10 +99,8 @@ class ListCommand extends Base { /** * @param ?string|ListCommand::ALL $userId * @param StorageConfig[] $mounts - * @param InputInterface $input - * @param OutputInterface $output */ - public function listMounts($userId, array $mounts, InputInterface $input, OutputInterface $output) { + public function listMounts($userId, array $mounts, InputInterface $input, OutputInterface $output): void { $outputType = $input->getOption('output'); if (count($mounts) === 0) { if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) { diff --git a/apps/files_external/lib/Command/Notify.php b/apps/files_external/lib/Command/Notify.php index 2e3ade7df7a..bba698fb25f 100644 --- a/apps/files_external/lib/Command/Notify.php +++ b/apps/files_external/lib/Command/Notify.php @@ -39,27 +39,24 @@ use OCP\Files\Storage\INotifyStorage; use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; use OCP\IDBConnection; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Notify extends Base { - /** @var GlobalStoragesService */ - private $globalService; - /** @var IDBConnection */ - private $connection; - /** @var ILogger */ - private $logger; + private GlobalStoragesService $globalService; + private IDBConnection $connection; + private LoggerInterface $logger; /** @var IUserManager */ private $userManager; public function __construct( GlobalStoragesService $globalService, IDBConnection $connection, - ILogger $logger, + LoggerInterface $logger, IUserManager $userManager ) { parent::__construct(); @@ -69,7 +66,7 @@ class Notify extends Base { $this->userManager = $userManager; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:notify') ->setDescription('Listen for active update notifications for a configured external mount') @@ -207,7 +204,7 @@ class Notify extends Base { return 0; } - private function createStorage(StorageConfig $mount) { + private function createStorage(StorageConfig $mount): IStorage { $class = $mount->getBackend()->getStorageClass(); return new $class($mount->getBackendOptions()); } @@ -221,7 +218,7 @@ class Notify extends Base { try { $storages = $this->getStorageIds($mountId, $parent); } catch (DriverException $ex) { - $this->logger->logException($ex, ['message' => 'Error while trying to find correct storage ids.', 'level' => ILogger::WARN]); + $this->logger->warning('Error while trying to find correct storage ids.', ['exception' => $ex]); $this->connection = $this->reconnectToDatabase($this->connection, $output); $output->writeln('<info>Needed to reconnect to the database</info>'); $storages = $this->getStorageIds($mountId, $path); @@ -307,7 +304,7 @@ class Notify extends Base { try { $connection->close(); } catch (\Exception $ex) { - $this->logger->logException($ex, ['app' => 'files_external', 'message' => 'Error while disconnecting from DB', 'level' => ILogger::WARN]); + $this->logger->warning('Error while disconnecting from DB', ['exception' => $ex]); $output->writeln("<info>Error while disconnecting from database: {$ex->getMessage()}</info>"); } $connected = false; @@ -315,7 +312,7 @@ class Notify extends Base { try { $connected = $connection->connect(); } catch (\Exception $ex) { - $this->logger->logException($ex, ['app' => 'files_external', 'message' => 'Error while re-connecting to database', 'level' => ILogger::WARN]); + $this->logger->warning('Error while re-connecting to database', ['exception' => $ex]); $output->writeln("<info>Error while re-connecting to database: {$ex->getMessage()}</info>"); sleep(60); } diff --git a/apps/files_external/lib/Command/Option.php b/apps/files_external/lib/Command/Option.php index 9f7d4a30bcd..30390ebabee 100644 --- a/apps/files_external/lib/Command/Option.php +++ b/apps/files_external/lib/Command/Option.php @@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; class Option extends Config { - protected function configure() { + protected function configure(): void { $this ->setName('files_external:option') ->setDescription('Manage mount options for a mount') diff --git a/apps/files_external/lib/Command/Verify.php b/apps/files_external/lib/Command/Verify.php index 0febfa15825..f8079ec4d65 100644 --- a/apps/files_external/lib/Command/Verify.php +++ b/apps/files_external/lib/Command/Verify.php @@ -38,17 +38,14 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Verify extends Base { - /** - * @var GlobalStoragesService - */ - protected $globalService; + protected GlobalStoragesService $globalService; public function __construct(GlobalStoragesService $globalService) { parent::__construct(); $this->globalService = $globalService; } - protected function configure() { + protected function configure(): void { $this ->setName('files_external:verify') ->setDescription('Verify mount configuration') |