summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-26 09:30:18 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-26 16:34:56 +0100
commitb80ebc96748b45fd2e0ba9323308657c4b00b7ec (patch)
treeec20e0ffa2f86b9b54939a83a785407319f94559 /apps/files
parent62403d0932be7d620c7bdadc6b4e13eb496fcd6f (diff)
downloadnextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.tar.gz
nextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.zip
Use the short array syntax, everywhere
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/ajax/download.php4
-rw-r--r--apps/files/ajax/list.php20
-rw-r--r--apps/files/appinfo/app.php2
-rw-r--r--apps/files/lib/AppInfo/Application.php2
-rw-r--r--apps/files/lib/Command/Scan.php2
-rw-r--r--apps/files/lib/Controller/ViewController.php2
-rw-r--r--apps/files/lib/Helper.php8
-rw-r--r--apps/files/lib/Service/TagService.php2
-rw-r--r--apps/files/templates/appnavigation.php2
-rw-r--r--apps/files/tests/HelperTest.php50
-rw-r--r--apps/files/tests/Service/TagServiceTest.php20
11 files changed, 57 insertions, 57 deletions
diff --git a/apps/files/ajax/download.php b/apps/files/ajax/download.php
index 5b29175a83c..d5ea0f634f2 100644
--- a/apps/files/ajax/download.php
+++ b/apps/files/ajax/download.php
@@ -38,7 +38,7 @@ $dir = isset($_GET['dir']) ? (string)$_GET['dir'] : '';
$files_list = json_decode($files);
// in case we get only a single file
if (!is_array($files_list)) {
- $files_list = array($files);
+ $files_list = [$files];
}
/**
@@ -52,7 +52,7 @@ if(isset($_GET['downloadStartSecret'])
setcookie('ocDownloadStarted', $_GET['downloadStartSecret'], time() + 20, '/');
}
-$server_params = array( 'head' => \OC::$server->getRequest()->getMethod() === 'HEAD' );
+$server_params = [ 'head' => \OC::$server->getRequest()->getMethod() === 'HEAD' ];
/**
* Http range requests support
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 0b66ed10897..8cbe5841aaf 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -43,7 +43,7 @@ try {
exit();
}
- $data = array();
+ $data = [];
$baseUrl = \OC::$server->getURLGenerator()->linkTo('files', 'index.php') . '?dir=';
$permissions = $dirInfo->getPermissions();
@@ -80,7 +80,7 @@ try {
$data['files'] = \OCA\Files\Helper::formatFileInfos($files);
$data['permissions'] = $permissions;
- \OC_JSON::success(array('data' => $data));
+ \OC_JSON::success(['data' => $data]);
} catch (\OCP\Files\StorageNotAvailableException $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files']);
\OC_JSON::error([
@@ -91,18 +91,18 @@ try {
]);
} catch (\OCP\Files\StorageInvalidException $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files']);
- \OC_JSON::error(array(
- 'data' => array(
+ \OC_JSON::error([
+ 'data' => [
'exception' => StorageInvalidException::class,
'message' => $l->t('Storage invalid')
- )
- ));
+ ]
+ ]);
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, ['app' => 'files']);
- \OC_JSON::error(array(
- 'data' => array(
+ \OC_JSON::error([
+ 'data' => [
'exception' => \Exception::class,
'message' => $l->t('Unknown error')
- )
- ));
+ ]
+ ]);
}
diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php
index 35e46c0c151..bb98613377c 100644
--- a/apps/files/appinfo/app.php
+++ b/apps/files/appinfo/app.php
@@ -36,7 +36,7 @@ $app = \OC::$server->query(Application::class);
// t('Files')
$l = \OC::$server->getL10N('files');
-\OC::$server->getSearch()->registerProvider(File::class, array('apps' => array('files')));
+\OC::$server->getSearch()->registerProvider(File::class, ['apps' => ['files']]);
$templateManager = \OC_Helper::getFileTemplateManager();
$templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');
diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php
index 8bda6329d29..b043cfeb6ac 100644
--- a/apps/files/lib/AppInfo/Application.php
+++ b/apps/files/lib/AppInfo/Application.php
@@ -50,7 +50,7 @@ class Application extends App {
public const APP_ID = 'files';
- public function __construct(array $urlParams=array()) {
+ public function __construct(array $urlParams=[]) {
parent::__construct(self::APP_ID, $urlParams);
$container = $this->getContainer();
$server = $container->getServer();
diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php
index 39eebbb2c43..38d4b1cc979 100644
--- a/apps/files/lib/Command/Scan.php
+++ b/apps/files/lib/Command/Scan.php
@@ -174,7 +174,7 @@ class Scan extends Base {
if ($inputPath) {
$inputPath = '/' . trim($inputPath, '/');
list (, $user,) = explode('/', $inputPath, 3);
- $users = array($user);
+ $users = [$user];
} else if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 70b878f43ad..7c5d2a08b88 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -200,7 +200,7 @@ class ViewController extends Controller {
$collapseClasses = 'collapsible';
}
- $favoritesSublistArray = Array();
+ $favoritesSublistArray = [];
$navBarPositionPosition = 6;
$currentCount = 0;
diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php
index f88689af266..c46d3028553 100644
--- a/apps/files/lib/Helper.php
+++ b/apps/files/lib/Helper.php
@@ -51,7 +51,7 @@ class Helper {
$l = \OC::$server->getL10N('files');
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
- $maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
+ $maxHumanFileSize = $l->t('Upload (max. %s)', [$maxHumanFileSize]);
return [
'uploadMaxFilesize' => $maxUploadFileSize,
@@ -140,7 +140,7 @@ class Helper {
* @return array formatted file info
*/
public static function formatFileInfo(FileInfo $i) {
- $entry = array();
+ $entry = [];
$entry['id'] = $i['fileid'];
$entry['parentId'] = $i['parent'];
@@ -182,7 +182,7 @@ class Helper {
* @return array
*/
public static function formatFileInfos($fileInfos) {
- $files = array();
+ $files = [];
foreach ($fileInfos as $i) {
$files[] = self::formatFileInfo($i);
}
@@ -262,7 +262,7 @@ class Helper {
} else if ($sortAttribute === 'size') {
$sortFunc = 'compareSize';
}
- usort($files, array(Helper::class, $sortFunc));
+ usort($files, [Helper::class, $sortFunc]);
if ($sortDescending) {
$files = array_reverse($files);
}
diff --git a/apps/files/lib/Service/TagService.php b/apps/files/lib/Service/TagService.php
index a477db324ac..5df00ae5c5f 100644
--- a/apps/files/lib/Service/TagService.php
+++ b/apps/files/lib/Service/TagService.php
@@ -83,7 +83,7 @@ class TagService {
public function updateFileTags($path, $tags) {
$fileId = $this->homeFolder->get($path)->getId();
- $currentTags = $this->tagger->getTagsForObjects(array($fileId));
+ $currentTags = $this->tagger->getTagsForObjects([$fileId]);
if (!empty($currentTags)) {
$currentTags = current($currentTags);
diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php
index b14617f0ca3..9d6227c86b3 100644
--- a/apps/files/templates/appnavigation.php
+++ b/apps/files/templates/appnavigation.php
@@ -47,7 +47,7 @@ script(\OCA\Files\AppInfo\Application::APP_ID, 'dist/files-app-settings');
<label for="webdavurl"><?php p($l->t('WebDAV')); ?></label>
<input id="webdavurl" type="text" readonly="readonly"
value="<?php p($_['webdav_url']); ?>"/>
- <em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer noopener">access your Files via WebDAV</a>', array(link_to_docs('user-webdav')))); ?></em>
+ <em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer noopener">access your Files via WebDAV</a>', [link_to_docs('user-webdav')])); ?></em>
</div>
</div>
diff --git a/apps/files/tests/HelperTest.php b/apps/files/tests/HelperTest.php
index b756386a2bf..8dda7be5a19 100644
--- a/apps/files/tests/HelperTest.php
+++ b/apps/files/tests/HelperTest.php
@@ -37,13 +37,13 @@ class HelperTest extends \Test\TestCase {
'/' . $name,
null,
'/',
- array(
+ [
'name' => $name,
'size' => $size,
'mtime' => $mtime,
'type' => $isDir ? 'dir' : 'file',
'mimetype' => $isDir ? 'httpd/unix-directory' : 'application/octet-stream'
- ),
+ ],
null
);
}
@@ -52,49 +52,49 @@ class HelperTest extends \Test\TestCase {
* Returns a file list for testing
*/
private function getTestFileList() {
- return array(
+ return [
self::makeFileInfo('a.txt', 4, 2.3 * pow(10, 9)),
self::makeFileInfo('q.txt', 5, 150),
self::makeFileInfo('subdir2', 87, 128, true),
self::makeFileInfo('b.txt', 2.2 * pow(10, 9), 800),
self::makeFileInfo('o.txt', 12, 100),
self::makeFileInfo('subdir', 88, 125, true),
- );
+ ];
}
function sortDataProvider() {
- return array(
- array(
+ return [
+ [
'name',
false,
- array('subdir', 'subdir2', 'a.txt', 'b.txt', 'o.txt', 'q.txt'),
- ),
- array(
+ ['subdir', 'subdir2', 'a.txt', 'b.txt', 'o.txt', 'q.txt'],
+ ],
+ [
'name',
true,
- array('q.txt', 'o.txt', 'b.txt', 'a.txt', 'subdir2', 'subdir'),
- ),
- array(
+ ['q.txt', 'o.txt', 'b.txt', 'a.txt', 'subdir2', 'subdir'],
+ ],
+ [
'size',
false,
- array('a.txt', 'q.txt', 'o.txt', 'subdir2', 'subdir', 'b.txt'),
- ),
- array(
+ ['a.txt', 'q.txt', 'o.txt', 'subdir2', 'subdir', 'b.txt'],
+ ],
+ [
'size',
true,
- array('b.txt', 'subdir', 'subdir2', 'o.txt', 'q.txt', 'a.txt'),
- ),
- array(
+ ['b.txt', 'subdir', 'subdir2', 'o.txt', 'q.txt', 'a.txt'],
+ ],
+ [
'mtime',
false,
- array('o.txt', 'subdir', 'subdir2', 'q.txt', 'b.txt', 'a.txt'),
- ),
- array(
+ ['o.txt', 'subdir', 'subdir2', 'q.txt', 'b.txt', 'a.txt'],
+ ],
+ [
'mtime',
true,
- array('a.txt', 'b.txt', 'q.txt', 'subdir2', 'subdir', 'o.txt'),
- ),
- );
+ ['a.txt', 'b.txt', 'q.txt', 'subdir2', 'subdir', 'o.txt'],
+ ],
+ ];
}
/**
@@ -103,7 +103,7 @@ class HelperTest extends \Test\TestCase {
public function testSortByName($sort, $sortDescending, $expectedOrder) {
$files = self::getTestFileList();
$files = \OCA\Files\Helper::sortFiles($files, $sort, $sortDescending);
- $fileNames = array();
+ $fileNames = [];
foreach ($files as $fileInfo) {
$fileNames[] = $fileInfo->getName();
}
diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php
index bc7c803953b..a2792a38647 100644
--- a/apps/files/tests/Service/TagServiceTest.php
+++ b/apps/files/tests/Service/TagServiceTest.php
@@ -132,25 +132,25 @@ class TagServiceTest extends \Test\TestCase {
$fileId = $testFile->getId();
// set tags
- $this->tagService->updateFileTags('subdir/test.txt', array($tag1, $tag2));
+ $this->tagService->updateFileTags('subdir/test.txt', [$tag1, $tag2]);
- $this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag1));
- $this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag2));
+ $this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag1));
+ $this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag2));
// remove tag
- $this->tagService->updateFileTags('subdir/test.txt', array($tag2));
- $this->assertEquals(array(), $this->tagger->getIdsForTag($tag1));
- $this->assertEquals(array($fileId), $this->tagger->getIdsForTag($tag2));
+ $this->tagService->updateFileTags('subdir/test.txt', [$tag2]);
+ $this->assertEquals([], $this->tagger->getIdsForTag($tag1));
+ $this->assertEquals([$fileId], $this->tagger->getIdsForTag($tag2));
// clear tags
- $this->tagService->updateFileTags('subdir/test.txt', array());
- $this->assertEquals(array(), $this->tagger->getIdsForTag($tag1));
- $this->assertEquals(array(), $this->tagger->getIdsForTag($tag2));
+ $this->tagService->updateFileTags('subdir/test.txt', []);
+ $this->assertEquals([], $this->tagger->getIdsForTag($tag1));
+ $this->assertEquals([], $this->tagger->getIdsForTag($tag2));
// non-existing file
$caught = false;
try {
- $this->tagService->updateFileTags('subdir/unexist.txt', array($tag1));
+ $this->tagService->updateFileTags('subdir/unexist.txt', [$tag1]);
} catch (\OCP\Files\NotFoundException $e) {
$caught = true;
}