]> source.dussan.org Git - nextcloud-server.git/commitdiff
chore: Check storage is an instance of the correct class instead of psalm-suppress fix/remove-references-to-deprected-storage-interface
authorCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 16 Sep 2024 16:07:03 +0000 (18:07 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Mon, 16 Sep 2024 16:11:39 +0000 (18:11 +0200)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
lib/private/Files/Storage/Common.php

index 80e39fa9b933a7779a3fb1af3704e727ebfc782f..eb93ab89bc7e8408e1ca8321554c11619c2a48bf 100644 (file)
@@ -326,11 +326,12 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
                if (!$storage) {
                        $storage = $this;
                }
-               /** @psalm-suppress NoInterfaceProperties The isset check is safe */
+               if (!$storage->instanceOfStorage(self::class)) {
+                       throw new \InvalidArgumentException('Storage is not of the correct class');
+               }
                if (!isset($storage->scanner)) {
                        $storage->scanner = new Scanner($storage);
                }
-               /** @psalm-suppress NoInterfaceProperties Legacy stuff */
                return $storage->scanner;
        }
 
@@ -356,12 +357,13 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
                if (!$storage) {
                        $storage = $this;
                }
-               /** @psalm-suppress NoInterfaceProperties The isset check is safe */
+               if (!$storage->instanceOfStorage(self::class)) {
+                       throw new \InvalidArgumentException('Storage is not of the correct class');
+               }
                if (!isset($storage->propagator)) {
                        $config = \OC::$server->getSystemConfig();
                        $storage->propagator = new Propagator($storage, \OC::$server->getDatabaseConnection(), ['appdata_' . $config->getValue('instanceid')]);
                }
-               /** @psalm-suppress NullableReturnStatement False-positive, as the if above avoids this being null */
                return $storage->propagator;
        }
 
@@ -375,11 +377,12 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
                if (!$storage) {
                        $storage = $this;
                }
-               /** @psalm-suppress NoInterfaceProperties The isset check is safe */
+               if (!$storage->instanceOfStorage(self::class)) {
+                       throw new \InvalidArgumentException('Storage is not of the correct class');
+               }
                if (!isset($storage->updater)) {
                        $storage->updater = new Updater($storage);
                }
-               /** @psalm-suppress NullableReturnStatement False-positive, as the if above avoids this being null */
                return $storage->updater;
        }