Skip to content

Commit 3953b18

Browse files
committed
cleanup: cleanup to match coding standards
1 parent 9daf98d commit 3953b18

33 files changed

+216
-216
lines changed

classes/local/object_manipulator/candidates/deleter_candidates.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function get_candidates_sql_params() {
5757
return [
5858
'consistancythreshold' => $consistancythreshold,
5959
'location' => OBJECT_LOCATION_DUPLICATED,
60-
'sizethreshold' => $this->config->sizethreshold
60+
'sizethreshold' => $this->config->sizethreshold,
6161
];
6262
}
6363
}

classes/local/object_manipulator/candidates/orphaner_candidates.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function get_candidates_sql() {
5353
*/
5454
public function get_candidates_sql_params() {
5555
return [
56-
'location' => OBJECT_LOCATION_ORPHANED
56+
'location' => OBJECT_LOCATION_ORPHANED,
5757
];
5858
}
5959
}

classes/local/object_manipulator/manipulator_builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class manipulator_builder {
4848
pusher::class,
4949
recoverer::class,
5050
checker::class,
51-
orphaner::class
51+
orphaner::class,
5252
];
5353

5454
/** @var string $manipulatorclass */

classes/local/report/location_report_builder.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function build_report($reportid) {
4747
OBJECT_LOCATION_DUPLICATED,
4848
OBJECT_LOCATION_EXTERNAL,
4949
OBJECT_LOCATION_ORPHANED,
50-
OBJECT_LOCATION_ERROR
50+
OBJECT_LOCATION_ERROR,
5151
];
5252

