]> source.dussan.org Git - nextcloud-server.git/commitdiff
Additional type hinting found by psalm
authorCarl Schwan <carl@carlschwan.eu>
Tue, 18 Oct 2022 10:22:40 +0000 (12:22 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Tue, 18 Oct 2022 10:28:34 +0000 (12:28 +0200)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
apps/files_external/lib/Command/Create.php
apps/files_external/lib/Lib/Backend/Backend.php
apps/files_external/lib/Lib/LegacyDependencyCheckPolyfill.php
apps/files_external/lib/Lib/Storage/AmazonS3.php
apps/files_external/lib/Lib/StorageConfig.php
apps/files_external/lib/Service/DBConfigService.php
apps/files_external/templates/settings.php
build/psalm-baseline.xml

index 372fa4ef372677622ad8cb8aa1d21a9bf3de0d2a..17e4731a2d69578e901b9c7571cedc303c001f7f 100644 (file)
@@ -34,6 +34,7 @@ use OCA\Files_External\Lib\StorageConfig;
 use OCA\Files_External\Service\BackendService;
 use OCA\Files_External\Service\GlobalStoragesService;
 use OCA\Files_External\Service\UserStoragesService;
+use OCA\Files_External\Service\StoragesService;
 use OCP\IUserManager;
 use OCP\IUserSession;
 use Symfony\Component\Console\Input\ArrayInput;
@@ -104,7 +105,7 @@ class Create extends Base {
        }
 
        protected function execute(InputInterface $input, OutputInterface $output): int {
-               $user = (string) $input->getOption('user');
+               $user = (string)$input->getOption('user');
                $mountPoint = $input->getArgument('mount_point');
                $storageIdentifier = $input->getArgument('storage_backend');
                $authIdentifier = $input->getArgument('authentication_backend');
@@ -172,7 +173,7 @@ class Create extends Base {
                return 0;
        }
 
-       private function validateParam($key, &$value, Backend $storageBackend, AuthMechanism $authBackend): bool {
+       private function validateParam(string $key, &$value, Backend $storageBackend, AuthMechanism $authBackend): bool {
                $params = array_merge($storageBackend->getParameters(), $authBackend->getParameters());
                foreach ($params as $param) {
                        /** @var DefinitionParameter $param */
@@ -186,7 +187,7 @@ class Create extends Base {
                return false;
        }
 
-       private function showMount($user, StorageConfig $mount, InputInterface $input, OutputInterface $output): void {
+       private function showMount(string $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'));
@@ -194,7 +195,7 @@ class Create extends Base {
                $listCommand->listMounts($user, [$mount], $listInput, $output);
        }
 
-       protected function getStorageService(string $userId) {
+       protected function getStorageService(string $userId): StoragesService {
                if (!empty($userId)) {
                        $user = $this->userManager->get($userId);
                        if (is_null($user)) {
index 845f51f54327df8f91f51e210e454347e5672e5b..d0058e98b52826e46f89575470f31553c71e5c9e 100644 (file)
@@ -32,6 +32,7 @@ use OCA\Files_External\Lib\StorageModifierTrait;
 use OCA\Files_External\Lib\VisibilityTrait;
 use OCA\Files_External\Lib\IIdentifier;
 use OCA\Files_External\Lib\IFrontendDefinition;
+use OCP\Files\Storage\IStorage;
 
 /**
  * Storage backend
@@ -75,7 +76,7 @@ class Backend implements \JsonSerializable, IIdentifier, IFrontendDefinition {
        private $legacyAuthMechanism;
 
        /**
-        * @return string
+        * @return class-string<IStorage>
         */
        public function getStorageClass() {
                return $this->storageClass;
index c2562e5c64e7f79cdc2e90a00d9c9d654ce224f9..42a72e960ea904ba83938eea911bb022a92bf0e4 100644 (file)
  */
 namespace OCA\Files_External\Lib;
 
+use OCP\Files\Storage\IStorage;
+
 /**
  * Polyfill for checking dependencies using legacy Storage::checkDependencies()
  */
 trait LegacyDependencyCheckPolyfill {
 
        /**
-        * @return string
+        * @return class-string<IStorage>
         */
        abstract public function getStorageClass();
 
index 1b3d2e6936fac9268e6cca2fc5eceb80c539787c..0424f33788157cc4007b24e32fa272582a656c81 100644 (file)
@@ -91,7 +91,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
                /** @var ICacheFactory $cacheFactory */
                $cacheFactory = Server::get(ICacheFactory::class);
                $this->memCache = $cacheFactory->createLocal('s3-external');
-               $this->logger = \OCP\Server::get(LoggerInterface::class);
+               $this->logger = Server::get(LoggerInterface::class);
        }
 
        /**
index 20e5aea62d245b164fdd34debf2389978bc2e6d2..757f9d35bdbe9939010883a8b53c400d059e4623 100644 (file)
@@ -126,17 +126,17 @@ class StorageConfig implements \JsonSerializable {
        /**
         * Creates a storage config
         *
-        * @param int|null $id config id or null for a new config
+        * @param int|string $id config id or null for a new config
         */
        public function __construct($id = null) {
-               $this->id = $id;
+               $this->id = $id ?? -1;
                $this->mountOptions['enable_sharing'] = false;
        }
 
        /**
         * Returns the configuration id
         *
-        * @return int
+        * @retun int
         */
        public function getId() {
                return $this->id;
@@ -147,7 +147,7 @@ class StorageConfig implements \JsonSerializable {
         *
         * @param int $id configuration id
         */
-       public function setId($id) {
+       public function setId(int $id): void {
                $this->id = $id;
        }
 
index f6446eea363e50649f94574e9eb900ae379a493d..bc089d18fbdb45d1047e3e652b047bdf56bd0d06 100644 (file)
@@ -64,11 +64,7 @@ class DBConfigService {
                $this->crypto = $crypto;
        }
 
-       /**
-        * @param int $mountId
-        * @return array
-        */
-       public function getMountById($mountId) {
+       public function getMountById(int $mountId): ?array {
                $builder = $this->connection->getQueryBuilder();
                $query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
                        ->from('external_mounts', 'm')
index d8dd91822c5db88c965eea6e8374b922d1731f75..af7438e28d776223684bf311df289e0293692c9b 100644 (file)
@@ -1,9 +1,11 @@
 <?php
-       use \OCA\Files_External\Lib\Backend\Backend;
+use \OCA\Files_External\Lib\Backend\Backend;
 use \OCA\Files_External\Lib\Auth\AuthMechanism;
 use \OCA\Files_External\Lib\DefinitionParameter;
 use \OCA\Files_External\Service\BackendService;
 
+/** @var array $_ */
+
 $canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting'];
 
        $l->t("Enable encryption");
index 1b0dda5af7504416031479681a0148dc64056175..795f34eda670e327c8c9b4d328865bef953acb27 100644 (file)
       <code>test</code>
     </TooManyArguments>
   </file>
+  <file src="apps/files_external/lib/Service/BackendService.php">
+    <TooManyArguments occurrences="1">
+      <code>dispatch</code>
+    </TooManyArguments>
+    <InvalidArgument occurrences="1">
+      <code>dispatch</code>
+    </InvalidArgument>
+  </file>
   <file src="apps/files_sharing/lib/AppInfo/Application.php">
     <InvalidArgument occurrences="6">
       <code>addServiceListener</code>