diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-09-16 20:50:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 20:50:38 +0200 |
commit | b9fb1db0f807fbbbfdbbf544a24d7cc3b396ec14 (patch) | |
tree | a48200e434ebd104fb94377e1a4807494ed2f9ae | |
parent | ede0c26b78722f07ea4b672ff7c00f9723e0454e (diff) | |
parent | 03b969fb9597ae86564ad5f8a83d6fd64bd1d65a (diff) | |
download | nextcloud-server-b9fb1db0f807fbbbfdbbf544a24d7cc3b396ec14.tar.gz nextcloud-server-b9fb1db0f807fbbbfdbbf544a24d7cc3b396ec14.zip |
Merge pull request #48009 from nextcloud/fix/remove-references-to-deprected-storage-interface
fix: Remove OCP\Files\Storage interface deprecated since version 9
38 files changed, 167 insertions, 656 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index 0b9199492fe..34cc2b77b37 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -28,7 +28,7 @@ use OCP\Files\InvalidPathException; use OCP\Files\LockNotAcquiredException; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\Files\Storage; +use OCP\Files\Storage\IWriteStreamStorage; use OCP\Files\StorageNotAvailableException; use OCP\IL10N; use OCP\IRequest; @@ -117,8 +117,10 @@ class File extends Node implements IFile { // verify path of the target $this->verifyPath(); - /** @var Storage $partStorage */ [$partStorage] = $this->fileView->resolvePath($this->path); + if ($partStorage === null) { + throw new ServiceUnavailable($this->l10n->t('Failed to get storage for file')); + } $needsPartFile = $partStorage->needsPartFile() && (strlen($this->path) > 1); $view = \OC\Files\Filesystem::getView(); @@ -141,10 +143,11 @@ class File extends Node implements IFile { } // the part file and target file might be on a different storage in case of a single file storage (e.g. single file share) - /** @var \OC\Files\Storage\Storage $partStorage */ [$partStorage, $internalPartPath] = $this->fileView->resolvePath($partFilePath); - /** @var \OC\Files\Storage\Storage $storage */ [$storage, $internalPath] = $this->fileView->resolvePath($this->path); + if ($partStorage === null || $storage === null) { + throw new ServiceUnavailable($this->l10n->t('Failed to get storage for file')); + } try { if (!$needsPartFile) { try { @@ -196,7 +199,7 @@ class File extends Node implements IFile { } } - if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) { + if ($partStorage->instanceOfStorage(IWriteStreamStorage::class)) { $isEOF = false; $wrappedData = CallbackWrapper::wrap($data, null, null, null, null, function ($stream) use (&$isEOF) { $isEOF = feof($stream); @@ -535,7 +538,6 @@ class File extends Node implements IFile { if (\OCP\Server::get(\OCP\App\IAppManager::class)->isEnabledForUser('encryption')) { return []; } - /** @var \OCP\Files\Storage $storage */ [$storage, $internalPath] = $this->fileView->resolvePath($this->path); if (is_null($storage)) { return []; diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 6f9a214fab9..55a6783225d 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -17,7 +17,7 @@ use OCA\DAV\Connector\Sabre\File; use OCP\Constants; use OCP\Files\FileInfo; use OCP\Files\ForbiddenException; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\IConfig; use OCP\IRequestId; use OCP\ITempManager; @@ -72,11 +72,8 @@ class FileTest extends TestCase { parent::tearDown(); } - /** - * @return MockObject|Storage - */ - private function getMockStorage() { - $storage = $this->getMockBuilder(Storage::class) + private function getMockStorage(): MockObject&IStorage { + $storage = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor() ->getMock(); $storage->method('getId') @@ -84,10 +81,7 @@ class FileTest extends TestCase { return $storage; } - /** - * @param string $string - */ - private function getStream($string) { + private function getStream(string $string) { $stream = fopen('php://temp', 'r+'); fwrite($stream, $string); fseek($stream, 0); diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php index 83f4139a2d9..c5e2b03d8b4 100644 --- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php @@ -18,7 +18,7 @@ use OCA\Files_Sharing\SharedStorage; use OCP\Constants; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Mount\IMountPoint; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\ICache; use OCP\Share\IManager; use OCP\Share\IShare; @@ -75,7 +75,7 @@ class NodeTest extends \Test\TestCase { return $this->createMock(MountPoint::class); } }); - $storage = $this->createMock(Storage\IStorage::class); + $storage = $this->createMock(IStorage::class); if ($shared) { $storage->method('instanceOfStorage') ->willReturn(true); @@ -145,7 +145,7 @@ class NodeTest extends \Test\TestCase { * @dataProvider sharePermissionsProvider */ public function testSharePermissions($type, $user, $permissions, $expected): void { - $storage = $this->getMockBuilder(Storage::class) + $storage = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor() ->getMock(); $storage->method('getPermissions')->willReturn($permissions); @@ -223,7 +223,7 @@ class NodeTest extends \Test\TestCase { } public function testShareAttributesNonShare(): void { - $storage = $this->getMockBuilder(Storage::class) + $storage = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index b07bd0a6b25..10f85f7e74e 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -15,8 +15,9 @@ use OCA\Encryption\Exceptions\PublicKeyMissingException; use OCA\Encryption\KeyManager; use OCA\Encryption\Session; use OCA\Encryption\Util; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\IL10N; +use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -50,13 +51,12 @@ class EncryptionTest extends TestCase { /** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l10nMock; - /** @var \OCP\Files\Storage|\PHPUnit\Framework\MockObject\MockObject */ - private $storageMock; + private IStorage&MockObject $storageMock; protected function setUp(): void { parent::setUp(); - $this->storageMock = $this->getMockBuilder(Storage::class) + $this->storageMock = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor()->getMock(); $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index a9919e8eab4..869e5e2cf96 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -15,7 +15,7 @@ use OCA\Encryption\Session; use OCA\Encryption\Util; use OCP\Encryption\Keys\IStorage; use OCP\Files\Cache\ICache; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage as FilesIStorage; use OCP\IConfig; use OCP\IUserSession; use OCP\Lock\ILockingProvider; @@ -687,7 +687,7 @@ class KeyManagerTest extends TestCase { $cache->expects($this->once()) ->method('update') ->with(123, ['encrypted' => 5, 'encryptedVersion' => 5]); - $storage = $this->getMockBuilder(Storage::class) + $storage = $this->getMockBuilder(FilesIStorage::class) ->disableOriginalConstructor()->getMock(); $storage->expects($this->once()) ->method('getCache') diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php index 6f2eec1ebf4..f2e6f406c35 100644 --- a/apps/encryption/tests/UtilTest.php +++ b/apps/encryption/tests/UtilTest.php @@ -11,7 +11,7 @@ use OC\Files\View; use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\Util; use OCP\Files\Mount\IMountPoint; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\IConfig; use OCP\IUser; use OCP\IUserManager; @@ -181,7 +181,7 @@ class UtilTest extends TestCase { } public function testGetStorage(): void { - $return = $this->getMockBuilder(Storage::class) + $return = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php index 97bc4f78142..d0437432427 100644 --- a/apps/files_external/lib/Config/ConfigAdapter.php +++ b/apps/files_external/lib/Config/ConfigAdapter.php @@ -14,7 +14,8 @@ use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\Service\UserGlobalStoragesService; use OCA\Files_External\Service\UserStoragesService; use OCP\Files\Config\IMountProvider; -use OCP\Files\Storage; +use OCP\Files\ObjectStore\IObjectStore; +use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorageFactory; use OCP\Files\StorageNotAvailableException; use OCP\IUser; @@ -34,11 +35,9 @@ class ConfigAdapter implements IMountProvider { /** * Process storage ready for mounting * - * @param StorageConfig $storage - * @param IUser $user * @throws \OCP\AppFramework\QueryException */ - private function prepareStorageConfig(StorageConfig &$storage, IUser $user) { + private function prepareStorageConfig(StorageConfig &$storage, IUser $user): void { foreach ($storage->getBackendOptions() as $option => $value) { $storage->setBackendOption($option, \OCA\Files_External\MountConfig::substitutePlaceholdersInConfig($value, $user->getUID())); } @@ -46,7 +45,7 @@ class ConfigAdapter implements IMountProvider { $objectStore = $storage->getBackendOption('objectstore'); if ($objectStore) { $objectClass = $objectStore['class']; - if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) { + if (!is_subclass_of($objectClass, IObjectStore::class)) { throw new \InvalidArgumentException('Invalid object store'); } $storage->setBackendOption('objectstore', new $objectClass($objectStore)); @@ -60,9 +59,8 @@ class ConfigAdapter implements IMountProvider { * Construct the storage implementation * * @param StorageConfig $storageConfig - * @return Storage */ - private function constructStorage(StorageConfig $storageConfig) { + private function constructStorage(StorageConfig $storageConfig): IStorage { $class = $storageConfig->getBackend()->getStorageClass(); $storage = new $class($storageConfig->getBackendOptions()); @@ -76,8 +74,6 @@ class ConfigAdapter implements IMountProvider { /** * Get all mountpoints applicable for the user * - * @param \OCP\IUser $user - * @param \OCP\Files\Storage\IStorageFactory $loader * @return \OCP\Files\Mount\IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $loader) { @@ -97,11 +93,11 @@ class ConfigAdapter implements IMountProvider { }, $storageConfigs); - \OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function (Storage\IStorage $storage) { + \OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function (IStorage $storage) { return $storage->getId(); }, $storages)); - $availableStorages = array_map(function (Storage\IStorage $storage, StorageConfig $storageConfig) { + $availableStorages = array_map(function (IStorage $storage, StorageConfig $storageConfig): IStorage { try { $availability = $storage->getAvailability(); if (!$availability['available'] && !Availability::shouldRecheck($availability)) { @@ -116,7 +112,7 @@ class ConfigAdapter implements IMountProvider { return $storage; }, $storages, $storageConfigs); - $mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) { + $mounts = array_map(function (StorageConfig $storageConfig, IStorage $storage) use ($user, $loader) { $storage->setOwner($user->getUID()); if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAL) { return new PersonalMount( diff --git a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php index d81c73ca13f..314ab82385e 100644 --- a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php +++ b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php @@ -12,7 +12,7 @@ use OCA\Files_External\Lib\SessionStorageWrapper; use OCA\Files_External\Lib\StorageConfig; use OCP\Authentication\Exceptions\CredentialsUnavailableException; use OCP\Authentication\LoginCredentials\IStore as CredentialsStore; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\Files\StorageAuthException; use OCP\IL10N; use OCP\IUser; @@ -56,7 +56,7 @@ class SessionCredentials extends AuthMechanism { $storage->setBackendOption('password', $credentials->getPassword()); } - public function wrapStorage(Storage $storage) { + public function wrapStorage(IStorage $storage): IStorage { return new SessionStorageWrapper(['storage' => $storage]); } } diff --git a/apps/files_external/lib/Lib/StorageModifierTrait.php b/apps/files_external/lib/Lib/StorageModifierTrait.php index 7cc7a15605c..4b9264f4223 100644 --- a/apps/files_external/lib/Lib/StorageModifierTrait.php +++ b/apps/files_external/lib/Lib/StorageModifierTrait.php @@ -6,7 +6,7 @@ */ namespace OCA\Files_External\Lib; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; use OCP\IUser; @@ -28,8 +28,8 @@ trait StorageModifierTrait { /** * Modify a StorageConfig parameters * - * @param StorageConfig $storage - * @param IUser $user User the storage is being used as + * @param StorageConfig &$storage + * @param ?IUser $user User the storage is being used as * @return void * @throws InsufficientDataForMeaningfulAnswerException * @throws StorageNotAvailableException @@ -38,14 +38,12 @@ trait StorageModifierTrait { } /** - * Wrap a Storage if necessary + * Wrap a storage if necessary * - * @param Storage $storage - * @return Storage * @throws InsufficientDataForMeaningfulAnswerException * @throws StorageNotAvailableException */ - public function wrapStorage(Storage $storage) { + public function wrapStorage(IStorage $storage): IStorage { return $storage; } } diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 36f4c0b8859..169054fd1d9 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -149,6 +149,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, if (!isset($this->scanner)) { $this->scanner = new Scanner($storage); } + /** @var \OCA\Files_Sharing\External\Scanner */ return $this->scanner; } diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 00f757d4734..62f5880294c 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -27,6 +27,7 @@ use OCP\Files\IHomeStorage; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\Storage\IDisableEncryptionStorage; +use OCP\Files\Storage\ILockingStorage; use OCP\Files\Storage\ISharedStorage; use OCP\Files\Storage\IStorage; use OCP\Lock\ILockingProvider; @@ -494,7 +495,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha * @throws \OCP\Lock\LockedException */ public function acquireLock($path, $type, ILockingProvider $provider) { - /** @var \OCP\Files\Storage $targetStorage */ + /** @var ILockingStorage $targetStorage */ [$targetStorage, $targetInternalPath] = $this->resolvePath($path); $targetStorage->acquireLock($targetInternalPath, $type, $provider); // lock the parent folders of the owner when locking the share as recipient @@ -510,7 +511,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha * @param \OCP\Lock\ILockingProvider $provider */ public function releaseLock($path, $type, ILockingProvider $provider) { - /** @var \OCP\Files\Storage $targetStorage */ + /** @var ILockingStorage $targetStorage */ [$targetStorage, $targetInternalPath] = $this->resolvePath($path); $targetStorage->releaseLock($targetInternalPath, $type, $provider); // unlock the parent folders of the owner when unlocking the share as recipient @@ -526,7 +527,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha * @param \OCP\Lock\ILockingProvider $provider */ public function changeLock($path, $type, ILockingProvider $provider) { - /** @var \OCP\Files\Storage $targetStorage */ + /** @var ILockingStorage $targetStorage */ [$targetStorage, $targetInternalPath] = $this->resolvePath($path); $targetStorage->changeLock($targetInternalPath, $type, $provider); } diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index f28302b4ccd..36ac04714b7 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -16,7 +16,7 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\IConfig; use OCP\IDateTimeZone; use OCP\IGroup; @@ -526,7 +526,7 @@ class ShareAPIControllerTest extends TestCase { ->getMock(); $cache->method('getNumericStorageId')->willReturn(101); - $storage = $this->getMockBuilder(Storage::class) + $storage = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor() ->getMock(); $storage->method('getId')->willReturn('STORAGE'); @@ -1923,7 +1923,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -1947,7 +1947,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -1972,7 +1972,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(File::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -1996,7 +1996,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(1); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -2035,7 +2035,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -2074,7 +2074,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -2120,7 +2120,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -2159,7 +2159,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -2205,7 +2205,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -2574,7 +2574,7 @@ class ShareAPIControllerTest extends TestCase { $path = $this->getMockBuilder(Folder::class)->getMock(); $path->method('getId')->willReturn(42); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', true], @@ -3762,7 +3762,7 @@ class ShareAPIControllerTest extends TestCase { $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); $cache->method('getNumericStorageId')->willReturn(100); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('getId')->willReturn('storageId'); $storage->method('getCache')->willReturn($cache); @@ -4759,7 +4759,7 @@ class ShareAPIControllerTest extends TestCase { $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); $cache->method('getNumericStorageId')->willReturn(100); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('getId')->willReturn('storageId'); $storage->method('getCache')->willReturn($cache); @@ -4923,7 +4923,7 @@ class ShareAPIControllerTest extends TestCase { private function getNonSharedUserFolder(): array { $node = $this->getMockBuilder(Folder::class)->getMock(); $userFolder = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], @@ -4938,7 +4938,7 @@ class ShareAPIControllerTest extends TestCase { private function getNonSharedUserFile(): array { $node = $this->getMockBuilder(File::class)->getMock(); $userFolder = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->willReturnMap([ ['OCA\Files_Sharing\External\Storage', false], diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php index 5f907ad8de3..49ff97c053a 100644 --- a/apps/files_sharing/tests/SharedStorageTest.php +++ b/apps/files_sharing/tests/SharedStorageTest.php @@ -416,9 +416,6 @@ class SharedStorageTest extends TestCase { $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files'); $this->assertTrue($view->file_exists($this->folder)); - /** - * @var \OCP\Files\Storage $sharedStorage - */ [$sharedStorage,] = $view->resolvePath($this->folder); $this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')); @@ -449,9 +446,6 @@ class SharedStorageTest extends TestCase { $view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files'); $this->assertTrue($view->file_exists($this->folder)); - /** - * @var \OCP\Files\Storage $sharedStorage - */ [$sharedStorage,] = $view->resolvePath($this->folder); $this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')); diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index c9863241045..544bc877d70 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -29,6 +29,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; +use OCP\Files\Storage\ILockingStorage; use OCP\FilesMetadata\IFilesMetadataManager; use OCP\IConfig; use OCP\IDBConnection; @@ -118,7 +119,7 @@ class Trashbin { * @param string $user * @param string $filename * @param string $timestamp - * @return string original location + * @return string|false original location */ public static function getLocation($user, $filename, $timestamp) { $query = \OC::$server->getDatabaseConnection()->getQueryBuilder(); @@ -139,7 +140,8 @@ class Trashbin { } } - private static function setUpTrash($user) { + /** @param string $user */ + private static function setUpTrash($user): void { $view = new View('/' . $user); if (!$view->is_dir('files_trashbin')) { $view->mkdir('files_trashbin'); @@ -162,10 +164,10 @@ class Trashbin { * @param string $sourcePath * @param string $owner * @param string $targetPath - * @param $user + * @param string $user * @param int $timestamp */ - private static function copyFilesToUser($sourcePath, $owner, $targetPath, $user, $timestamp) { + private static function copyFilesToUser($sourcePath, $owner, $targetPath, $user, $timestamp): void { self::setUpTrash($owner); $targetFilename = basename($targetPath); @@ -256,7 +258,7 @@ class Trashbin { while (!$gotLock) { try { - /** @var \OC\Files\Storage\Storage $trashStorage */ + /** @var ILockingStorage $trashStorage */ [$trashStorage, $trashInternalPath] = $ownerView->resolvePath($trashPath); $trashStorage->acquireLock($trashInternalPath, ILockingProvider::LOCK_EXCLUSIVE, $lockingProvider); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 5510143197a..78aca5fe883 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -421,7 +421,6 @@ return array( 'OCP\\Files\\SimpleFS\\ISimpleFolder' => $baseDir . '/lib/public/Files/SimpleFS/ISimpleFolder.php', 'OCP\\Files\\SimpleFS\\ISimpleRoot' => $baseDir . '/lib/public/Files/SimpleFS/ISimpleRoot.php', 'OCP\\Files\\SimpleFS\\InMemoryFile' => $baseDir . '/lib/public/Files/SimpleFS/InMemoryFile.php', - 'OCP\\Files\\Storage' => $baseDir . '/lib/public/Files/Storage.php', 'OCP\\Files\\StorageAuthException' => $baseDir . '/lib/public/Files/StorageAuthException.php', 'OCP\\Files\\StorageBadConfigException' => $baseDir . '/lib/public/Files/StorageBadConfigException.php', 'OCP\\Files\\StorageConnectionException' => $baseDir . '/lib/public/Files/StorageConnectionException.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 7b8584b5438..6a17bc4ff31 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -454,7 +454,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Files\\SimpleFS\\ISimpleFolder' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/ISimpleFolder.php', 'OCP\\Files\\SimpleFS\\ISimpleRoot' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/ISimpleRoot.php', 'OCP\\Files\\SimpleFS\\InMemoryFile' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/InMemoryFile.php', - 'OCP\\Files\\Storage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage.php', 'OCP\\Files\\StorageAuthException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageAuthException.php', 'OCP\\Files\\StorageBadConfigException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageBadConfigException.php', 'OCP\\Files\\StorageConnectionException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageConnectionException.php', diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index c85104ac4b9..6e1c86eed47 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -15,6 +15,7 @@ use OC\SystemConfig; use OCP\Files\Cache\IScanner; use OCP\Files\ForbiddenException; use OCP\Files\NotFoundException; +use OCP\Files\Storage\ILockingStorage; use OCP\Files\Storage\IReliableEtagStorage; use OCP\IDBConnection; use OCP\Lock\ILockingProvider; @@ -125,7 +126,7 @@ class Scanner extends BasicEmitter implements IScanner { if (!self::isPartialFile($file)) { // acquire a lock if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->acquireLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -134,7 +135,7 @@ class Scanner extends BasicEmitter implements IScanner { $data = $data ?? $this->getData($file); } catch (ForbiddenException $e) { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -233,7 +234,7 @@ class Scanner extends BasicEmitter implements IScanner { } } catch (\Exception $e) { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -242,7 +243,7 @@ class Scanner extends BasicEmitter implements IScanner { // release the acquired lock if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -319,7 +320,7 @@ class Scanner extends BasicEmitter implements IScanner { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->acquireLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } @@ -337,7 +338,7 @@ class Scanner extends BasicEmitter implements IScanner { } } finally { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(ILockingStorage::class)) { $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); } diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 228fc516677..663041ed92c 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -141,6 +141,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil if (!isset($this->scanner)) { $this->scanner = new ObjectStoreScanner($storage); } + /** @var \OC\Files\ObjectStore\ObjectStoreScanner */ return $this->scanner; } diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index cefba66683b..eb93ab89bc7 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -44,14 +44,14 @@ use Psr\Log\LoggerInterface; abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { use LocalTempFileTrait; - protected $cache; - protected $scanner; - protected $watcher; - protected $propagator; + protected ?Cache $cache = null; + protected ?Scanner $scanner = null; + protected ?Watcher $watcher = null; + protected ?Propagator $propagator = null; protected $storageCache; - protected $updater; + protected ?Updater $updater = null; - protected $mountOptions = []; + protected array $mountOptions = []; protected $owner = null; private ?bool $shouldLogLocks = null; @@ -232,10 +232,6 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return hash_final($ctx, $raw); } - public function search($query) { - return $this->searchInDir($query); - } - public function getLocalFile($path) { return $this->getCachedFile($path); } @@ -310,13 +306,19 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return $dependencies; } + /** + * @return Cache + */ public function getCache($path = '', $storage = null) { if (!$storage) { $storage = $this; } + /** @psalm-suppress NoInterfaceProperties The isset check is safe */ if (!isset($storage->cache)) { $storage->cache = new Cache($storage, $this->getCacheDependencies()); } + /** @psalm-suppress NullableReturnStatement False-positive, as the if above avoids this being null */ + /** @psalm-suppress NoInterfaceProperties Legacy */ return $storage->cache; } @@ -324,6 +326,9 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { if (!$storage) { $storage = $this; } + if (!$storage->instanceOfStorage(self::class)) { + throw new \InvalidArgumentException('Storage is not of the correct class'); + } if (!isset($storage->scanner)) { $storage->scanner = new Scanner($storage); } @@ -345,13 +350,16 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { /** * get a propagator instance for the cache * - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher - * @return \OC\Files\Cache\Propagator + * @param \OC\Files\Storage\Storage $storage (optional) the storage to pass to the watcher + * @return Propagator */ public function getPropagator($storage = null) { if (!$storage) { $storage = $this; } + 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')]); @@ -359,10 +367,19 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { return $storage->propagator; } + /** + * get a propagator instance for the cache + * + * @param \OC\Files\Storage\Storage $storage (optional) the storage to pass to the watcher + * @return Updater + */ public function getUpdater($storage = null) { if (!$storage) { $storage = $this; } + if (!$storage->instanceOfStorage(self::class)) { + throw new \InvalidArgumentException('Storage is not of the correct class'); + } if (!isset($storage->updater)) { $storage->updater = new Updater($storage); } diff --git a/lib/private/Files/Storage/Home.php b/lib/private/Files/Storage/Home.php index a8d1f82b987..0e53e7b28d4 100644 --- a/lib/private/Files/Storage/Home.php +++ b/lib/private/Files/Storage/Home.php @@ -52,13 +52,14 @@ class Home extends Local implements \OCP\Files\IHomeStorage { if (!isset($this->cache)) { $this->cache = new \OC\Files\Cache\HomeCache($storage, $this->getCacheDependencies()); } + /** @var \OC\Files\Cache\HomeCache */ return $this->cache; } /** * get a propagator instance for the cache * - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher + * @param \OC\Files\Storage\Storage $storage (optional) the storage to pass to the watcher * @return \OC\Files\Cache\Propagator */ public function getPropagator($storage = null) { @@ -68,6 +69,7 @@ class Home extends Local implements \OCP\Files\IHomeStorage { if (!isset($this->propagator)) { $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); } + /** @var \OC\Files\Cache\Propagator */ return $this->propagator; } diff --git a/lib/private/Files/Storage/Storage.php b/lib/private/Files/Storage/Storage.php index 44b1a52cfc0..aff914ee12a 100644 --- a/lib/private/Files/Storage/Storage.php +++ b/lib/private/Files/Storage/Storage.php @@ -5,16 +5,18 @@ * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ + namespace OC\Files\Storage; -use OCP\Lock\ILockingProvider; +use OCP\Files\Storage\ILockingStorage; +use OCP\Files\Storage\IStorage; /** * Provide a common interface to all different storage options * * All paths passed to the storage are relative to the storage and should NOT have a leading slash. */ -interface Storage extends \OCP\Files\Storage { +interface Storage extends IStorage, ILockingStorage { /** * get a cache instance for the storage * @@ -33,15 +35,6 @@ interface Storage extends \OCP\Files\Storage { */ public function getScanner($path = '', $storage = null); - - /** - * get the user id of the owner of a file or folder - * - * @param string $path - * @return string - */ - public function getOwner($path); - /** * get a watcher instance for the cache * @@ -79,30 +72,6 @@ interface Storage extends \OCP\Files\Storage { public function getMetaData($path); /** - * @param string $path The path of the file to acquire the lock for - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @param \OCP\Lock\ILockingProvider $provider - * @throws \OCP\Lock\LockedException - */ - public function acquireLock($path, $type, ILockingProvider $provider); - - /** - * @param string $path The path of the file to release the lock for - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @param \OCP\Lock\ILockingProvider $provider - * @throws \OCP\Lock\LockedException - */ - public function releaseLock($path, $type, ILockingProvider $provider); - - /** - * @param string $path The path of the file to change the lock for - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @param \OCP\Lock\ILockingProvider $provider - * @throws \OCP\Lock\LockedException - */ - public function changeLock($path, $type, ILockingProvider $provider); - - /** * Get the contents of a directory with metadata * * @param string $directory diff --git a/lib/private/Files/Storage/StorageFactory.php b/lib/private/Files/Storage/StorageFactory.php index 612592e2d3a..590425f5b64 100644 --- a/lib/private/Files/Storage/StorageFactory.php +++ b/lib/private/Files/Storage/StorageFactory.php @@ -8,6 +8,7 @@ namespace OC\Files\Storage; use OCP\Files\Mount\IMountPoint; +use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorageFactory; class StorageFactory implements IStorageFactory { @@ -56,19 +57,17 @@ class StorageFactory implements IStorageFactory { /** * Create an instance of a storage and apply the registered storage wrappers * - * @param \OCP\Files\Mount\IMountPoint $mountPoint * @param string $class * @param array $arguments - * @return \OCP\Files\Storage + * @return IStorage */ public function getInstance(IMountPoint $mountPoint, $class, $arguments) { return $this->wrap($mountPoint, new $class($arguments)); } /** - * @param \OCP\Files\Mount\IMountPoint $mountPoint - * @param \OCP\Files\Storage $storage - * @return \OCP\Files\Storage + * @param IStorage $storage + * @return IStorage */ public function wrap(IMountPoint $mountPoint, $storage) { $wrappers = array_values($this->storageWrappers); @@ -81,7 +80,7 @@ class StorageFactory implements IStorageFactory { }, $wrappers); foreach ($wrappers as $wrapper) { $storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint); - if (!($storage instanceof \OCP\Files\Storage)) { + if (!($storage instanceof IStorage)) { throw new \Exception('Invalid result from storage wrapper'); } } diff --git a/lib/private/Files/Storage/Temporary.php b/lib/private/Files/Storage/Temporary.php index 95ae84cb7d9..6c7ef4260c1 100644 --- a/lib/private/Files/Storage/Temporary.php +++ b/lib/private/Files/Storage/Temporary.php @@ -11,7 +11,7 @@ namespace OC\Files\Storage; * local storage backend in temporary folder for testing purpose */ class Temporary extends Local { - public function __construct($arguments = null) { + public function __construct($arguments = []) { parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]); } diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index 11f21eb828e..a696a3e4802 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -382,16 +382,6 @@ class Encoding extends Wrapper { } /** - * search for occurrences of $query in file names - * - * @param string $query - * @return array|bool - */ - public function search($query) { - return $this->storage->search($query); - } - - /** * see https://www.php.net/manual/en/function.touch.php * If the backend does not support the operation, false should be returned * diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 2e8306dc705..5673caf834a 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -322,16 +322,6 @@ class Jail extends Wrapper { } /** - * search for occurrences of $query in file names - * - * @param string $query - * @return array|bool - */ - public function search($query) { - return $this->getWrapperStorage()->search($query); - } - - /** * see https://www.php.net/manual/en/function.touch.php * If the backend does not support the operation, false should be returned * diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index f8aa9d963dc..f0420f4f16a 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -317,16 +317,6 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea } /** - * search for occurrences of $query in file names - * - * @param string $query - * @return array|bool - */ - public function search($query) { - return $this->getWrapperStorage()->search($query); - } - - /** * see https://www.php.net/manual/en/function.touch.php * If the backend does not support the operation, false should be returned * diff --git a/lib/public/Files/Storage.php b/lib/public/Files/Storage.php deleted file mode 100644 index 049841075ca..00000000000 --- a/lib/public/Files/Storage.php +++ /dev/null @@ -1,445 +0,0 @@ -<?php - -/** - * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2016 ownCloud, Inc. - * SPDX-License-Identifier: AGPL-3.0-only - */ -// use OCP namespace for all classes that are considered public. -// This means that they should be used by apps instead of the internal Nextcloud classes - -namespace OCP\Files; - -use OCP\Files\Storage\IStorage; -use OCP\Lock\ILockingProvider; - -/** - * Provide a common interface to all different storage options - * - * All paths passed to the storage are relative to the storage and should NOT have a leading slash. - * - * @since 6.0.0 - * @deprecated 9.0.0 use \OCP\Files\Storage\IStorage instead - */ -interface Storage extends IStorage { - /** - * $parameters is a free form array with the configuration options needed to construct the storage - * - * @param array $parameters - * @since 6.0.0 - */ - public function __construct($parameters); - - /** - * Get the identifier for the storage, - * the returned id should be the same for every storage object that is created with the same parameters - * and two storage objects with the same id should refer to two storages that display the same files. - * - * @return string - * @since 6.0.0 - */ - public function getId(); - - /** - * see https://www.php.net/manual/en/function.mkdir.php - * implementations need to implement a recursive mkdir - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function mkdir($path); - - /** - * see https://www.php.net/manual/en/function.rmdir.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function rmdir($path); - - /** - * see https://www.php.net/manual/en/function.opendir.php - * - * @param string $path - * @return resource|false - * @since 6.0.0 - */ - public function opendir($path); - - /** - * see https://www.php.net/manual/en/function.is-dir.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function is_dir($path); - - /** - * see https://www.php.net/manual/en/function.is-file.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function is_file($path); - - /** - * see https://www.php.net/manual/en/function.stat.php - * only the following keys are required in the result: size and mtime - * - * @param string $path - * @return array|bool - * @since 6.0.0 - */ - public function stat($path); - - /** - * see https://www.php.net/manual/en/function.filetype.php - * - * @param string $path - * @return string|bool - * @since 6.0.0 - */ - public function filetype($path); - - /** - * see https://www.php.net/manual/en/function.filesize.php - * The result for filesize when called on a folder is required to be 0 - * - * @param string $path - * @return false|int|float - * @since 6.0.0 - */ - public function filesize($path); - - /** - * check if a file can be created in $path - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isCreatable($path); - - /** - * check if a file can be read - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isReadable($path); - - /** - * check if a file can be written to - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isUpdatable($path); - - /** - * check if a file can be deleted - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isDeletable($path); - - /** - * check if a file can be shared - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function isSharable($path); - - /** - * get the full permissions of a path. - * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php - * - * @param string $path - * @return int - * @since 6.0.0 - */ - public function getPermissions($path); - - /** - * see https://www.php.net/manual/en/function.file_exists.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function file_exists($path); - - /** - * see https://www.php.net/manual/en/function.filemtime.php - * - * @param string $path - * @return int|bool - * @since 6.0.0 - */ - public function filemtime($path); - - /** - * see https://www.php.net/manual/en/function.file_get_contents.php - * - * @param string $path - * @return string|false - * @since 6.0.0 - */ - public function file_get_contents($path); - - /** - * see https://www.php.net/manual/en/function.file_put_contents.php - * - * @param string $path - * @param mixed $data - * @return int|float|false - * @since 6.0.0 - */ - public function file_put_contents($path, $data); - - /** - * see https://www.php.net/manual/en/function.unlink.php - * - * @param string $path - * @return bool - * @since 6.0.0 - */ - public function unlink($path); - - /** - * see https://www.php.net/manual/en/function.rename.php - * - * @param string $source - * @param string $target - * @return bool - * @since 6.0.0 - */ - public function rename($source, $target); - - /** - * see https://www.php.net/manual/en/function.copy.php - * - * @param string $source - * @param string $target - * @return bool - * @since 6.0.0 - */ - public function copy($source, $target); - - /** - * see https://www.php.net/manual/en/function.fopen.php - * - * @param string $path - * @param string $mode - * @return resource|bool - * @since 6.0.0 - */ - public function fopen($path, $mode); - - /** - * get the mimetype for a file or folder - * The mimetype for a folder is required to be "httpd/unix-directory" - * - * @param string $path - * @return string|bool - * @since 6.0.0 - */ - public function getMimeType($path); - - /** - * see https://www.php.net/manual/en/function.hash-file.php - * - * @param string $type - * @param string $path - * @param bool $raw - * @return string|bool - * @since 6.0.0 - */ - public function hash($type, $path, $raw = false); - - /** - * see https://www.php.net/manual/en/function.disk-free-space.php - * - * @param string $path - * @return int|float|bool - * @since 6.0.0 - */ - public function free_space($path); - - /** - * search for occurrences of $query in file names - * - * @param string $query - * @return array|bool - * @since 6.0.0 - */ - public function search($query); - - /** - * see https://www.php.net/manual/en/function.touch.php - * If the backend does not support the operation, false should be returned - * - * @param string $path - * @param int $mtime - * @return bool - * @since 6.0.0 - */ - public function touch($path, $mtime = null); - - /** - * get the path to a local version of the file. - * The local version of the file can be temporary and doesn't have to be persistent across requests - * - * @param string $path - * @return string|false - * @since 6.0.0 - */ - public function getLocalFile($path); - - /** - * check if a file or folder has been updated since $time - * - * @param string $path - * @param int $time - * @return bool - * @since 6.0.0 - * - * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. - * returning true for other changes in the folder is optional - */ - public function hasUpdated($path, $time); - - /** - * get the ETag for a file or folder - * - * @param string $path - * @return string|false - * @since 6.0.0 - */ - public function getETag($path); - - /** - * Returns whether the storage is local, which means that files - * are stored on the local filesystem instead of remotely. - * Calling getLocalFile() for local storages should always - * return the local files, whereas for non-local storages - * it might return a temporary file. - * - * @return bool true if the files are stored locally, false otherwise - * @since 7.0.0 - */ - public function isLocal(); - - /** - * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class - * - * @template T of IStorage - * @param string $class - * @psalm-param class-string<T> $class - * @return bool - * @since 7.0.0 - * @psalm-assert-if-true T $this - */ - public function instanceOfStorage($class); - - /** - * A custom storage implementation can return an url for direct download of a give file. - * - * For now the returned array can hold the parameter url - in future more attributes might follow. - * - * @param string $path - * @return array|bool - * @since 8.0.0 - */ - public function getDirectDownload($path); - - /** - * @param string $path the path of the target folder - * @param string $fileName the name of the file itself - * @return void - * @throws InvalidPathException - * @since 8.1.0 - */ - public function verifyPath($path, $fileName); - - /** - * @param IStorage $sourceStorage - * @param string $sourceInternalPath - * @param string $targetInternalPath - * @return bool - * @since 8.1.0 - */ - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath); - - /** - * @param IStorage $sourceStorage - * @param string $sourceInternalPath - * @param string $targetInternalPath - * @return bool - * @since 8.1.0 - */ - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath); - - /** - * @param string $path The path of the file to acquire the lock for - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @param \OCP\Lock\ILockingProvider $provider - * @throws \OCP\Lock\LockedException - * @since 8.1.0 - */ - public function acquireLock($path, $type, ILockingProvider $provider); - - /** - * @param string $path The path of the file to acquire the lock for - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @param \OCP\Lock\ILockingProvider $provider - * @throws \OCP\Lock\LockedException - * @since 8.1.0 - */ - public function releaseLock($path, $type, ILockingProvider $provider); - - /** - * @param string $path The path of the file to change the lock for - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @param \OCP\Lock\ILockingProvider $provider - * @throws \OCP\Lock\LockedException - * @since 8.1.0 - */ - public function changeLock($path, $type, ILockingProvider $provider); - - /** - * Test a storage for availability - * - * @since 8.2.0 - * @return bool - */ - public function test(); - - /** - * @since 8.2.0 - * @return array [ available, last_checked ] - */ - public function getAvailability(); - - /** - * @since 8.2.0 - * @param bool $isAvailable - */ - public function setAvailability($isAvailable); - - /** - * @since 12.0.0 - * @return mixed - */ - public function needsPartFile(); -} diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php index e18d6768346..d2fd3b75553 100644 --- a/lib/public/Files/Storage/IStorage.php +++ b/lib/public/Files/Storage/IStorage.php @@ -401,11 +401,20 @@ interface IStorage { /** * @since 9.0.0 * @param bool $isAvailable + * @return void */ public function setAvailability($isAvailable); /** + * @since 12.0.0 + * @since 31.0.0 moved from Storage to IStorage + * @return bool + */ + public function needsPartFile(); + + /** * @param string $path path for which to retrieve the owner + * @return string * @since 9.0.0 */ public function getOwner($path); diff --git a/lib/public/Files/Storage/IStorageFactory.php b/lib/public/Files/Storage/IStorageFactory.php index e0ec3128876..6d44b39274e 100644 --- a/lib/public/Files/Storage/IStorageFactory.php +++ b/lib/public/Files/Storage/IStorageFactory.php @@ -28,10 +28,10 @@ interface IStorageFactory { public function addStorageWrapper($wrapperName, $callback); /** - * @param \OCP\Files\Mount\IMountPoint $mountPoint + * @param IMountPoint $mountPoint * @param string $class * @param array $arguments - * @return \OCP\Files\Storage + * @return IStorage * @since 8.0.0 */ public function getInstance(IMountPoint $mountPoint, $class, $arguments); diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index d073efc8235..6a8453bcaf8 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -12,7 +12,7 @@ use OC\Encryption\Exceptions\DecryptionFailedException; use OC\Encryption\Manager; use OC\Files\FileInfo; use OC\Files\View; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\IUserManager; use OCP\UserInterface; use Symfony\Component\Console\Formatter\OutputFormatterInterface; @@ -246,11 +246,11 @@ class DecryptAllTest extends TestCase { ->setMethods(['decryptFile']) ->getMock(); - $storage = $this->getMockBuilder(Storage::class) + $storage = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor()->getMock(); - $sharedStorage = $this->getMockBuilder(Storage::class) + $sharedStorage = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor()->getMock(); $sharedStorage->expects($this->once())->method('instanceOfStorage') diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php index 1ecb9dc89c7..1ac7342a3d8 100644 --- a/tests/lib/Encryption/EncryptionWrapperTest.php +++ b/tests/lib/Encryption/EncryptionWrapperTest.php @@ -10,7 +10,8 @@ namespace Test\Encryption; use OC\Encryption\EncryptionWrapper; use OC\Encryption\Manager; use OC\Memcache\ArrayCache; -use OCP\Files\Storage; +use OCP\Files\Storage\IDisableEncryptionStorage; +use OCP\Files\Storage\IStorage; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -42,7 +43,7 @@ class EncryptionWrapperTest extends TestCase { * @dataProvider provideWrapStorage */ public function testWrapStorage($expectedWrapped, $wrappedStorages): void { - $storage = $this->getMockBuilder(Storage::class) + $storage = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor() ->getMock(); @@ -74,7 +75,7 @@ class EncryptionWrapperTest extends TestCase { [true, ['OCA\Files_Trashbin\Storage']], // Do not wrap shared storages - [false, [Storage\IDisableEncryptionStorage::class]], + [false, [IDisableEncryptionStorage::class]], ]; } } diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php index eda61feb249..3de54e315a1 100644 --- a/tests/lib/Files/Mount/MountPointTest.php +++ b/tests/lib/Files/Mount/MountPointTest.php @@ -8,14 +8,14 @@ namespace Test\Files\Mount; use OC\Files\Storage\StorageFactory; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; class DummyStorage { } class MountPointTest extends \Test\TestCase { public function testGetStorage(): void { - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->expects($this->once()) ->method('getId') ->willReturn(123); diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index 2e3b6e369d3..5af409a1a93 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -28,7 +28,7 @@ use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\Search\ISearchComparison; use OCP\Files\Search\ISearchOrder; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use PHPUnit\Framework\MockObject\MockObject; /** @@ -292,7 +292,7 @@ class FolderTest extends NodeTest { $root->method('getUser') ->willReturn($this->user); /** @var Storage\IStorage&MockObject $storage */ - $storage = $this->createMock(Storage\IStorage::class); + $storage = $this->createMock(IStorage::class); $storage->method('getId')->willReturn('test::1'); $cache = new Cache($storage); @@ -341,7 +341,7 @@ class FolderTest extends NodeTest { ->method('getUser') ->willReturn($this->user); /** @var \PHPUnit\Framework\MockObject\MockObject|Storage $storage */ - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('getId')->willReturn('test::2'); $cache = new Cache($storage); @@ -379,7 +379,7 @@ class FolderTest extends NodeTest { ->getMock(); $root->method('getUser') ->willReturn($this->user); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('getId')->willReturn('test::1'); $cache = new Cache($storage); @@ -420,10 +420,10 @@ class FolderTest extends NodeTest { $root->expects($this->any()) ->method('getUser') ->willReturn($this->user); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('getId')->willReturn('test::1'); $cache = new Cache($storage); - $subStorage = $this->createMock(Storage::class); + $subStorage = $this->createMock(IStorage::class); $subStorage->method('getId')->willReturn('test::2'); $subCache = new Cache($subStorage); $subMount = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock(); @@ -922,14 +922,14 @@ class FolderTest extends NodeTest { $root->expects($this->any()) ->method('getUser') ->willReturn($this->user); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('getId')->willReturn('test::1'); $cache = new Cache($storage); - $subStorage1 = $this->createMock(Storage::class); + $subStorage1 = $this->createMock(IStorage::class); $subStorage1->method('getId')->willReturn('test::2'); $subCache1 = new Cache($subStorage1); $subMount1 = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock(); - $subStorage2 = $this->createMock(Storage::class); + $subStorage2 = $this->createMock(IStorage::class); $subStorage2->method('getId')->willReturn('test::3'); $subCache2 = new Cache($subStorage2); $subMount2 = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock(); diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index d12448a2481..db87aa925d3 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -16,7 +16,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountPoint; use OCP\Files\Node; use OCP\Files\NotFoundException; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\ICacheFactory; use OCP\IUser; use OCP\IUserManager; @@ -111,7 +111,7 @@ abstract class NodeTest extends \Test\TestCase { abstract protected function getViewDeleteMethod(); protected function getMockStorage() { - $storage = $this->getMockBuilder(Storage::class) + $storage = $this->getMockBuilder(IStorage::class) ->disableOriginalConstructor() ->getMock(); $storage->expects($this->any()) diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php index 5b0bbf2f95b..36d70965848 100644 --- a/tests/lib/Files/Storage/Storage.php +++ b/tests/lib/Files/Storage/Storage.php @@ -8,6 +8,7 @@ namespace Test\Files\Storage; use OC\Files\Cache\Watcher; +use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IWriteStreamStorage; abstract class Storage extends \Test\TestCase { @@ -572,7 +573,7 @@ abstract class Storage extends \Test\TestCase { } public function testInstanceOfStorage(): void { - $this->assertTrue($this->instance->instanceOfStorage('\OCP\Files\Storage')); + $this->assertTrue($this->instance->instanceOfStorage(IStorage::class)); $this->assertTrue($this->instance->instanceOfStorage(get_class($this->instance))); $this->assertFalse($this->instance->instanceOfStorage('\OC')); } diff --git a/tests/lib/Files/Storage/StorageFactoryTest.php b/tests/lib/Files/Storage/StorageFactoryTest.php index 66f2a2af9a6..d1e8d927dc9 100644 --- a/tests/lib/Files/Storage/StorageFactoryTest.php +++ b/tests/lib/Files/Storage/StorageFactoryTest.php @@ -10,7 +10,7 @@ namespace Test\Files\Storage; use OC\Files\Mount\MountPoint; use OC\Files\Storage\Wrapper\Wrapper; use OCP\Files\Mount\IMountPoint; -use OCP\Files\Storage as IStorage; +use OCP\Files\Storage\IStorage; use Test\TestCase; class DummyWrapper extends Wrapper { diff --git a/tests/lib/Lockdown/Filesystem/NullStorageTest.php b/tests/lib/Lockdown/Filesystem/NullStorageTest.php index 331adeb8a54..cc65221d0a3 100644 --- a/tests/lib/Lockdown/Filesystem/NullStorageTest.php +++ b/tests/lib/Lockdown/Filesystem/NullStorageTest.php @@ -11,7 +11,7 @@ use OC\Files\FileInfo; use OC\ForbiddenException; use OC\Lockdown\Filesystem\NullCache; use OC\Lockdown\Filesystem\NullStorage; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use Test\TestCase; class NullStorageTest extends TestCase { @@ -196,7 +196,7 @@ class NullStorageTest extends TestCase { } public function testCopyFromStorage(): void { - $sourceStorage = $this->createMock(Storage::class); + $sourceStorage = $this->createMock(IStorage::class); $this->expectException(ForbiddenException::class); $this->expectExceptionMessage('This request is not allowed to access the filesystem'); @@ -205,7 +205,7 @@ class NullStorageTest extends TestCase { } public function testMoveFromStorage(): void { - $sourceStorage = $this->createMock(Storage::class); + $sourceStorage = $this->createMock(IStorage::class); $this->expectException(ForbiddenException::class); $this->expectExceptionMessage('This request is not allowed to access the filesystem'); diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 2250e28bd13..d0c43b2862c 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -23,7 +23,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\Files\Mount\IMountPoint; use OCP\Files\Node; -use OCP\Files\Storage; +use OCP\Files\Storage\IStorage; use OCP\HintException; use OCP\IConfig; use OCP\IDateTimeZone; @@ -631,7 +631,7 @@ class ManagerTest extends \Test\TestCase { $file = $this->createMock(File::class); $node = $this->createMock(Node::class); - $storage = $this->createMock(Storage\IStorage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->with('\OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -706,7 +706,7 @@ class ManagerTest extends \Test\TestCase { $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Cannot increase permissions of path', true]; $data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Cannot increase permissions of path', true]; - $nonMovableStorage = $this->createMock(Storage\IStorage::class); + $nonMovableStorage = $this->createMock(IStorage::class); $nonMovableStorage->method('instanceOfStorage') ->with('\OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -752,7 +752,7 @@ class ManagerTest extends \Test\TestCase { $data[] = [$this->createShare(null, IShare::TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false]; - $remoteStorage = $this->createMock(Storage\IStorage::class); + $remoteStorage = $this->createMock(IStorage::class); $remoteStorage->method('instanceOfStorage') ->with('\OCA\Files_Sharing\External\Storage') ->willReturn(true); @@ -2059,7 +2059,7 @@ class ManagerTest extends \Test\TestCase { $path->method('getPath')->willReturn('path'); $mount = $this->createMock(IMountPoint::class); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $mount->method('getStorage')->willReturn($storage); $storage->method('instanceOfStorage')->with('\OCA\Files_Sharing\ISharedStorage')->willReturn(true); @@ -2073,7 +2073,7 @@ class ManagerTest extends \Test\TestCase { $path->method('getPath')->willReturn('path'); $mount = $this->createMock(IMountPoint::class); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $mount->method('getStorage')->willReturn($storage); $storage->method('instanceOfStorage')->with('\OCA\Files_Sharing\ISharedStorage')->willReturn(false); @@ -2221,7 +2221,7 @@ class ManagerTest extends \Test\TestCase { $shareOwner = $this->createMock(IUser::class); $shareOwner->method('getUID')->willReturn('shareOwner'); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $path = $this->createMock(File::class); $path->method('getOwner')->willReturn($shareOwner); $path->method('getName')->willReturn('target'); @@ -2276,7 +2276,7 @@ class ManagerTest extends \Test\TestCase { $shareOwner = $this->createMock(IUser::class); $shareOwner->method('getUID')->willReturn('shareOwner'); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $path = $this->createMock(File::class); $path->method('getOwner')->willReturn($shareOwner); $path->method('getName')->willReturn('target'); @@ -2339,7 +2339,7 @@ class ManagerTest extends \Test\TestCase { $shareOwner = $this->createMock(IUser::class); $shareOwner->method('getUID')->willReturn('shareOwner'); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $path = $this->createMock(File::class); $path->method('getOwner')->willReturn($shareOwner); $path->method('getName')->willReturn('target'); @@ -2459,7 +2459,7 @@ class ManagerTest extends \Test\TestCase { $shareOwner = $this->createMock(IUser::class); $shareOwner->method('getUID')->willReturn('shareOwner'); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $path = $this->createMock(File::class); $path->method('getOwner')->willReturn($shareOwner); $path->method('getName')->willReturn('target'); @@ -2563,7 +2563,7 @@ class ManagerTest extends \Test\TestCase { $shareOwner = $this->createMock(IUser::class); $shareOwner->method('getUID')->willReturn('shareOwner'); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $path = $this->createMock(File::class); $path->method('getOwner')->willReturn($shareOwner); $path->method('getName')->willReturn('target'); @@ -2623,12 +2623,12 @@ class ManagerTest extends \Test\TestCase { $shareOwner = $this->createMock(IUser::class); $shareOwner->method('getUID')->willReturn('shareOwner'); - $storage = $this->createMock(Storage::class); + $storage = $this->createMock(IStorage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(true); - $storage2 = $this->createMock(Storage::class); + $storage2 = $this->createMock(IStorage::class); $storage2->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); |