5353
$totalcount = 0;
@@ -71,7 +71,7 @@ public function build_report($reportid) {
7171

7272
if ($location !== OBJECT_LOCATION_ORPHANED) {
7373
// Process the query normally.
74-
$result = $DB->get_record_sql($sql, array($location));
74+
$result = $DB->get_record_sql($sql, [$location]);
7575
} else if ($location === OBJECT_LOCATION_ORPHANED) {
7676
// Start the query from objectfs, for ORPHANED objects, they are not located in the files table.
7777
$sql = 'SELECT COALESCE(count(sub.contenthash) ,0) AS objectcount
@@ -80,7 +80,7 @@ public function build_report($reportid) {
8080
LEFT JOIN {files} f on f.contenthash = o.contenthash
8181
GROUP BY o.contenthash, f.filesize, o.location
8282
HAVING o.location = ?' . $localsql .') AS sub';
83-
$result = $DB->get_record_sql($sql, array($location));
83+
$result = $DB->get_record_sql($sql, [$location]);
8484
$result->objectsum = 0;
8585
}
8686

classes/local/report/object_location_history_table.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ public function __construct() {
8282
public function query_db($pagesize, $useinitialsbar = true) {
8383
global $DB;
8484
$fields = 'CONCAT(reportid, datakey) AS uid, datakey AS location, objectcount AS count, objectsum AS size';
85-
$conditions = array('reporttype' => 'location');
85+
$conditions = ['reporttype' => 'location'];
8686
$rawrecords = $DB->get_records('tool_objectfs_report_data', $conditions, 'reportid', $fields);
8787
$reports = objectfs_report::get_report_ids();
8888

8989
// Used to fallback to when the expected record is not there.
9090
// NOTE: This avoids the need to null coalesce on a non-existing count/size.
9191
$emptyrecord = (object)[
9292
'count' => 0,
93-
'size' => 0
93+
'size' => 0,
9494
];
9595
foreach ($reports as $id => $timecreated) {
9696
// Initialises the records to be used, and fallback to an empty one if not found.

classes/local/report/object_status_history_table.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function query_db($pagesize, $useinitialsbar = true) {
102102
default:
103103
$sort = 'heading ASC';
104104
}
105-
$params = array('reporttype' => $this->reporttype, 'reportid' => $this->reportid);
105+
$params = ['reporttype' => $this->reporttype, 'reportid' => $this->reportid];
106106
$fields = 'datakey AS heading, objectcount AS count, objectsum AS size';
107107
$rows = $DB->get_records('tool_objectfs_report_data', $params, $sort, $fields);
108108
$this->rawdata = $rows;
@@ -196,7 +196,7 @@ public function add_barchart($value, $max, $type, $precision = 0) {
196196
if ($max > 0) {
197197
$share = round(100 * $value / $max, $precision);
198198
}
199-
$htmlparams = array('class' => 'ofs-bar', 'style' => 'width:'.$share.'%');
199+
$htmlparams = ['class' => 'ofs-bar', 'style' => 'width:'.$share.'%'];
200200

201201
switch ($type) {
202202
case 'count':

classes/local/report/objectfs_report.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static function generate_status_report() {
150150
public static function cleanup_reports() {
151151
global $DB;
152152
$reportdate = time() - YEARSECS;
153-
$params = array('reportdate' => $reportdate);
153+
$params = ['reportdate' => $reportdate];
154154
$reports = $DB->get_records_select('tool_objectfs_reports', 'reportdate < :reportdate', $params, 'id', 'id');
155155
$reportids = array_keys($reports);
156156
$DB->delete_records_list('tool_objectfs_reports', 'id', $reportids);
@@ -177,7 +177,7 @@ public static function get_report_types() {
177177
*/
178178
public static function get_report_ids() {
179179
global $DB;
180-
$reports = array();
180+
$reports = [];
181181
$records = $DB->get_records('tool_objectfs_reports', null, 'id DESC', 'id, reportdate');
182182
foreach ($records as $record) {
183183
$reports[$record->id] = $record->reportdate;

classes/local/store/azure/client.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ public function get_relative_path_from_fullpath($fullpath) {
149149
* @return resource
150150
*/
151151
public function get_seekable_stream_context() {
152-
$context = stream_context_create(array(
153-
'blob' => array(
154-
'seekable' => true
155-
)
156-
));
152+
$context = stream_context_create([
153+
'blob' => [
154+
'seekable' => true,
155+
],
156+
]);
157157
return $context;
158158
}
159159

@@ -259,7 +259,7 @@ public function test_connection() {
259259
public function test_permissions($testdelete) {
260260
$permissions = new \stdClass();
261261
$permissions->success = true;
262-
$permissions->messages = array();
262+
$permissions->messages = [];
263263

264264
try {
265265
$result = $this->client->createBlockBlob($this->container, 'permissions_check_file', 'permissions_check_file');

classes/local/store/digitalocean/client.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ public function set_client($config) {
7777
return;
7878
}
7979

80-
$this->client = \Aws\S3\S3Client::factory(array(
81-
'credentials' => array('key' => $config->do_key, 'secret' => $config->do_secret),
80+
$this->client = \Aws\S3\S3Client::factory([
81+
'credentials' => ['key' => $config->do_key, 'secret' => $config->do_secret],
8282
'region' => $config->do_region,
8383
'endpoint' => 'https://' . $config->do_region . '.digitaloceanspaces.com',
84-
'version' => AWS_API_VERSION
85-
));
84+
'version' => AWS_API_VERSION,
85+
]);
8686
}
8787

8888
/**
@@ -93,13 +93,13 @@ public function set_client($config) {
9393
*/
9494
public function define_client_section($settings, $config) {
9595

96-
$regionoptions = array(
96+
$regionoptions = [
9797
'sfo2' => 'sfo2 (San Fransisco)',
9898
'nyc3' => 'nyc3 (New York City)',
9999
'ams3' => 'ams3 (Amsterdam)',
100100
'sgp1' => 'spg1 (Singapore)',
101101
'fra1' => 'fra1 (Frankfurt)',
102-
);
102+
];
103103

104104
$settings->add(new \admin_setting_heading('tool_objectfs/do',
105105
new \lang_string('settings:do:header', 'tool_objectfs'), ''));

classes/local/store/object_client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function verify_object($contenthash, $localpath);
9898
*
9999
* @return mixed
100100
*/
101-
public function generate_presigned_url($contenthash, $headers = array());
101+
public function generate_presigned_url($contenthash, $headers = []);
102102

103103
/**
104104
* support_presigned_urls

classes/local/store/object_client_base.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function support_presigned_urls() {
103103
*
104104
* @throws \coding_exception
105105
*/
106-
public function generate_presigned_url($contenthash, $headers = array()) {
106+
public function generate_presigned_url($contenthash, $headers = []) {
107107
throw new \coding_exception("Pre-signed URLs not supported");
108108
}
109109

classes/local/store/object_file_system.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public function delete_empty_dirs($rootpath = '') {
470470
$pathinfo['filename'],
471471
$pathinfo['basename'],
472472
$pathinfo['filename'],
473-
$pathinfo['basename']
473+
$pathinfo['basename'],
474474
]);
475475

476476
if (!$exists) {
@@ -844,7 +844,7 @@ protected function copy_from_external_to_local($contenthash) {
844844
* @return bool
845845
* @throws \dml_exception
846846
*/
847-
public function redirect_to_presigned_url($contenthash, $headers = array()) {
847+
public function redirect_to_presigned_url($contenthash, $headers = []) {
848848
global $FULLME;
849849
try {
850850
$signedurl = $this->externalclient->generate_presigned_url($contenthash, $headers);
@@ -926,7 +926,7 @@ public function presigned_url_should_redirect_file($file) {
926926
* @return bool
927927
* @throws \dml_exception
928928
*/
929-
public function presigned_url_should_redirect($contenthash, $headers = array()) {
929+
public function presigned_url_should_redirect($contenthash, $headers = []) {
930930
// Redirect regardless.
931931
if ($this->externalclient->presignedminfilesize == 0 &&
932932
manager::all_extensions_whitelisted()) {

classes/local/store/s3/client.php

+30-30
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function __construct($config) {
9191
* @return array
9292
*/
9393
public function __sleep() {
94-
return array('bucket');
94+
return ['bucket'];
9595
}
9696

9797
/**
@@ -150,17 +150,17 @@ public function set_client($config) {
150150
return;
151151
}
152152

153-
$options = array(
153+
$options = [
154154
'region' => $config->s3_region,
155-
'version' => AWS_API_VERSION
156-
);
155+
'version' => AWS_API_VERSION,
156+
];
157157

158158
if (empty($config->s3_usesdkcreds)) {
159-
$options['credentials'] = array('key' => $config->s3_key, 'secret' => $config->s3_secret);
159+
$options['credentials'] = ['key' => $config->s3_key, 'secret' => $config->s3_secret];
160160
}
161161

162162
if ($config->useproxy) {
163-
$options['http'] = array('proxy' => $this->get_proxy_string());
163+
$options['http'] = ['proxy' => $this->get_proxy_string()];
164164
}
165165

166166
// Support base_url config for aws api compatible endpoints.
@@ -196,9 +196,9 @@ private function get_md5_from_hash($contenthash) {
196196

197197
try {
198198
$key = $this->get_filepath_from_hash($contenthash);
199-
$result = $this->client->headObject(array(
199+
$result = $this->client->headObject([
200200
'Bucket' => $this->bucket,
201-
'Key' => $this->bucketkeyprefix . $key));
201+
'Key' => $this->bucketkeyprefix . $key]);
202202
} catch (\Aws\S3\Exception\S3Exception $e) {
203203
return false;
204204
}
@@ -265,11 +265,11 @@ public function rename_file($currentpath, $destinationpath) {
265265
* @return mixed
266266
*/
267267
public function get_seekable_stream_context() {
268-
$context = stream_context_create(array(
269-
's3' => array(
270-
'seekable' => true
271-
)
272-
));
268+
$context = stream_context_create([
269+
's3' => [
270+
'seekable' => true,
271+
],
272+
]);
273273
return $context;
274274
}
275275

@@ -303,7 +303,7 @@ public function test_connection() {
303303
$connection->success = false;
304304
$connection->details = get_string('settings:notconfigured', 'tool_objectfs');
305305
} else {
306-
$this->client->headBucket(array('Bucket' => $this->bucket));
306+
$this->client->headBucket(['Bucket' => $this->bucket]);
307307
}
308308
} catch (\Aws\S3\Exception\S3Exception $e) {
309309
$connection->success = false;
@@ -331,29 +331,29 @@ public function test_connection() {
331331
public function test_permissions($testdelete) {
332332
$permissions = new \stdClass();
333333
$permissions->success = true;
334-
$permissions->messages = array();
334+
$permissions->messages = [];
335335

336336
if ($this->is_functional()) {
337337
$permissions->success = false;
338-
$permissions->messages = array();
338+
$permissions->messages = [];
339339
return $permissions;
340340
}
341341

342342
try {
343-
$result = $this->client->putObject(array(
343+
$result = $this->client->putObject([
344344
'Bucket' => $this->bucket,
345345
'Key' => $this->bucketkeyprefix . 'permissions_check_file',
346-
'Body' => 'test content'));
346+
'Body' => 'test content']);
347347
} catch (\Aws\S3\Exception\S3Exception $e) {
348348
$details = $this->get_exception_details($e);
349349
$permissions->messages[get_string('settings:writefailure', 'tool_objectfs') . $details] = 'notifyproblem';
350350
$permissions->success = false;
351351
}
352352

353353
try {
354-
$result = $this->client->getObject(array(
354+
$result = $this->client->getObject([
355355
'Bucket' => $this->bucket,
356-
'Key' => $this->bucketkeyprefix . 'permissions_check_file'));
356+
'Key' => $this->bucketkeyprefix . 'permissions_check_file']);
357357
} catch (\Aws\S3\Exception\S3Exception $e) {
358358
$errorcode = $e->getAwsErrorCode();
359359
// Write could have failed.
@@ -368,7 +368,7 @@ public function test_permissions($testdelete) {
368368
try {
369369
$result = $this->client->deleteObject([
370370
'Bucket' => $this->bucket,
371-
'Key' => $this->bucketkeyprefix . 'permissions_check_file'
371+
'Key' => $this->bucketkeyprefix . 'permissions_check_file',
372372
]);
373373
$permissions->messages[get_string('settings:deletesuccess', 'tool_objectfs')] = 'warning';
374374
$permissions->success = false;
@@ -536,7 +536,7 @@ public function support_presigned_urls() {
536536
* @return signed_url
537537
* @throws \Exception
538538
*/
539-
public function generate_presigned_url($contenthash, $headers = array()) {
539+
public function generate_presigned_url($contenthash, $headers = []) {
540540
if ('cf' === $this->signingmethod) {
541541
return $this->generate_presigned_url_cloudfront($contenthash, $headers);
542542
}
@@ -825,18 +825,18 @@ public function curl_range_request_to_presigned_url($contenthash, $ranges, $head
825825
} catch (\Exception $e) {
826826
throw new \coding_exception('Failed to generate pre-signed url: ' . $e->getMessage());
827827
}
828-
$headers = array(
828+
$headers = [
829829
'Range: bytes=' . $ranges->rangefrom . '-' . $ranges->rangeto,
830-
);
830+
];
831831
$curl = new \curl();
832-
$curl->setopt(array('CURLOPT_HTTP_VERSION' => CURL_HTTP_VERSION_1_1));
833-
$curl->setopt(array('CURLOPT_RETURNTRANSFER' => true));
834-
$curl->setopt(array('CURLOPT_SSL_VERIFYPEER' => false));
835-
$curl->setopt(array('CURLOPT_CONNECTTIMEOUT' => 15));
836-
$curl->setopt(array('CURLOPT_TIMEOUT' => 15));
832+
$curl->setopt(['CURLOPT_HTTP_VERSION' => CURL_HTTP_VERSION_1_1]);
833+
$curl->setopt(['CURLOPT_RETURNTRANSFER' => true]);
834+
$curl->setopt(['CURLOPT_SSL_VERIFYPEER' => false]);
835+
$curl->setopt(['CURLOPT_CONNECTTIMEOUT' => 15]);
836+
$curl->setopt(['CURLOPT_TIMEOUT' => 15]);
837837
$curl->setHeader($headers);
838838
$content = $curl->get($url);
839-
return array('responseheaders' => $curl->getResponse(), 'content' => $content, 'url' => $url);
839+
return ['responseheaders' => $curl->getResponse(), 'content' => $content, 'url' => $url];
840840
}
841841

842842
/**

classes/local/store/swift/client.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private function get_endpoint() {
7070
'password' => $this->config->openstack_password,
7171
'domain' => ['id' => 'default'],
7272
],
73-
'scope' => ['project' => ['id' => $this->config->openstack_projectid]]
73+
'scope' => ['project' => ['id' => $this->config->openstack_projectid]],
7474
];
7575

7676
if (!isset($this->config->openstack_authtoken['expires_at'])
@@ -179,7 +179,7 @@ public function get_seekable_stream_context() {
179179
'endpoint' => $this->config->openstack_authurl,
180180
'region' => $this->config->openstack_region,
181181
'cachedtoken' => $this->config->openstack_authtoken,
182-
]
182+
],
183183
]);
184184
return $context;
185185
}
@@ -288,7 +288,7 @@ public function test_connection() {
288288
public function test_permissions($testdelete) {
289289
$permissions = new \stdClass();
290290
$permissions->success = true;
291-
$permissions->messages = array();
291+
$permissions->messages = [];
292292

293293
$container = $this->get_container();
294294

0 commit comments

Comments
 (0)