Skip to content

Commit d0cc583

Browse files
committed
Minor: Format code
1 parent aa417d2 commit d0cc583

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

main/inc/ajax/document.ajax.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
switch ($action) {
1111
case 'get_dir_size':
1212
api_protect_course_script(true);
13-
$path = isset($_GET['path']) ? $_GET['path'] : '';
13+
$path = $_GET['path'] ?? '';
1414
$isAllowedToEdit = api_is_allowed_to_edit();
1515
$size = DocumentManager::getTotalFolderSize($path, $isAllowedToEdit);
1616
echo format_file_size($size);
1717
break;
1818
case 'get_dirs_size':
1919
api_protect_course_script(true);
20-
$requests = isset($_GET['requests']) ? $_GET['requests'] : '';
20+
$requests = $_GET['requests'] ?? '';
2121
$isAllowedToEdit = api_is_allowed_to_edit();
2222
$response = [];
2323
$requests = explode(',', $requests);
@@ -27,7 +27,7 @@
2727
'id' => $request,
2828
'size' => format_file_size($fileSize),
2929
];
30-
array_push($response, $data);
30+
$response[] = $data;
3131
}
3232
echo json_encode($response);
3333
break;
@@ -114,7 +114,7 @@
114114
$directoryParentId = isset($_POST['directory_parent_id']) ? (int) $_POST['directory_parent_id'] : 0;
115115
$currentDirectory = '';
116116
if (empty($directoryParentId)) {
117-
$currentDirectory = isset($_REQUEST['curdirpath']) ? $_REQUEST['curdirpath'] : '';
117+
$currentDirectory = $_REQUEST['curdirpath'] ?? '';
118118
} else {
119119
$documentData = DocumentManager::get_document_data_by_id($directoryParentId, api_get_course_id());
120120
if ($documentData) {
@@ -124,7 +124,7 @@
124124
if (empty($currentDirectory)) {
125125
$currentDirectory = DIRECTORY_SEPARATOR;
126126
}
127-
$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : '';
127+
$ifExists = $_POST['if_exists'] ?? '';
128128
$unzip = isset($_POST['unzip']) ? 1 : 0;
129129

130130
if (empty($ifExists)) {
@@ -189,7 +189,7 @@
189189
get_lang('Uploaded')
190190
);
191191
} else {
192-
$json['name'] = isset($file['name']) ? $file['name'] : get_lang('Unknown');
192+
$json['name'] = $file['name'] ?? get_lang('Unknown');
193193
$json['url'] = '';
194194
$json['error'] = get_lang('Error');
195195
}
@@ -275,7 +275,7 @@
275275
break;
276276
case 'document_destination':
277277
//obtained the bootstrap-select selected value via ajax
278-
$dirValue = isset($_POST['dirValue']) ? $_POST['dirValue'] : null;
278+
$dirValue = $_POST['dirValue'] ?? null;
279279
echo Security::remove_XSS($dirValue);
280280
break;
281281
}

main/inc/lib/fileUpload.lib.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -739,17 +739,11 @@ function handle_uploaded_document(
739739
}
740740
}
741741

742-
/**
743-
* @param string $file
744-
* @param string $storePath
745-
*
746-
* @return bool
747-
*/
748-
function moveUploadedFile($file, $storePath)
742+
function moveUploadedFile(array $file, string $storePath): bool
749743
{
750-
$handleFromFile = isset($file['from_file']) && $file['from_file'] ? true : false;
751-
$moveFile = isset($file['move_file']) && $file['move_file'] ? true : false;
752-
$copyFile = isset($file['copy_file']) && $file['copy_file'] ? true : false;
744+
$handleFromFile = isset($file['from_file']) && $file['from_file'];
745+
$moveFile = isset($file['move_file']) && $file['move_file'];
746+
$copyFile = isset($file['copy_file']) && $file['copy_file'];
753747
if ($moveFile) {
754748
$copied = copy($file['tmp_name'], $storePath);
755749

0 commit comments

Comments
 (0)