]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files_trashbin): Fix all IStorage return types
authorprovokateurin <kate@provokateurin.de>
Thu, 19 Sep 2024 16:18:15 +0000 (18:18 +0200)
committerprovokateurin <kate@provokateurin.de>
Thu, 26 Sep 2024 15:29:22 +0000 (17:29 +0200)
Signed-off-by: provokateurin <kate@provokateurin.de>
apps/files_trashbin/lib/Storage.php
apps/files_trashbin/tests/StorageTest.php

index c05d248c9d05a18f534166d4b3041b681211381a..23a0e5bd9193e62ccb76eeb85841883845d2bd73 100644 (file)
@@ -48,14 +48,7 @@ class Storage extends Wrapper {
                parent::__construct($parameters);
        }
 
-       /**
-        * Deletes the given file by moving it into the trashbin.
-        *
-        * @param string $path path of file or folder to delete
-        *
-        * @return bool true if the operation succeeded, false otherwise
-        */
-       public function unlink($path) {
+       public function unlink($path): bool {
                if ($this->trashEnabled) {
                        try {
                                return $this->doDelete($path, 'unlink');
@@ -72,14 +65,7 @@ class Storage extends Wrapper {
                }
        }
 
-       /**
-        * Deletes the given folder by moving it into the trashbin.
-        *
-        * @param string $path path of folder to delete
-        *
-        * @return bool true if the operation succeeded, false otherwise
-        */
-       public function rmdir($path) {
+       public function rmdir($path): bool {
                if ($this->trashEnabled) {
                        return $this->doDelete($path, 'rmdir');
                } else {
@@ -94,7 +80,7 @@ class Storage extends Wrapper {
         * @param $path
         * @return bool
         */
-       protected function shouldMoveToTrash($path) {
+       protected function shouldMoveToTrash($path): bool {
                $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path);
                $parts = explode('/', $normalized);
                if (count($parts) < 4 || strpos($normalized, '/appdata_') === 0) {
@@ -132,7 +118,7 @@ class Storage extends Wrapper {
         * @param Node $node
         * @return MoveToTrashEvent
         */
-       protected function createMoveToTrashEvent(Node $node) {
+       protected function createMoveToTrashEvent(Node $node): MoveToTrashEvent {
                return new MoveToTrashEvent($node);
        }
 
@@ -144,7 +130,7 @@ class Storage extends Wrapper {
         *
         * @return bool true if the operation succeeded, false otherwise
         */
-       private function doDelete($path, $method) {
+       private function doDelete($path, $method): bool {
                if (
                        !\OC::$server->getAppManager()->isEnabledForUser('files_trashbin')
                        || (pathinfo($path, PATHINFO_EXTENSION) === 'part')
@@ -170,7 +156,7 @@ class Storage extends Wrapper {
        /**
         * Setup the storage wrapper callback
         */
-       public static function setupStorage() {
+       public static function setupStorage(): void {
                $trashManager = \OC::$server->get(ITrashManager::class);
                $userManager = \OC::$server->get(IUserManager::class);
                $logger = \OC::$server->get(LoggerInterface::class);
@@ -195,7 +181,7 @@ class Storage extends Wrapper {
                return $this->mountPoint;
        }
 
-       public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
+       public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
                $sourceIsTrashbin = $sourceStorage->instanceOfStorage(Storage::class);
                try {
                        // the fallback for moving between storage involves a copy+delete
@@ -219,11 +205,11 @@ class Storage extends Wrapper {
                }
        }
 
-       protected function disableTrash() {
+       protected function disableTrash(): void {
                $this->trashEnabled = false;
        }
 
-       protected function enableTrash() {
+       protected function enableTrash(): void {
                $this->trashEnabled = true;
        }
 }
index f0f3159b32aae77683a07b8dfc860943335f5f29..9de4bf0cc13fb38978ae617517d72c6737cdcaf5 100644 (file)
@@ -29,11 +29,11 @@ use Psr\Log\LoggerInterface;
 use Test\Traits\MountProviderTrait;
 
 class TemporaryNoCross extends Temporary {
-       public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = null) {
+       public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = null): bool {
                return Common::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime);
        }
 
-       public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
+       public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool {
                return Common::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
        }
 }