]> source.dussan.org Git - nextcloud-server.git/commitdiff
refactor(objectstorage): cleanup types 40981/head
authorThomas Citharel <tcit@tcit.fr>
Fri, 20 Oct 2023 07:08:08 +0000 (09:08 +0200)
committerThomas Citharel <tcit@tcit.fr>
Fri, 2 Feb 2024 13:59:21 +0000 (14:59 +0100)
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php
lib/private/Files/ObjectStore/HomeObjectStoreStorage.php
lib/private/Files/ObjectStore/ObjectStoreStorage.php
tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php

index 2f6db935236af5a805ac9f94f83b575b68e9886e..2c473cb6da95b33b51225a1e7e1d71d3417cce02 100644 (file)
@@ -26,9 +26,12 @@ declare(strict_types=1);
 namespace OC\Files\ObjectStore;
 
 class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage {
-       /** @var string */
-       private $internalId;
+       private string $internalId;
 
+       /**
+        * @param array $params
+        * @throws \Exception
+        */
        public function __construct($params) {
                if (!isset($params['internal-id'])) {
                        throw new \Exception('missing id in parameters');
@@ -37,7 +40,7 @@ class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage {
                parent::__construct($params);
        }
 
-       public function getId() {
+       public function getId(): string {
                return 'object::appdata::preview:' . $this->internalId;
        }
 }
index feceb706e19df5cdb4da5c05dc95a9fdc8dddf82..443c5147742c832f3f61f9950df40357a2913a41 100644 (file)
@@ -26,6 +26,7 @@
  */
 namespace OC\Files\ObjectStore;
 
+use Exception;
 use OCP\Files\IHomeStorage;
 use OCP\IUser;
 
@@ -34,17 +35,19 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage
 
        /**
         * The home user storage requires a user object to create a unique storage id
+        *
         * @param array $params
+        * @throws Exception
         */
        public function __construct($params) {
                if (! isset($params['user']) || ! $params['user'] instanceof IUser) {
-                       throw new \Exception('missing user object in parameters');
+                       throw new Exception('missing user object in parameters');
                }
                $this->user = $params['user'];
                parent::__construct($params);
        }
 
-       public function getId() {
+       public function getId(): string {
                return 'object::user:' . $this->user->getUID();
        }
 
@@ -52,13 +55,10 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage
         * get the owner of a path
         *
         * @param string $path The path to get the owner
-        * @return false|string uid
+        * @return string uid
         */
-       public function getOwner($path) {
-               if (is_object($this->user)) {
-                       return $this->user->getUID();
-               }
-               return false;
+       public function getOwner($path): string {
+               return $this->user->getUID();
        }
 
        public function getUser(): IUser {
index 5c2881bef0f414d14d88c0265e8900d000f414f4..3e0fbd1591956363edd541d139f10a5ec748e00f 100644 (file)
@@ -47,6 +47,7 @@ use OCP\Files\ObjectStore\IObjectStore;
 use OCP\Files\ObjectStore\IObjectStoreMultiPartUpload;
 use OCP\Files\Storage\IChunkedFileWrite;
 use OCP\Files\Storage\IStorage;
+use OCP\ILogger;
 
 class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFileWrite {
        use CopyDirectory;
@@ -55,13 +56,15 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
        protected string $id;
        private string $objectPrefix = 'urn:oid:';
 
-       private $logger;
+       private ILogger $logger;
 
        private bool $handleCopiesAsOwned;
+       protected bool $validateWrites = true;
 
-       /** @var bool */
-       protected $validateWrites = true;
-
+       /**
+        * @param array $params
+        * @throws \Exception
+        */
        public function __construct($params) {
                if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) {
                        $this->objectStore = $params['objectstore'];
index b85f6289c94858a3943ce41b5fa2fac7a2e27fe6..9c3981315359b90f630aef2abdb7039e1f2c0441 100644 (file)
@@ -30,7 +30,7 @@ use OCP\Files\ObjectStore\IObjectStore;
  * Allow overwriting the object store instance for test purposes
  */
 class ObjectStoreStorageOverwrite extends ObjectStoreStorage {
-       public function setObjectStore(IObjectStore $objectStore) {
+       public function setObjectStore(IObjectStore $objectStore): void {
                $this->objectStore = $objectStore;
        }
 
@@ -38,7 +38,7 @@ class ObjectStoreStorageOverwrite extends ObjectStoreStorage {
                return $this->objectStore;
        }
 
-       public function setValidateWrites(bool $validate) {
+       public function setValidateWrites(bool $validate): void {
                $this->validateWrites = $validate;
        }
 }