diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-26 09:30:18 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-26 16:34:56 +0100 |
commit | b80ebc96748b45fd2e0ba9323308657c4b00b7ec (patch) | |
tree | ec20e0ffa2f86b9b54939a83a785407319f94559 /apps/files_trashbin | |
parent | 62403d0932be7d620c7bdadc6b4e13eb496fcd6f (diff) | |
download | nextcloud-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_trashbin')
-rw-r--r-- | apps/files_trashbin/lib/Helper.php | 8 | ||||
-rw-r--r-- | apps/files_trashbin/lib/Trashbin.php | 44 | ||||
-rw-r--r-- | apps/files_trashbin/tests/Command/CleanUpTest.php | 12 | ||||
-rw-r--r-- | apps/files_trashbin/tests/StorageTest.php | 16 | ||||
-rw-r--r-- | apps/files_trashbin/tests/TrashbinTest.php | 4 |
5 files changed, 42 insertions, 42 deletions
diff --git a/apps/files_trashbin/lib/Helper.php b/apps/files_trashbin/lib/Helper.php index 343734f882a..3cc096decbb 100644 --- a/apps/files_trashbin/lib/Helper.php +++ b/apps/files_trashbin/lib/Helper.php @@ -46,7 +46,7 @@ class Helper { * @return \OCP\Files\FileInfo[] */ public static function getTrashFiles($dir, $user, $sortAttribute = '', $sortDescending = false) { - $result = array(); + $result = []; $timestamp = null; $view = new \OC\Files\View('/' . $user . '/files_trashbin/files'); @@ -84,7 +84,7 @@ class Helper { } } $type = $entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE ? 'dir' : 'file'; - $i = array( + $i = [ 'name' => $name, 'mtime' => $timestamp, 'mimetype' => $type === 'dir' ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($name), @@ -94,7 +94,7 @@ class Helper { 'etag' => '', 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE, 'fileid' => $entry->getId(), - ); + ]; if ($originalPath) { if ($originalPath !== '.') { $i['extraData'] = $originalPath . '/' . $originalName; @@ -117,7 +117,7 @@ class Helper { * @param \OCP\Files\FileInfo[] $fileInfos file infos */ public static function formatFileInfos($fileInfos) { - $files = array(); + $files = []; foreach ($fileInfos as $i) { $entry = \OCA\Files\Helper::formatFileInfo($i); $entry['id'] = $i->getId(); diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 8e94a215400..0f1787223a2 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -122,13 +122,13 @@ class Trashbin { public static function getLocations($user) { $query = \OC_DB::prepare('SELECT `id`, `timestamp`, `location`' . ' FROM `*PREFIX*files_trash` WHERE `user`=?'); - $result = $query->execute(array($user)); - $array = array(); + $result = $query->execute([$user]); + $array = []; while ($row = $result->fetchRow()) { if (isset($array[$row['id']])) { $array[$row['id']][$row['timestamp']] = $row['location']; } else { - $array[$row['id']] = array($row['timestamp'] => $row['location']); + $array[$row['id']] = [$row['timestamp'] => $row['location']]; } } return $array; @@ -145,7 +145,7 @@ class Trashbin { public static function getLocation($user, $filename, $timestamp) { $query = \OC_DB::prepare('SELECT `location` FROM `*PREFIX*files_trash`' . ' WHERE `user`=? AND `id`=? AND `timestamp`=?'); - $result = $query->execute(array($user, $filename, $timestamp))->fetchAll(); + $result = $query->execute([$user, $filename, $timestamp])->fetchAll(); if (isset($result[0]['location'])) { return $result[0]['location']; } else { @@ -201,7 +201,7 @@ class Trashbin { if ($view->file_exists($target)) { $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)"); - $result = $query->execute(array($targetFilename, $timestamp, $targetLocation, $user)); + $result = $query->execute([$targetFilename, $timestamp, $targetLocation, $user]); if (!$result) { \OC::$server->getLogger()->error('trash bin database couldn\'t be updated for the files owner', ['app' => 'files_trashbin']); } @@ -281,12 +281,12 @@ class Trashbin { if ($moveSuccessful) { $query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)"); - $result = $query->execute(array($filename, $timestamp, $location, $owner)); + $result = $query->execute([$filename, $timestamp, $location, $owner]); if (!$result) { \OC::$server->getLogger()->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); } - \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', array('filePath' => Filesystem::normalizePath($file_path), - 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp))); + \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path), + 'trashPath' => Filesystem::normalizePath($filename . '.d' . $timestamp)]); self::retainVersions($filename, $owner, $ownerPath, $timestamp); @@ -433,14 +433,14 @@ class Trashbin { $view->chroot('/' . $user . '/files'); $view->touch('/' . $location . '/' . $uniqueFilename, $mtime); $view->chroot($fakeRoot); - \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', array('filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename), - 'trashPath' => Filesystem::normalizePath($file))); + \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename), + 'trashPath' => Filesystem::normalizePath($file)]); self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp); if ($timestamp) { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?'); - $query->execute(array($user, $filename, $timestamp)); + $query->execute([$user, $filename, $timestamp]); } return true; @@ -512,14 +512,14 @@ class Trashbin { } // Array to store the relative path in (after the file is deleted, the view won't be able to relativise the path anymore) - $filePaths = array(); + $filePaths = []; foreach($fileInfos as $fileInfo){ $filePaths[] = $view->getRelativePath($fileInfo->getPath()); } unset($fileInfos); // save memory // Bulk PreDelete-Hook - \OC_Hook::emit('\OCP\Trashbin', 'preDeleteAll', array('paths' => $filePaths)); + \OC_Hook::emit('\OCP\Trashbin', 'preDeleteAll', ['paths' => $filePaths]); // Single-File Hooks foreach($filePaths as $path){ @@ -529,10 +529,10 @@ class Trashbin { // actual file deletion $trash->delete(); $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?'); - $query->execute(array($user)); + $query->execute([$user]); // Bulk PostDelete-Hook - \OC_Hook::emit('\OCP\Trashbin', 'deleteAll', array('paths' => $filePaths)); + \OC_Hook::emit('\OCP\Trashbin', 'deleteAll', ['paths' => $filePaths]); // Single-File Hooks foreach($filePaths as $path){ @@ -550,7 +550,7 @@ class Trashbin { * @param string $path */ protected static function emitTrashbinPreDelete($path){ - \OC_Hook::emit('\OCP\Trashbin', 'preDelete', array('path' => $path)); + \OC_Hook::emit('\OCP\Trashbin', 'preDelete', ['path' => $path]); } /** @@ -558,7 +558,7 @@ class Trashbin { * @param string $path */ protected static function emitTrashbinPostDelete($path){ - \OC_Hook::emit('\OCP\Trashbin', 'delete', array('path' => $path)); + \OC_Hook::emit('\OCP\Trashbin', 'delete', ['path' => $path]); } /** @@ -577,7 +577,7 @@ class Trashbin { if ($timestamp) { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?'); - $query->execute(array($user, $filename, $timestamp)); + $query->execute([$user, $filename, $timestamp]); $file = $filename . '.d' . $timestamp; } else { $file = $filename; @@ -660,7 +660,7 @@ class Trashbin { */ public static function deleteUser($uid) { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=?'); - return $query->execute(array($uid)); + return $query->execute([$uid]); } /** @@ -818,7 +818,7 @@ class Trashbin { } } - return array($size, $count); + return [$size, $count]; } /** @@ -868,7 +868,7 @@ class Trashbin { */ private static function getVersionsFromTrash($filename, $timestamp, $user) { $view = new View('/' . $user . '/files_trashbin/versions'); - $versions = array(); + $versions = []; //force rescan of versions, local storage may not have updated the cache if (!self::$scannedVersions) { @@ -1015,6 +1015,6 @@ class Trashbin { * @return string */ public static function preview_icon($path) { - return \OC::$server->getURLGenerator()->linkToRoute('core_ajax_trashbin_preview', array('x' => 32, 'y' => 32, 'file' => $path)); + return \OC::$server->getURLGenerator()->linkToRoute('core_ajax_trashbin_preview', ['x' => 32, 'y' => 32, 'file' => $path]); } } diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php index 3bfbf2b35fd..a906bf75853 100644 --- a/apps/files_trashbin/tests/Command/CleanUpTest.php +++ b/apps/files_trashbin/tests/Command/CleanUpTest.php @@ -81,12 +81,12 @@ class CleanUpTest extends TestCase { $query->delete($this->trashTable)->execute(); for ($i = 0; $i < 10; $i++) { $query->insert($this->trashTable) - ->values(array( + ->values([ 'id' => $query->expr()->literal('file'.$i), 'timestamp' => $query->expr()->literal($i), 'location' => $query->expr()->literal('.'), 'user' => $query->expr()->literal('user'.$i%2) - ))->execute(); + ])->execute(); } $getAllQuery = $this->dbConnection->getQueryBuilder(); $result = $getAllQuery->select('id') @@ -143,10 +143,10 @@ class CleanUpTest extends TestCase { } public function dataTestRemoveDeletedFiles() { - return array( - array(true), - array(false) - ); + return [ + [true], + [false] + ]; } /** diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index 6b57d111ea9..6047e488a77 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -145,8 +145,8 @@ class StorageTest extends \Test\TestCase { * isn't. */ public function testCrossStorageDeleteFile() { - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage'); $this->userView->file_put_contents('substorage/subfile.txt', 'foo'); $storage2->getScanner()->scan(''); @@ -171,8 +171,8 @@ class StorageTest extends \Test\TestCase { * isn't. */ public function testCrossStorageDeleteFolder() { - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage'); $this->userView->mkdir('substorage/folder'); $this->userView->file_put_contents('substorage/folder/subfile.txt', 'bar'); @@ -388,8 +388,8 @@ class StorageTest extends \Test\TestCase { public function testKeepFileAndVersionsWhenMovingFileBetweenStorages() { \OCA\Files_Versions\Hooks::connectHooks(); - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage'); // trigger a version (multiple would not work because of the expire logic) $this->userView->file_put_contents('test.txt', 'v1'); @@ -429,8 +429,8 @@ class StorageTest extends \Test\TestCase { public function testKeepFileAndVersionsWhenMovingFolderBetweenStorages() { \OCA\Files_Versions\Hooks::connectHooks(); - $storage2 = new Temporary(array()); - \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage'); + $storage2 = new Temporary([]); + \OC\Files\Filesystem::mount($storage2, [], $this->user . '/files/substorage'); // trigger a version (multiple would not work because of the expire logic) $this->userView->file_put_contents('folder/inside.txt', 'v1'); diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 4465bfbab3c..bdcef91e37c 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -270,14 +270,14 @@ class TrashbinTest extends \Test\TestCase { $filesInTrashUser2AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2); // user2-1.txt should have been expired - $this->verifyArray($filesInTrashUser2AfterDelete, array('user2-2.txt', 'user1-4.txt')); + $this->verifyArray($filesInTrashUser2AfterDelete, ['user2-2.txt', 'user1-4.txt']); self::loginHelper(self::TEST_TRASHBIN_USER1); // user1-1.txt and user1-3.txt should have been expired $filesInTrashUser1AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1); - $this->verifyArray($filesInTrashUser1AfterDelete, array('user1-2.txt', 'user1-4.txt')); + $this->verifyArray($filesInTrashUser1AfterDelete, ['user1-2.txt', 'user1-4.txt']); } /** |