diff options
author | Kate <26026535+provokateurin@users.noreply.github.com> | 2024-10-28 10:19:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-28 10:19:41 +0100 |
commit | 5efb175665a71ac32fb6a6d5a141c72d12e8534c (patch) | |
tree | f27662fc76503cce1e1b0fc551db3b125396ecd7 /lib/private/Files | |
parent | 2eaa9f79b4fbc76b062d9f2bd1f5cfffb2143f57 (diff) | |
parent | 0de4843b73ee4779c7e455dd80c36a6b506e0024 (diff) | |
download | nextcloud-server-5efb175665a71ac32fb6a6d5a141c72d12e8534c.tar.gz nextcloud-server-5efb175665a71ac32fb6a6d5a141c72d12e8534c.zip |
Merge pull request #48614 from nextcloud/refactor/storage/constructors
Diffstat (limited to 'lib/private/Files')
20 files changed, 67 insertions, 67 deletions
diff --git a/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php b/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php index 66fa74172d3..aaaee044bac 100644 --- a/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php @@ -12,15 +12,15 @@ class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage { private string $internalId; /** - * @param array $params + * @param array $parameters * @throws \Exception */ - public function __construct($params) { - if (!isset($params['internal-id'])) { + public function __construct(array $parameters) { + if (!isset($parameters['internal-id'])) { throw new \Exception('missing id in parameters'); } - $this->internalId = (string)$params['internal-id']; - parent::__construct($params); + $this->internalId = (string)$parameters['internal-id']; + parent::__construct($parameters); } public function getId(): string { diff --git a/lib/private/Files/ObjectStore/Azure.php b/lib/private/Files/ObjectStore/Azure.php index 2dacdac1f8d..575cc336ba8 100644 --- a/lib/private/Files/ObjectStore/Azure.php +++ b/lib/private/Files/ObjectStore/Azure.php @@ -27,7 +27,7 @@ class Azure implements IObjectStore { /** * @param array $parameters */ - public function __construct($parameters) { + public function __construct(array $parameters) { $this->containerName = $parameters['container']; $this->accountName = $parameters['account_name']; $this->accountKey = $parameters['account_key']; diff --git a/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php b/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php index eb95c0b4bf7..4e2d10705fe 100644 --- a/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php @@ -17,15 +17,15 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage /** * The home user storage requires a user object to create a unique storage id * - * @param array $params + * @param array $parameters * @throws Exception */ - public function __construct($params) { - if (! isset($params['user']) || ! $params['user'] instanceof IUser) { + public function __construct(array $parameters) { + if (! isset($parameters['user']) || ! $parameters['user'] instanceof IUser) { throw new Exception('missing user object in parameters'); } - $this->user = $params['user']; - parent::__construct($params); + $this->user = $parameters['user']; + parent::__construct($parameters); } public function getId(): string { diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index b07b6955b1a..0963ffbb28f 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -41,27 +41,27 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil private bool $preserveCacheItemsOnDelete = false; /** - * @param array $params + * @param array $parameters * @throws \Exception */ - public function __construct($params) { - if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) { - $this->objectStore = $params['objectstore']; + public function __construct(array $parameters) { + if (isset($parameters['objectstore']) && $parameters['objectstore'] instanceof IObjectStore) { + $this->objectStore = $parameters['objectstore']; } else { throw new \Exception('missing IObjectStore instance'); } - if (isset($params['storageid'])) { - $this->id = 'object::store:' . $params['storageid']; + if (isset($parameters['storageid'])) { + $this->id = 'object::store:' . $parameters['storageid']; } else { $this->id = 'object::store:' . $this->objectStore->getStorageId(); } - if (isset($params['objectPrefix'])) { - $this->objectPrefix = $params['objectPrefix']; + if (isset($parameters['objectPrefix'])) { + $this->objectPrefix = $parameters['objectPrefix']; } - if (isset($params['validateWrites'])) { - $this->validateWrites = (bool)$params['validateWrites']; + if (isset($parameters['validateWrites'])) { + $this->validateWrites = (bool)$parameters['validateWrites']; } - $this->handleCopiesAsOwned = (bool)($params['handleCopiesAsOwned'] ?? false); + $this->handleCopiesAsOwned = (bool)($parameters['handleCopiesAsOwned'] ?? false); $this->logger = \OCP\Server::get(LoggerInterface::class); } diff --git a/lib/private/Files/ObjectStore/S3.php b/lib/private/Files/ObjectStore/S3.php index 72c19d951e4..41ab75caf45 100644 --- a/lib/private/Files/ObjectStore/S3.php +++ b/lib/private/Files/ObjectStore/S3.php @@ -14,7 +14,7 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload { use S3ConnectionTrait; use S3ObjectTrait; - public function __construct($parameters) { + public function __construct(array $parameters) { $parameters['primary_storage'] = true; $this->parseParams($parameters); } diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 6006c477440..334ca34294e 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -65,7 +65,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, private ?LoggerInterface $logger = null; private ?IFilenameValidator $filenameValidator = null; - public function __construct($parameters) { + public function __construct(array $parameters) { } protected function remove(string $path): bool { diff --git a/lib/private/Files/Storage/CommonTest.php b/lib/private/Files/Storage/CommonTest.php index bf61dfaec86..da796130899 100644 --- a/lib/private/Files/Storage/CommonTest.php +++ b/lib/private/Files/Storage/CommonTest.php @@ -14,8 +14,8 @@ class CommonTest extends \OC\Files\Storage\Common { */ private $storage; - public function __construct($params) { - $this->storage = new \OC\Files\Storage\Local($params); + public function __construct(array $parameters) { + $this->storage = new \OC\Files\Storage\Local($parameters); } public function getId(): string { diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index e0f7700415f..b849a69246f 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -83,14 +83,14 @@ class DAV extends Common { ]; /** - * @param array $params + * @param array $parameters * @throws \Exception */ - public function __construct($params) { + public function __construct(array $parameters) { $this->statCache = new ArrayCache(); $this->httpClientService = Server::get(IClientService::class); - if (isset($params['host']) && isset($params['user']) && isset($params['password'])) { - $host = $params['host']; + if (isset($parameters['host']) && isset($parameters['user']) && isset($parameters['password'])) { + $host = $parameters['host']; //remove leading http[s], will be generated in createBaseUri() if (str_starts_with($host, 'https://')) { $host = substr($host, 8); @@ -98,16 +98,16 @@ class DAV extends Common { $host = substr($host, 7); } $this->host = $host; - $this->user = $params['user']; - $this->password = $params['password']; - if (isset($params['authType'])) { - $this->authType = $params['authType']; + $this->user = $parameters['user']; + $this->password = $parameters['password']; + if (isset($parameters['authType'])) { + $this->authType = $parameters['authType']; } - if (isset($params['secure'])) { - if (is_string($params['secure'])) { - $this->secure = ($params['secure'] === 'true'); + if (isset($parameters['secure'])) { + if (is_string($parameters['secure'])) { + $this->secure = ($parameters['secure'] === 'true'); } else { - $this->secure = (bool)$params['secure']; + $this->secure = (bool)$parameters['secure']; } } else { $this->secure = false; @@ -116,7 +116,7 @@ class DAV extends Common { // inject mock for testing $this->certManager = \OC::$server->getCertificateManager(); } - $this->root = $params['root'] ?? '/'; + $this->root = $parameters['root'] ?? '/'; $this->root = '/' . ltrim($this->root, '/'); $this->root = rtrim($this->root, '/') . '/'; } else { diff --git a/lib/private/Files/Storage/FailedStorage.php b/lib/private/Files/Storage/FailedStorage.php index 1c91a775525..a8288de48d0 100644 --- a/lib/private/Files/Storage/FailedStorage.php +++ b/lib/private/Files/Storage/FailedStorage.php @@ -20,10 +20,10 @@ class FailedStorage extends Common { protected $e; /** - * @param array $params ['exception' => \Exception] + * @param array $parameters ['exception' => \Exception] */ - public function __construct($params) { - $this->e = $params['exception']; + public function __construct(array $parameters) { + $this->e = $parameters['exception']; if (!$this->e) { throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor'); } diff --git a/lib/private/Files/Storage/Home.php b/lib/private/Files/Storage/Home.php index 5280cb26ff3..91b8071ac30 100644 --- a/lib/private/Files/Storage/Home.php +++ b/lib/private/Files/Storage/Home.php @@ -30,11 +30,11 @@ class Home extends Local implements \OCP\Files\IHomeStorage { /** * Construct a Home storage instance * - * @param array $arguments array with "user" containing the - * storage owner + * @param array $parameters array with "user" containing the + * storage owner */ - public function __construct($arguments) { - $this->user = $arguments['user']; + public function __construct(array $parameters) { + $this->user = $parameters['user']; $datadir = $this->user->getHome(); $this->id = 'home::' . $this->user->getUID(); diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 9e3ec663f03..0b0272ce717 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -40,11 +40,11 @@ class Local extends \OC\Files\Storage\Common { protected bool $caseInsensitive = false; - public function __construct($arguments) { - if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) { + public function __construct(array $parameters) { + if (!isset($parameters['datadir']) || !is_string($parameters['datadir'])) { throw new \InvalidArgumentException('No data directory set for local storage'); } - $this->datadir = str_replace('//', '/', $arguments['datadir']); + $this->datadir = str_replace('//', '/', $parameters['datadir']); // some crazy code uses a local storage on root... if ($this->datadir === '/') { $this->realDataDir = $this->datadir; @@ -64,7 +64,7 @@ class Local extends \OC\Files\Storage\Common { // support Write-Once-Read-Many file systems $this->unlinkOnTruncate = $this->config->getSystemValueBool('localstorage.unlink_on_truncate', false); - if (isset($arguments['isExternal']) && $arguments['isExternal'] && !$this->stat('')) { + if (isset($parameters['isExternal']) && $parameters['isExternal'] && !$this->stat('')) { // data dir not accessible or available, can happen when using an external storage of type Local // on an unmounted system mount point throw new StorageNotAvailableException('Local storage path does not exist "' . $this->getSourcePath('') . '"'); diff --git a/lib/private/Files/Storage/Temporary.php b/lib/private/Files/Storage/Temporary.php index 429f0fd1e92..ff7a816930d 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 = []) { + public function __construct(array $parameters = []) { parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]); } diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php index ffe8f08e40f..70212cacab8 100644 --- a/lib/private/Files/Storage/Wrapper/Availability.php +++ b/lib/private/Files/Storage/Wrapper/Availability.php @@ -23,7 +23,7 @@ class Availability extends Wrapper { /** @var IConfig */ protected $config; - public function __construct($parameters) { + public function __construct(array $parameters) { $this->config = $parameters['config'] ?? \OC::$server->getConfig(); parent::__construct($parameters); } diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index 02b70e5ae60..d5afbad9592 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -28,7 +28,7 @@ class Encoding extends Wrapper { /** * @param array $parameters */ - public function __construct($parameters) { + public function __construct(array $parameters) { $this->storage = $parameters['storage']; $this->namesCache = new CappedMemoryCache(); } diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index a29e985377b..c9ed9c7cb53 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -42,7 +42,7 @@ class Encryption extends Wrapper { * @param array $parameters */ public function __construct( - $parameters, + array $parameters, private IManager $encryptionManager, private Util $util, private LoggerInterface $logger, diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index a85f59b87eb..c8db0e94e59 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -30,14 +30,14 @@ class Jail extends Wrapper { protected $rootPath; /** - * @param array $arguments ['storage' => $storage, 'root' => $root] + * @param array $parameters ['storage' => $storage, 'root' => $root] * * $storage: The storage that will be wrapper * $root: The folder in the wrapped storage that will become the root folder of the wrapped storage */ - public function __construct($arguments) { - parent::__construct($arguments); - $this->rootPath = $arguments['root']; + public function __construct(array $parameters) { + parent::__construct($parameters); + $this->rootPath = $parameters['root']; } public function getUnjailedPath(string $path): string { diff --git a/lib/private/Files/Storage/Wrapper/KnownMtime.php b/lib/private/Files/Storage/Wrapper/KnownMtime.php index 37454bdad17..657c6c9250c 100644 --- a/lib/private/Files/Storage/Wrapper/KnownMtime.php +++ b/lib/private/Files/Storage/Wrapper/KnownMtime.php @@ -20,10 +20,10 @@ class KnownMtime extends Wrapper { private CappedMemoryCache $knowMtimes; private ClockInterface $clock; - public function __construct($arguments) { - parent::__construct($arguments); + public function __construct(array $parameters) { + parent::__construct($parameters); $this->knowMtimes = new CappedMemoryCache(); - $this->clock = $arguments['clock']; + $this->clock = $parameters['clock']; } public function file_put_contents(string $path, mixed $data): int|float|false { diff --git a/lib/private/Files/Storage/Wrapper/PermissionsMask.php b/lib/private/Files/Storage/Wrapper/PermissionsMask.php index aed37bc27ba..684040146ba 100644 --- a/lib/private/Files/Storage/Wrapper/PermissionsMask.php +++ b/lib/private/Files/Storage/Wrapper/PermissionsMask.php @@ -25,14 +25,14 @@ class PermissionsMask extends Wrapper { private $mask; /** - * @param array $arguments ['storage' => $storage, 'mask' => $mask] + * @param array $parameters ['storage' => $storage, 'mask' => $mask] * * $storage: The storage the permissions mask should be applied on * $mask: The permission bits that should be kept, a combination of the \OCP\Constant::PERMISSION_ constants */ - public function __construct($arguments) { - parent::__construct($arguments); - $this->mask = $arguments['mask']; + public function __construct(array $parameters) { + parent::__construct($parameters); + $this->mask = $parameters['mask']; } private function checkMask(int $permissions): bool { diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php index 3fd46c76d21..3be77ba1b37 100644 --- a/lib/private/Files/Storage/Wrapper/Quota.php +++ b/lib/private/Files/Storage/Wrapper/Quota.php @@ -25,7 +25,7 @@ class Quota extends Wrapper { /** * @param array $parameters */ - public function __construct($parameters) { + public function __construct(array $parameters) { parent::__construct($parameters); $this->quota = $parameters['quota'] ?? null; $this->quotaCallback = $parameters['quotaCallback'] ?? null; diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index e1edbab95c6..6dea439fe25 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -36,7 +36,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea /** * @param array $parameters */ - public function __construct($parameters) { + public function __construct(array $parameters) { $this->storage = $parameters['storage']; } |