Skip to content

Commit 0de4843

Browse files
committed
refactor(Storage): Align all Storage constructors
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 74cd6e2 commit 0de4843

34 files changed

+166
-167
lines changed

apps/dav/lib/Storage/PublicOwnerWrapper.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class PublicOwnerWrapper extends Wrapper {
1515
private string $owner;
1616

1717
/**
18-
* @param array $arguments ['storage' => $storage, 'owner' => $owner]
18+
* @param array $parameters ['storage' => $storage, 'owner' => $owner]
1919
*
2020
* $storage: The storage the permissions mask should be applied on
2121
* $owner: The owner to use in case no owner is found
2222
*/
23-
public function __construct($arguments) {
24-
parent::__construct($arguments);
25-
$this->owner = $arguments['owner'];
23+
public function __construct(array $parameters) {
24+
parent::__construct($parameters);
25+
$this->owner = $parameters['owner'];
2626
}
2727

2828
public function getOwner(string $path): string|false {

apps/dav/lib/Storage/PublicShareWrapper.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ class PublicShareWrapper extends Wrapper implements ISharedStorage {
1717
private IShare $share;
1818

1919
/**
20-
* @param array $arguments ['storage' => $storage, 'share' => $share]
20+
* @param array $parameters ['storage' => $storage, 'share' => $share]
2121
*
2222
* $storage: The storage the permissions mask should be applied on
2323
* $share: The share to use in case no share is found
2424
*/
25-
public function __construct($arguments) {
26-
parent::__construct($arguments);
27-
$this->share = $arguments['share'];
25+
public function __construct(array $parameters) {
26+
parent::__construct($parameters);
27+
$this->share = $parameters['share'];
2828
}
2929

3030
public function getShare(): IShare {

apps/files_external/lib/Lib/SessionStorageWrapper.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
* Wrap Storage in PermissionsMask for session ephemeral use
1414
*/
1515
class SessionStorageWrapper extends PermissionsMask {
16-
1716
/**
18-
* @param array $arguments ['storage' => $storage]
17+
* @param array $parameters ['storage' => $storage]
1918
*/
20-
public function __construct($arguments) {
19+
public function __construct(array $parameters) {
2120
// disable sharing permission
22-
$arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE;
23-
parent::__construct($arguments);
21+
$parameters['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE;
22+
parent::__construct($parameters);
2423
}
2524
}

apps/files_external/lib/Lib/Storage/AmazonS3.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function needsPartFile(): bool {
4646
private ?bool $versioningEnabled = null;
4747
private ICache $memCache;
4848

49-
public function __construct($parameters) {
49+
public function __construct(array $parameters) {
5050
parent::__construct($parameters);
5151
$this->parseParams($parameters);
5252
$this->id = 'amazon::external::' . md5($this->params['hostname'] . ':' . $this->params['bucket'] . ':' . $this->params['key']);

apps/files_external/lib/Lib/Storage/FTP.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ class FTP extends Common {
2929
/** @var FtpConnection|null */
3030
private $connection;
3131

32-
public function __construct($params) {
33-
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
34-
$this->host = $params['host'];
35-
$this->username = $params['user'];
36-
$this->password = $params['password'];
37-
if (isset($params['secure'])) {
38-
if (is_string($params['secure'])) {
39-
$this->secure = ($params['secure'] === 'true');
32+
public function __construct(array $parameters) {
33+
if (isset($parameters['host']) && isset($parameters['user']) && isset($parameters['password'])) {
34+
$this->host = $parameters['host'];
35+
$this->username = $parameters['user'];
36+
$this->password = $parameters['password'];
37+
if (isset($parameters['secure'])) {
38+
if (is_string($parameters['secure'])) {
39+
$this->secure = ($parameters['secure'] === 'true');
4040
} else {
41-
$this->secure = (bool)$params['secure'];
41+
$this->secure = (bool)$parameters['secure'];
4242
}
4343
} else {
4444
$this->secure = false;
4545
}
46-
$this->root = isset($params['root']) ? '/' . ltrim($params['root']) : '/';
47-
$this->port = $params['port'] ?? 21;
48-
$this->utf8Mode = isset($params['utf8']) && $params['utf8'];
46+
$this->root = isset($parameters['root']) ? '/' . ltrim($parameters['root']) : '/';
47+
$this->port = $parameters['port'] ?? 21;
48+
$this->utf8Mode = isset($parameters['utf8']) && $parameters['utf8'];
4949
} else {
5050
throw new \Exception('Creating ' . self::class . ' storage failed, required parameters not set');
5151
}

apps/files_external/lib/Lib/Storage/OwnCloud.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
class OwnCloud extends DAV implements IDisableEncryptionStorage {
2121
public const OC_URL_SUFFIX = 'remote.php/webdav';
2222

23-
public function __construct($params) {
23+
public function __construct(array $parameters) {
2424
// extract context path from host if specified
2525
// (owncloud install path on host)
26-
$host = $params['host'];
26+
$host = $parameters['host'];
2727
// strip protocol
2828
if (substr($host, 0, 8) === 'https://') {
2929
$host = substr($host, 8);
30-
$params['secure'] = true;
30+
$parameters['secure'] = true;
3131
} elseif (substr($host, 0, 7) === 'http://') {
3232
$host = substr($host, 7);
33-
$params['secure'] = false;
33+
$parameters['secure'] = false;
3434
}
3535
$contextPath = '';
3636
$hostSlashPos = strpos($host, '/');
@@ -43,17 +43,17 @@ public function __construct($params) {
4343
$contextPath .= '/';
4444
}
4545

46-
if (isset($params['root'])) {
47-
$root = '/' . ltrim($params['root'], '/');
46+
if (isset($parameters['root'])) {
47+
$root = '/' . ltrim($parameters['root'], '/');
4848
} else {
4949
$root = '/';
5050
}
5151

52-
$params['host'] = $host;
53-
$params['root'] = $contextPath . self::OC_URL_SUFFIX . $root;
54-
$params['authType'] = Client::AUTH_BASIC;
52+
$parameters['host'] = $host;
53+
$parameters['root'] = $contextPath . self::OC_URL_SUFFIX . $root;
54+
$parameters['authType'] = Client::AUTH_BASIC;
5555

56-
parent::__construct($params);
56+
parent::__construct($parameters);
5757
}
5858

5959
public function needsPartFile(): bool {

apps/files_external/lib/Lib/Storage/SFTP.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,33 @@ private function splitHost(string $host): array {
5757
}
5858
}
5959

60-
public function __construct($params) {
60+
public function __construct(array $parameters) {
6161
// Register sftp://
6262
Stream::register();
6363

64-
$parsedHost = $this->splitHost($params['host']);
64+
$parsedHost = $this->splitHost($parameters['host']);
6565

6666
$this->host = $parsedHost[0];
6767
$this->port = $parsedHost[1];
6868

69-
if (!isset($params['user'])) {
69+
if (!isset($parameters['user'])) {
7070
throw new \UnexpectedValueException('no authentication parameters specified');
7171
}
72-
$this->user = $params['user'];
72+
$this->user = $parameters['user'];
7373

74-
if (isset($params['public_key_auth'])) {
75-
$this->auth[] = $params['public_key_auth'];
74+
if (isset($parameters['public_key_auth'])) {
75+
$this->auth[] = $parameters['public_key_auth'];
7676
}
77-
if (isset($params['password']) && $params['password'] !== '') {
78-
$this->auth[] = $params['password'];
77+
if (isset($parameters['password']) && $parameters['password'] !== '') {
78+
$this->auth[] = $parameters['password'];
7979
}
8080

8181
if ($this->auth === []) {
8282
throw new \UnexpectedValueException('no authentication parameters specified');
8383
}
8484

8585
$this->root
86-
= isset($params['root']) ? $this->cleanPath($params['root']) : '/';
86+
= isset($parameters['root']) ? $this->cleanPath($parameters['root']) : '/';
8787

8888
$this->root = '/' . ltrim($this->root, '/');
8989
$this->root = rtrim($this->root, '/') . '/';

apps/files_external/lib/Lib/Storage/SMB.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -69,55 +69,55 @@ class SMB extends Common implements INotifyStorage {
6969
/** @var bool */
7070
protected $checkAcl;
7171

72-
public function __construct($params) {
73-
if (!isset($params['host'])) {
72+
public function __construct(array $parameters) {
73+
if (!isset($parameters['host'])) {
7474
throw new \Exception('Invalid configuration, no host provided');
7575
}
7676

77-
if (isset($params['auth'])) {
78-
$auth = $params['auth'];
79-
} elseif (isset($params['user']) && isset($params['password']) && isset($params['share'])) {
80-
[$workgroup, $user] = $this->splitUser($params['user']);
81-
$auth = new BasicAuth($user, $workgroup, $params['password']);
77+
if (isset($parameters['auth'])) {
78+
$auth = $parameters['auth'];
79+
} elseif (isset($parameters['user']) && isset($parameters['password']) && isset($parameters['share'])) {
80+
[$workgroup, $user] = $this->splitUser($parameters['user']);
81+
$auth = new BasicAuth($user, $workgroup, $parameters['password']);
8282
} else {
8383
throw new \Exception('Invalid configuration, no credentials provided');
8484
}
8585

86-
if (isset($params['logger'])) {
87-
if (!$params['logger'] instanceof LoggerInterface) {
86+
if (isset($parameters['logger'])) {
87+
if (!$parameters['logger'] instanceof LoggerInterface) {
8888
throw new \Exception(
8989
'Invalid logger. Got '
90-
. get_class($params['logger'])
90+
. get_class($parameters['logger'])
9191
. ' Expected ' . LoggerInterface::class
9292
);
9393
}
94-
$this->logger = $params['logger'];
94+
$this->logger = $parameters['logger'];
9595
} else {
9696
$this->logger = \OCP\Server::get(LoggerInterface::class);
9797
}
9898

9999
$options = new Options();
100-
if (isset($params['timeout'])) {
101-
$timeout = (int)$params['timeout'];
100+
if (isset($parameters['timeout'])) {
101+
$timeout = (int)$parameters['timeout'];
102102
if ($timeout > 0) {
103103
$options->setTimeout($timeout);
104104
}
105105
}
106106
$system = \OCP\Server::get(SystemBridge::class);
107107
$serverFactory = new ServerFactory($options, $system);
108-
$this->server = $serverFactory->createServer($params['host'], $auth);
109-
$this->share = $this->server->getShare(trim($params['share'], '/'));
108+
$this->server = $serverFactory->createServer($parameters['host'], $auth);
109+
$this->share = $this->server->getShare(trim($parameters['share'], '/'));
110110

111-
$this->root = $params['root'] ?? '/';
111+
$this->root = $parameters['root'] ?? '/';
112112
$this->root = '/' . ltrim($this->root, '/');
113113
$this->root = rtrim($this->root, '/') . '/';
114114

115-
$this->showHidden = isset($params['show_hidden']) && $params['show_hidden'];
116-
$this->caseSensitive = (bool)($params['case_sensitive'] ?? true);
117-
$this->checkAcl = isset($params['check_acl']) && $params['check_acl'];
115+
$this->showHidden = isset($parameters['show_hidden']) && $parameters['show_hidden'];
116+
$this->caseSensitive = (bool)($parameters['case_sensitive'] ?? true);
117+
$this->checkAcl = isset($parameters['check_acl']) && $parameters['check_acl'];
118118

119119
$this->statCache = new CappedMemoryCache();
120-
parent::__construct($params);
120+
parent::__construct($parameters);
121121
}
122122

123123
private function splitUser(string $user): array {

apps/files_external/lib/Lib/Storage/Swift.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -122,44 +122,44 @@ private function doesObjectExist(string $path): bool {
122122
return $this->fetchObject($path) !== false;
123123
}
124124

125-
public function __construct($params) {
126-
if ((empty($params['key']) and empty($params['password']))
127-
or (empty($params['user']) && empty($params['userid'])) or empty($params['bucket'])
128-
or empty($params['region'])
125+
public function __construct(array $parameters) {
126+
if ((empty($parameters['key']) and empty($parameters['password']))
127+
or (empty($parameters['user']) && empty($parameters['userid'])) or empty($parameters['bucket'])
128+
or empty($parameters['region'])
129129
) {
130130
throw new StorageBadConfigException('API Key or password, Login, Bucket and Region have to be configured.');
131131
}
132132

133-
$user = $params['user'];
134-
$this->id = 'swift::' . $user . md5($params['bucket']);
133+
$user = $parameters['user'];
134+
$this->id = 'swift::' . $user . md5($parameters['bucket']);
135135

136-
$bucketUrl = new Uri($params['bucket']);
136+
$bucketUrl = new Uri($parameters['bucket']);
137137
if ($bucketUrl->getHost()) {
138-
$params['bucket'] = basename($bucketUrl->getPath());
139-
$params['endpoint_url'] = (string)$bucketUrl->withPath(dirname($bucketUrl->getPath()));
138+
$parameters['bucket'] = basename($bucketUrl->getPath());
139+
$parameters['endpoint_url'] = (string)$bucketUrl->withPath(dirname($bucketUrl->getPath()));
140140
}
141141

142-
if (empty($params['url'])) {
143-
$params['url'] = 'https://identity.api.rackspacecloud.com/v2.0/';
142+
if (empty($parameters['url'])) {
143+
$parameters['url'] = 'https://identity.api.rackspacecloud.com/v2.0/';
144144
}
145145

146-
if (empty($params['service_name'])) {
147-
$params['service_name'] = 'cloudFiles';
146+
if (empty($parameters['service_name'])) {
147+
$parameters['service_name'] = 'cloudFiles';
148148
}
149149

150-
$params['autocreate'] = true;
150+
$parameters['autocreate'] = true;
151151

152-
if (isset($params['domain'])) {
153-
$params['user'] = [
154-
'name' => $params['user'],
155-
'password' => $params['password'],
152+
if (isset($parameters['domain'])) {
153+
$parameters['user'] = [
154+
'name' => $parameters['user'],
155+
'password' => $parameters['password'],
156156
'domain' => [
157-
'name' => $params['domain'],
157+
'name' => $parameters['domain'],
158158
]
159159
];
160160
}
161161

162-
$this->params = $params;
162+
$this->params = $parameters;
163163
// FIXME: private class...
164164
$this->objectCache = new CappedMemoryCache();
165165
$this->connectionFactory = new SwiftFactory(
@@ -168,7 +168,7 @@ public function __construct($params) {
168168
\OC::$server->get(LoggerInterface::class)
169169
);
170170
$this->objectStore = new \OC\Files\ObjectStore\Swift($this->params, $this->connectionFactory);
171-
$this->bucket = $params['bucket'];
171+
$this->bucket = $parameters['bucket'];
172172
$this->mimeDetector = \OC::$server->get(IMimeTypeDetector::class);
173173
}
174174

apps/files_sharing/lib/SharedStorage.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
8989
*/
9090
protected $storage;
9191

92-
public function __construct($arguments) {
93-
$this->ownerView = $arguments['ownerView'];
92+
public function __construct(array $parameters) {
93+
$this->ownerView = $parameters['ownerView'];
9494
$this->logger = \OC::$server->get(LoggerInterface::class);
9595

96-
$this->superShare = $arguments['superShare'];
97-
$this->groupedShares = $arguments['groupedShares'];
96+
$this->superShare = $parameters['superShare'];
97+
$this->groupedShares = $parameters['groupedShares'];
9898

99-
$this->user = $arguments['user'];
100-
if (isset($arguments['sharingDisabledForUser'])) {
101-
$this->sharingDisabledForUser = $arguments['sharingDisabledForUser'];
99+
$this->user = $parameters['user'];
100+
if (isset($parameters['sharingDisabledForUser'])) {
101+
$this->sharingDisabledForUser = $parameters['sharingDisabledForUser'];
102102
} else {
103103
$this->sharingDisabledForUser = false;
104104
}

lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage {
1212
private string $internalId;
1313

1414
/**
15-
* @param array $params
15+
* @param array $parameters
1616
* @throws \Exception
1717
*/
18-
public function __construct($params) {
19-
if (!isset($params['internal-id'])) {
18+
public function __construct(array $parameters) {
19+
if (!isset($parameters['internal-id'])) {
2020
throw new \Exception('missing id in parameters');
2121
}
22-
$this->internalId = (string)$params['internal-id'];
23-
parent::__construct($params);
22+
$this->internalId = (string)$parameters['internal-id'];
23+
parent::__construct($parameters);
2424
}
2525

2626
public function getId(): string {

lib/private/Files/ObjectStore/Azure.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Azure implements IObjectStore {
2727
/**
2828
* @param array $parameters
2929
*/
30-
public function __construct($parameters) {
30+
public function __construct(array $parameters) {
3131
$this->containerName = $parameters['container'];
3232
$this->accountName = $parameters['account_name'];
3333
$this->accountKey = $parameters['account_key'];

0 commit comments

Comments
 (0)