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 /lib/private/Files | |
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 'lib/private/Files')
30 files changed, 139 insertions, 139 deletions
diff --git a/lib/private/Files/Cache/HomeCache.php b/lib/private/Files/Cache/HomeCache.php index ec3c8df519d..0691c1d1e44 100644 --- a/lib/private/Files/Cache/HomeCache.php +++ b/lib/private/Files/Cache/HomeCache.php @@ -54,14 +54,14 @@ class HomeCache extends Cache { $sql = 'SELECT SUM(`size`) AS f1 ' . 'FROM `*PREFIX*filecache` ' . 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0'; - $result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId())); + $result = \OC_DB::executeAudited($sql, [$id, $this->getNumericStorageId()]); if ($row = $result->fetchRow()) { $result->closeCursor(); list($sum) = array_values($row); $totalSize = 0 + $sum; $entry['size'] += 0; if ($entry['size'] !== $totalSize) { - $this->update($id, array('size' => $totalSize)); + $this->update($id, ['size' => $totalSize]); } } } diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index 30688a8da3e..b481a9918b9 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -164,8 +164,8 @@ class Scanner extends BasicEmitter implements IScanner { // pre-emit only if it was a file. By that we avoid counting/treating folders as files if ($data['mimetype'] !== 'httpd/unix-directory') { - $this->emit('\OC\Files\Cache\Scanner', 'scanFile', array($file, $this->storageId)); - \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId)); + $this->emit('\OC\Files\Cache\Scanner', 'scanFile', [$file, $this->storageId]); + \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', ['path' => $file, 'storage' => $this->storageId]); } $parent = dirname($file); @@ -233,8 +233,8 @@ class Scanner extends BasicEmitter implements IScanner { // post-emit only if it was a file. By that we avoid counting/treating folders as files if ($data['mimetype'] !== 'httpd/unix-directory') { - $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId)); - \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId)); + $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', [$file, $this->storageId]); + \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', ['path' => $file, 'storage' => $this->storageId]); } } else { @@ -266,8 +266,8 @@ class Scanner extends BasicEmitter implements IScanner { } protected function removeFromCache($path) { - \OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $path)); - $this->emit('\OC\Files\Cache\Scanner', 'removeFromCache', array($path)); + \OC_Hook::emit('Scanner', 'removeFromCache', ['file' => $path]); + $this->emit('\OC\Files\Cache\Scanner', 'removeFromCache', [$path]); if ($this->cacheActive) { $this->cache->remove($path); } @@ -283,8 +283,8 @@ class Scanner extends BasicEmitter implements IScanner { if (isset($data['scan_permissions'])) { $data['permissions'] = $data['scan_permissions']; } - \OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'data' => $data)); - $this->emit('\OC\Files\Cache\Scanner', 'addToCache', array($path, $this->storageId, $data)); + \OC_Hook::emit('Scanner', 'addToCache', ['file' => $path, 'data' => $data]); + $this->emit('\OC\Files\Cache\Scanner', 'addToCache', [$path, $this->storageId, $data]); if ($this->cacheActive) { if ($fileId !== -1) { $this->cache->update($fileId, $data); @@ -303,8 +303,8 @@ class Scanner extends BasicEmitter implements IScanner { * @param int $fileId */ protected function updateCache($path, $data, $fileId = -1) { - \OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'data' => $data)); - $this->emit('\OC\Files\Cache\Scanner', 'updateCache', array($path, $this->storageId, $data)); + \OC_Hook::emit('Scanner', 'addToCache', ['file' => $path, 'data' => $data]); + $this->emit('\OC\Files\Cache\Scanner', 'updateCache', [$path, $this->storageId, $data]); if ($this->cacheActive) { if ($fileId !== -1) { $this->cache->update($fileId, $data); @@ -357,7 +357,7 @@ class Scanner extends BasicEmitter implements IScanner { * @return array[] */ protected function getExistingChildren($folderId) { - $existingChildren = array(); + $existingChildren = []; $children = $this->cache->getFolderContentsById($folderId); foreach ($children as $child) { $existingChildren[$child['name']] = $child; @@ -372,7 +372,7 @@ class Scanner extends BasicEmitter implements IScanner { * @return string[] */ protected function getNewChildren($folder) { - $children = array(); + $children = []; if ($dh = $this->storage->opendir($folder)) { if (is_resource($dh)) { while (($file = readdir($dh)) !== false) { @@ -399,7 +399,7 @@ class Scanner extends BasicEmitter implements IScanner { if ($reuse === -1) { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } - $this->emit('\OC\Files\Cache\Scanner', 'scanFolder', array($path, $this->storageId)); + $this->emit('\OC\Files\Cache\Scanner', 'scanFolder', [$path, $this->storageId]); $size = 0; if (!is_null($folderId)) { $folderId = $this->cache->getId($path); @@ -415,9 +415,9 @@ class Scanner extends BasicEmitter implements IScanner { } } if ($this->cacheActive) { - $this->cache->update($folderId, array('size' => $size)); + $this->cache->update($folderId, ['size' => $size]); } - $this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', array($path, $this->storageId)); + $this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', [$path, $this->storageId]); return $size; } @@ -531,7 +531,7 @@ class Scanner extends BasicEmitter implements IScanner { private function runBackgroundScanJob(callable $callback, $path) { try { $callback(); - \OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path)); + \OC_Hook::emit('Scanner', 'correctFolderSize', ['path' => $path]); if ($this->cacheActive && $this->cache instanceof Cache) { $this->cache->correctFolderSize($path, null, true); } diff --git a/lib/private/Files/Cache/Storage.php b/lib/private/Files/Cache/Storage.php index 13af41acfea..439ed30890c 100644 --- a/lib/private/Files/Cache/Storage.php +++ b/lib/private/Files/Cache/Storage.php @@ -127,7 +127,7 @@ class Storage { public static function getStorageId($numericId) { $sql = 'SELECT `id` FROM `*PREFIX*storages` WHERE `numeric_id` = ?'; - $result = \OC_DB::executeAudited($sql, array($numericId)); + $result = \OC_DB::executeAudited($sql, [$numericId]); if ($row = $result->fetchRow()) { return $row['id']; } else { @@ -194,11 +194,11 @@ class Storage { $storageId = self::adjustStorageId($storageId); $numericId = self::getNumericStorageId($storageId); $sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?'; - \OC_DB::executeAudited($sql, array($storageId)); + \OC_DB::executeAudited($sql, [$storageId]); if (!is_null($numericId)) { $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?'; - \OC_DB::executeAudited($sql, array($numericId)); + \OC_DB::executeAudited($sql, [$numericId]); } } } diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php index 59cff9b3a41..b093b591d4e 100644 --- a/lib/private/Files/Cache/Updater.php +++ b/lib/private/Files/Cache/Updater.php @@ -247,7 +247,7 @@ class Updater implements IUpdater { if ($parentId != -1) { $mtime = $this->storage->filemtime($parent); if ($mtime !== false) { - $this->cache->update($parentId, array('storage_mtime' => $mtime)); + $this->cache->update($parentId, ['storage_mtime' => $mtime]); } } } diff --git a/lib/private/Files/Cache/Watcher.php b/lib/private/Files/Cache/Watcher.php index beb49ff2d65..884054c9a02 100644 --- a/lib/private/Files/Cache/Watcher.php +++ b/lib/private/Files/Cache/Watcher.php @@ -35,7 +35,7 @@ class Watcher implements IWatcher { protected $watchPolicy = self::CHECK_ONCE; - protected $checkedPaths = array(); + protected $checkedPaths = []; /** * @var \OC\Files\Storage\Storage $storage diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 92601e38d13..e2ed62b4444 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -209,9 +209,9 @@ class CacheJail extends CacheWrapper { } private function formatSearchResults($results) { - $results = array_filter($results, array($this, 'filterCacheEntry')); + $results = array_filter($results, [$this, 'filterCacheEntry']); $results = array_values($results); - return array_map(array($this, 'formatCacheEntry'), $results); + return array_map([$this, 'formatCacheEntry'], $results); } /** @@ -282,7 +282,7 @@ class CacheJail extends CacheWrapper { */ public function getAll() { // not supported - return array(); + return []; } /** diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php index 40bac888673..27aa203655b 100644 --- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php +++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php @@ -96,7 +96,7 @@ class CacheWrapper extends Cache { */ public function getFolderContentsById($fileId) { $results = $this->getCache()->getFolderContentsById($fileId); - return array_map(array($this, 'formatCacheEntry'), $results); + return array_map([$this, 'formatCacheEntry'], $results); } /** @@ -223,7 +223,7 @@ class CacheWrapper extends Cache { */ public function search($pattern) { $results = $this->getCache()->search($pattern); - return array_map(array($this, 'formatCacheEntry'), $results); + return array_map([$this, 'formatCacheEntry'], $results); } /** @@ -234,12 +234,12 @@ class CacheWrapper extends Cache { */ public function searchByMime($mimetype) { $results = $this->getCache()->searchByMime($mimetype); - return array_map(array($this, 'formatCacheEntry'), $results); + return array_map([$this, 'formatCacheEntry'], $results); } public function searchQuery(ISearchQuery $query) { $results = $this->getCache()->searchQuery($query); - return array_map(array($this, 'formatCacheEntry'), $results); + return array_map([$this, 'formatCacheEntry'], $results); } /** diff --git a/lib/private/Files/Config/MountProviderCollection.php b/lib/private/Files/Config/MountProviderCollection.php index 4ef3f9f8d94..4b723cc764b 100644 --- a/lib/private/Files/Config/MountProviderCollection.php +++ b/lib/private/Files/Config/MountProviderCollection.php @@ -46,7 +46,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { /** * @var \OCP\Files\Config\IMountProvider[] */ - private $providers = array(); + private $providers = []; /** * @var \OCP\Files\Storage\IStorageFactory @@ -86,7 +86,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { }); $mounts = array_reduce($mounts, function (array $mounts, array $providerMounts) { return array_merge($mounts, $providerMounts); - }, array()); + }, []); return $this->filterMounts($user, $mounts); } diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index 24d21ad6049..d4e584c39f9 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -83,7 +83,7 @@ class Filesystem { */ static private $defaultInstance; - static private $usersSetup = array(); + static private $usersSetup = []; static private $normalizedPathCache = null; @@ -300,7 +300,7 @@ class Filesystem { if (!self::$mounts) { \OC_Util::setupFS(); } - $result = array(); + $result = []; $mounts = self::$mounts->findIn($path); foreach ($mounts as $mount) { $result[] = $mount->getMountPoint(); @@ -356,9 +356,9 @@ class Filesystem { } $mount = self::$mounts->find($path); if ($mount) { - return array($mount->getStorage(), rtrim($mount->getInternalPath($path), '/')); + return [$mount->getStorage(), rtrim($mount->getInternalPath($path), '/')]; } else { - return array(null, null); + return [null, null]; } } @@ -461,7 +461,7 @@ class Filesystem { '/' . $user . '/files' )); } - \OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', array('user' => $user)); + \OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', ['user' => $user]); } /** @@ -478,7 +478,7 @@ class Filesystem { $userObject = $userManager->get($user); if ($userObject) { $mounts = $provider->getMountsForUser($userObject, Filesystem::getLoader()); - array_walk($mounts, array(self::$mounts, 'addMount')); + array_walk($mounts, [self::$mounts, 'addMount']); } } }); @@ -521,7 +521,7 @@ class Filesystem { */ public static function clearMounts() { if (self::$mounts) { - self::$usersSetup = array(); + self::$usersSetup = []; self::$mounts->clear(); } } @@ -619,7 +619,7 @@ class Filesystem { static public function isFileBlacklisted($filename) { $filename = self::normalizePath($filename); - $blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', array('.htaccess')); + $blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', ['.htaccess']); $filename = strtolower(basename($filename)); return in_array($filename, $blacklist); } diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 2b5fa3f7199..93f9941d383 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -50,7 +50,7 @@ class MountPoint implements IMountPoint { * * @var array */ - protected $arguments = array(); + protected $arguments = []; protected $mountPoint; /** @@ -58,7 +58,7 @@ class MountPoint implements IMountPoint { * * @var array */ - protected $mountOptions = array(); + protected $mountOptions = []; /** * @var \OC\Files\Storage\StorageFactory $loader @@ -87,7 +87,7 @@ class MountPoint implements IMountPoint { */ public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) { if (is_null($arguments)) { - $arguments = array(); + $arguments = []; } if (is_null($loader)) { $this->loader = new StorageFactory(); diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php index dcfa0b93ed1..fd5e996627d 100644 --- a/lib/private/Files/Node/File.php +++ b/lib/private/Files/Node/File.php @@ -67,12 +67,12 @@ class File extends Node implements \OCP\Files\File { */ public function putContent($data) { if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { - $this->sendHooks(array('preWrite')); + $this->sendHooks(['preWrite']); if ($this->view->file_put_contents($this->path, $data) === false) { throw new GenericFileException('file_put_contents failed'); } $this->fileInfo = null; - $this->sendHooks(array('postWrite')); + $this->sendHooks(['postWrite']); } else { throw new NotPermittedException(); } @@ -85,8 +85,8 @@ class File extends Node implements \OCP\Files\File { * @throws LockedException */ public function fopen($mode) { - $preHooks = array(); - $postHooks = array(); + $preHooks = []; + $postHooks = []; $requiredPermissions = \OCP\Constants::PERMISSION_READ; switch ($mode) { case 'r+': @@ -126,7 +126,7 @@ class File extends Node implements \OCP\Files\File { */ public function delete() { if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { - $this->sendHooks(array('preDelete')); + $this->sendHooks(['preDelete']); $fileInfo = $this->getFileInfo(); $this->view->unlink($this->path); $nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo); diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 727b08e9335..f910eb27fdf 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -205,9 +205,9 @@ class Folder extends Node implements \OCP\Files\Folder { */ public function search($query) { if (is_string($query)) { - return $this->searchCommon('search', array('%' . $query . '%')); + return $this->searchCommon('search', ['%' . $query . '%']); } else { - return $this->searchCommon('searchQuery', array($query)); + return $this->searchCommon('searchQuery', [$query]); } } @@ -218,7 +218,7 @@ class Folder extends Node implements \OCP\Files\Folder { * @return Node[] */ public function searchByMime($mimetype) { - return $this->searchCommon('searchByMime', array($mimetype)); + return $this->searchCommon('searchByMime', [$mimetype]); } /** @@ -229,7 +229,7 @@ class Folder extends Node implements \OCP\Files\Folder { * @return Node[] */ public function searchByTag($tag, $userId) { - return $this->searchCommon('searchByTag', array($tag, $userId)); + return $this->searchCommon('searchByTag', [$tag, $userId]); } /** @@ -243,7 +243,7 @@ class Folder extends Node implements \OCP\Files\Folder { throw new \InvalidArgumentException('searching by owner is only allows on the users home folder'); } - $files = array(); + $files = []; $rootLength = strlen($this->path); $mount = $this->root->getMount($this->path); $storage = $mount->getStorage(); @@ -256,7 +256,7 @@ class Folder extends Node implements \OCP\Files\Folder { $cache = $storage->getCache(''); - $results = call_user_func_array(array($cache, $method), $args); + $results = call_user_func_array([$cache, $method], $args); foreach ($results as $result) { if ($internalRootLength === 0 or substr($result['path'], 0, $internalRootLength) === $internalPath) { $result['internalPath'] = $result['path']; @@ -394,7 +394,7 @@ class Folder extends Node implements \OCP\Files\Folder { public function delete() { if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { - $this->sendHooks(array('preDelete')); + $this->sendHooks(['preDelete']); $fileInfo = $this->getFileInfo(); $this->view->rmdir($this->path); $nonExisting = new NonExistingFolder($this->root, $this->view, $this->path, $fileInfo); diff --git a/lib/private/Files/Node/LazyRoot.php b/lib/private/Files/Node/LazyRoot.php index 8076c3b4f6a..654badbd9d0 100644 --- a/lib/private/Files/Node/LazyRoot.php +++ b/lib/private/Files/Node/LazyRoot.php @@ -89,14 +89,14 @@ class LazyRoot implements IRootFolder { /** * @inheritDoc */ - public function emit($scope, $method, $arguments = array()) { + public function emit($scope, $method, $arguments = []) { $this->__call(__FUNCTION__, func_get_args()); } /** * @inheritDoc */ - public function mount($storage, $mountPoint, $arguments = array()) { + public function mount($storage, $mountPoint, $arguments = []) { $this->__call(__FUNCTION__, func_get_args()); } diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 896b3050384..a8b5fea6be8 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -139,9 +139,9 @@ class Node implements \OCP\Files\Node { */ public function touch($mtime = null) { if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { - $this->sendHooks(array('preTouch')); + $this->sendHooks(['preTouch']); $this->view->touch($this->path, $mtime); - $this->sendHooks(array('postTouch')); + $this->sendHooks(['postTouch']); if ($this->fileInfo) { if (is_null($mtime)) { $mtime = time(); diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 948715aec04..843069ff50d 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -133,7 +133,7 @@ class Root extends Folder implements IRootFolder { * @param string $method * @param Node[] $arguments */ - public function emit($scope, $method, $arguments = array()) { + public function emit($scope, $method, $arguments = []) { $this->emitter->emit($scope, $method, $arguments); } @@ -142,7 +142,7 @@ class Root extends Folder implements IRootFolder { * @param string $mountPoint * @param array $arguments */ - public function mount($storage, $mountPoint, $arguments = array()) { + public function mount($storage, $mountPoint, $arguments = []) { $mount = new MountPoint($storage, $mountPoint, $arguments); $this->mountManager->addMount($mount); } diff --git a/lib/private/Files/ObjectStore/NoopScanner.php b/lib/private/Files/ObjectStore/NoopScanner.php index f82eb7b1ddc..c25594ccb3f 100644 --- a/lib/private/Files/ObjectStore/NoopScanner.php +++ b/lib/private/Files/ObjectStore/NoopScanner.php @@ -44,7 +44,7 @@ class NoopScanner extends Scanner { * @return array an array of metadata of the scanned file */ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) { - return array(); + return []; } /** @@ -56,7 +56,7 @@ class NoopScanner extends Scanner { * @return array with the meta data of the scanned file or folder */ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { - return array(); + return []; } /** diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index e0d437839a0..0f2d1f244a8 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -245,7 +245,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { $path = $this->normalizePath($path); try { - $files = array(); + $files = []; $folderContents = $this->getCache()->getFolderContents($path); foreach ($folderContents as $file) { $files[] = $file['name']; @@ -375,14 +375,14 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { // work with all object storage implementations $this->file_put_contents($path, ' '); $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path); - $stat = array( + $stat = [ 'etag' => $this->getETag($path), 'mimetype' => $mimeType, 'size' => 0, 'mtime' => $mtime, 'storage_mtime' => $mtime, 'permissions' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, - ); + ]; $this->getCache()->put($path, $stat); } catch (\Exception $ex) { $this->logger->logException($ex, [ diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index f931b6092a6..f4ed8c5b5c0 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -117,7 +117,7 @@ trait S3ConnectionTrait { if (!$this->connection->isBucketDnsCompatible($this->bucket)) { throw new \Exception("The bucket will not be created because the name is not dns compatible, please correct it: " . $this->bucket); } - $this->connection->createBucket(array('Bucket' => $this->bucket)); + $this->connection->createBucket(['Bucket' => $this->bucket]); $this->testTimeout(); } catch (S3Exception $e) { $logger->logException($e, [ diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 8760fae1185..c976174f8cf 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -296,7 +296,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { * @return array */ protected function searchInDir($query, $dir = '') { - $files = array(); + $files = []; $dh = $this->opendir($dir); if (is_resource($dh)) { while (($item = readdir($dh)) !== false) { @@ -434,7 +434,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { $path = '/' . $path; } - $output = array(); + $output = []; foreach (explode('/', $path) as $chunk) { if ($chunk == '..') { array_pop($output); diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 625e5f3f625..970f3f8c156 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -265,7 +265,7 @@ class DAV extends Common { try { $response = $this->client->propFind( $this->encodePath($path), - array( + [ '{DAV:}getlastmodified', '{DAV:}getcontentlength', '{DAV:}getcontenttype', @@ -273,7 +273,7 @@ class DAV extends Common { '{http://open-collaboration-services.org/ns}share-permissions', '{DAV:}resourcetype', '{DAV:}getetag', - ) + ] ); $this->statCache->set($path, $response); } catch (ClientHttpException $e) { @@ -591,7 +591,7 @@ class DAV extends Common { } catch (\Exception $e) { $this->convertException($e, $path); } - return array(); + return []; } /** {@inheritdoc} */ diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 13a3ca87097..e186d29c348 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -107,7 +107,7 @@ class Local extends \OC\Files\Storage\Common { * @var \SplFileInfo $file */ $file = $it->current(); - if (in_array($file->getBasename(), array('.', '..'))) { + if (in_array($file->getBasename(), ['.', '..'])) { $it->next(); continue; } elseif ($file->isDir()) { @@ -340,7 +340,7 @@ class Local extends \OC\Files\Storage\Common { * @return array */ protected function searchInDir($query, $dir = '') { - $files = array(); + $files = []; $physicalDir = $this->getSourcePath($dir); foreach (scandir($physicalDir) as $item) { if (\OC\Files\Filesystem::isIgnoredDir($item)) diff --git a/lib/private/Files/Storage/Temporary.php b/lib/private/Files/Storage/Temporary.php index bb501cb5565..2e1d1e33bef 100644 --- a/lib/private/Files/Storage/Temporary.php +++ b/lib/private/Files/Storage/Temporary.php @@ -30,7 +30,7 @@ namespace OC\Files\Storage; */ class Temporary extends Local{ public function __construct($arguments = null) { - parent::__construct(array('datadir' => \OC::$server->getTempManager()->getTemporaryFolder())); + parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]); } public function cleanUp() { diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 68cf6f99ee5..cbe9b874501 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -87,7 +87,7 @@ class Encryption extends Wrapper { private $mountManager; /** @var array remember for which path we execute the repair step to avoid recursions */ - private $fixUnencryptedSizeOf = array(); + private $fixUnencryptedSizeOf = []; /** @var ArrayCache */ private $arrayCache; @@ -125,7 +125,7 @@ class Encryption extends Wrapper { $this->uid = $uid; $this->fileHelper = $fileHelper; $this->keyStorage = $keyStorage; - $this->unencryptedSize = array(); + $this->unencryptedSize = []; $this->update = $update; $this->mountManager = $mountManager; $this->arrayCache = $arrayCache; @@ -892,7 +892,7 @@ class Encryption extends Wrapper { * @return array */ protected function parseRawHeader($rawHeader) { - $result = array(); + $result = []; if (substr($rawHeader, 0, strlen(Util::HEADER_START)) === Util::HEADER_START) { $header = $rawHeader; $endAt = strpos($header, Util::HEADER_END); diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 7cb24f9b5b6..3030fa8c7ef 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -503,7 +503,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea * @return mixed */ public function __call($method, $args) { - return call_user_func_array(array($this->getWrapperStorage(), $method), $args); + return call_user_func_array([$this->getWrapperStorage(), $method], $args); } /** diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php index dc6cd9cea7f..2ae872de337 100644 --- a/lib/private/Files/Stream/Encryption.php +++ b/lib/private/Files/Stream/Encryption.php @@ -109,7 +109,7 @@ class Encryption extends Wrapper { protected $fileUpdated; public function __construct() { - $this->expectedContextProperties = array( + $this->expectedContextProperties = [ 'source', 'storage', 'internalPath', @@ -124,7 +124,7 @@ class Encryption extends Wrapper { 'encryptionStorage', 'headerSize', 'signed' - ); + ]; } @@ -165,8 +165,8 @@ class Encryption extends Wrapper { $signed, $wrapper = Encryption::class) { - $context = stream_context_create(array( - 'ocencryption' => array( + $context = stream_context_create([ + 'ocencryption' => [ 'source' => $source, 'storage' => $storage, 'internalPath' => $internalPath, @@ -181,8 +181,8 @@ class Encryption extends Wrapper { 'encryptionStorage' => $encStorage, 'headerSize' => $headerSize, 'signed' => $signed - ) - )); + ] + ]); return self::wrapSource($source, $context, 'ocencryption', $wrapper, $mode); } diff --git a/lib/private/Files/Stream/Quota.php b/lib/private/Files/Stream/Quota.php index 08272ad61cb..f07c0c2b678 100644 --- a/lib/private/Files/Stream/Quota.php +++ b/lib/private/Files/Stream/Quota.php @@ -44,12 +44,12 @@ class Quota extends Wrapper { * @return resource */ static public function wrap($stream, $limit) { - $context = stream_context_create(array( - 'quota' => array( + $context = stream_context_create([ + 'quota' => [ 'source' => $stream, 'limit' => $limit - ) - )); + ] + ]); return Wrapper::wrapSource($stream, $context, 'quota', self::class); } diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index 1352963fc67..0db564032ac 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -103,7 +103,7 @@ class Detection implements IMimeTypeDetector { public function registerType(string $extension, string $mimetype, ?string $secureMimeType = null): void { - $this->mimetypes[$extension] = array($mimetype, $secureMimeType); + $this->mimetypes[$extension] = [$mimetype, $secureMimeType]; $this->secureMimeTypes[$mimetype] = $secureMimeType ?: $mimetype; } diff --git a/lib/private/Files/Type/TemplateManager.php b/lib/private/Files/Type/TemplateManager.php index 4febf9afbf1..d9afe138171 100644 --- a/lib/private/Files/Type/TemplateManager.php +++ b/lib/private/Files/Type/TemplateManager.php @@ -29,7 +29,7 @@ namespace OC\Files\Type; * @deprecated 18.0.0 */ class TemplateManager { - protected $templates = array(); + protected $templates = []; public function registerTemplate($mimetype, $path) { $this->templates[$mimetype] = $path; diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 943078215b5..49f8177834a 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -131,19 +131,19 @@ class Scanner extends PublicEmitter { protected function attachListener($mount) { $scanner = $mount->getStorage()->getScanner(); $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path)); + $this->emit('\OC\Files\Utils\Scanner', 'scanFile', [$mount->getMountPoint() . $path]); $this->dispatcher->dispatchTyped(new BeforeFileScannedEvent($mount->getMountPoint() . $path)); }); $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); + $this->emit('\OC\Files\Utils\Scanner', 'scanFolder', [$mount->getMountPoint() . $path]); $this->dispatcher->dispatchTyped(new BeforeFolderScannedEvent($mount->getMountPoint() . $path)); }); $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path)); + $this->emit('\OC\Files\Utils\Scanner', 'postScanFile', [$mount->getMountPoint() . $path]); $this->dispatcher->dispatchTyped(new FileScannedEvent($mount->getMountPoint() . $path)); }); $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path)); + $this->emit('\OC\Files\Utils\Scanner', 'postScanFolder', [$mount->getMountPoint() . $path]); $this->dispatcher->dispatchTyped(new FolderScannedEvent($mount->getMountPoint() . $path)); }); } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 8ea94626a2a..abfde63be5a 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -266,7 +266,7 @@ class View { * for \OC\Files\Storage\Storage via basicOperation(). */ public function mkdir($path) { - return $this->basicOperation('mkdir', $path, array('create', 'write')); + return $this->basicOperation('mkdir', $path, ['create', 'write']); } /** @@ -284,7 +284,7 @@ class View { $this->lockFile($relPath, ILockingProvider::LOCK_SHARED, true); \OC_Hook::emit( Filesystem::CLASSNAME, "umount", - array(Filesystem::signal_param_path => $relPath) + [Filesystem::signal_param_path => $relPath] ); $this->changeLock($relPath, ILockingProvider::LOCK_EXCLUSIVE, true); $result = $mount->removeMount(); @@ -292,7 +292,7 @@ class View { if ($result) { \OC_Hook::emit( Filesystem::CLASSNAME, "post_umount", - array(Filesystem::signal_param_path => $relPath) + [Filesystem::signal_param_path => $relPath] ); } $this->unlockFile($relPath, ILockingProvider::LOCK_SHARED, true); @@ -345,7 +345,7 @@ class View { return $this->removeMount($mount, $absolutePath); } if ($this->is_dir($path)) { - $result = $this->basicOperation('rmdir', $path, array('delete')); + $result = $this->basicOperation('rmdir', $path, ['delete']); } else { $result = false; } @@ -363,7 +363,7 @@ class View { * @return resource */ public function opendir($path) { - return $this->basicOperation('opendir', $path, array('read')); + return $this->basicOperation('opendir', $path, ['read']); } /** @@ -559,7 +559,7 @@ class View { $mtime = strtotime($mtime); } - $hooks = array('touch'); + $hooks = ['touch']; if (!$this->file_exists($path)) { $hooks[] = 'create'; @@ -581,7 +581,7 @@ class View { $mtime = time(); } //if native touch fails, we emulate it by changing the mtime in the cache - $this->putFileInfo($path, array('mtime' => floor($mtime))); + $this->putFileInfo($path, ['mtime' => floor($mtime)]); } return true; } @@ -592,7 +592,7 @@ class View { * @throws LockedException */ public function file_get_contents($path) { - return $this->basicOperation('file_get_contents', $path, array('read')); + return $this->basicOperation('file_get_contents', $path, ['read']); } /** @@ -602,20 +602,20 @@ class View { */ protected function emit_file_hooks_pre($exists, $path, &$run) { if (!$exists) { - \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_create, array( + \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_create, [ Filesystem::signal_param_path => $this->getHookPath($path), Filesystem::signal_param_run => &$run, - )); + ]); } else { - \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_update, array( + \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_update, [ Filesystem::signal_param_path => $this->getHookPath($path), Filesystem::signal_param_run => &$run, - )); + ]); } - \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_write, array( + \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_write, [ Filesystem::signal_param_path => $this->getHookPath($path), Filesystem::signal_param_run => &$run, - )); + ]); } /** @@ -624,17 +624,17 @@ class View { */ protected function emit_file_hooks_post($exists, $path) { if (!$exists) { - \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_create, array( + \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_create, [ Filesystem::signal_param_path => $this->getHookPath($path), - )); + ]); } else { - \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_update, array( + \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_update, [ Filesystem::signal_param_path => $this->getHookPath($path), - )); + ]); } - \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_write, array( + \OC_Hook::emit(Filesystem::CLASSNAME, Filesystem::signal_post_write, [ Filesystem::signal_param_path => $this->getHookPath($path), - )); + ]); } /** @@ -690,7 +690,7 @@ class View { return false; } } else { - $hooks = $this->file_exists($path) ? array('update', 'write') : array('create', 'write'); + $hooks = $this->file_exists($path) ? ['update', 'write'] : ['create', 'write']; return $this->basicOperation('file_put_contents', $path, $hooks, $data); } } @@ -770,11 +770,11 @@ class View { } elseif ($this->shouldEmitHooks($path1)) { \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_rename, - array( + [ Filesystem::signal_param_oldpath => $this->getHookPath($path1), Filesystem::signal_param_newpath => $this->getHookPath($path2), Filesystem::signal_param_run => &$run - ) + ] ); } if ($run) { @@ -844,10 +844,10 @@ class View { \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_post_rename, - array( + [ Filesystem::signal_param_oldpath => $this->getHookPath($path1), Filesystem::signal_param_newpath => $this->getHookPath($path2) - ) + ] ); } } @@ -900,11 +900,11 @@ class View { \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_copy, - array( + [ Filesystem::signal_param_oldpath => $this->getHookPath($path1), Filesystem::signal_param_newpath => $this->getHookPath($path2), Filesystem::signal_param_run => &$run - ) + ] ); $this->emit_file_hooks_pre($exists, $path2, $run); } @@ -938,10 +938,10 @@ class View { \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_post_copy, - array( + [ Filesystem::signal_param_oldpath => $this->getHookPath($path1), Filesystem::signal_param_newpath => $this->getHookPath($path2) - ) + ] ); $this->emit_file_hooks_post($exists, $path2); } @@ -968,7 +968,7 @@ class View { */ public function fopen($path, $mode) { $mode = str_replace('b', '', $mode); // the binary flag is a windows only feature which we do not support - $hooks = array(); + $hooks = []; switch ($mode) { case 'r': $hooks[] = 'read'; @@ -1087,7 +1087,7 @@ class View { \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_read, - array(Filesystem::signal_param_path => $this->getHookPath($path)) + [Filesystem::signal_param_path => $this->getHookPath($path)] ); } list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix); @@ -1270,18 +1270,18 @@ class View { \OC_Hook::emit( Filesystem::CLASSNAME, $prefix . $hook, - array( + [ Filesystem::signal_param_run => &$run, Filesystem::signal_param_path => $path - ) + ] ); } elseif (!$post) { \OC_Hook::emit( Filesystem::CLASSNAME, $prefix . $hook, - array( + [ Filesystem::signal_param_path => $path - ) + ] ); } } @@ -1297,7 +1297,7 @@ class View { * @return bool */ public function hasUpdated($path, $time) { - return $this->basicOperation('hasUpdated', $path, array(), $time); + return $this->basicOperation('hasUpdated', $path, [], $time); } /** @@ -1591,7 +1591,7 @@ class View { * @return FileInfo[] */ public function search($query) { - return $this->searchCommon('search', array('%' . $query . '%')); + return $this->searchCommon('search', ['%' . $query . '%']); } /** @@ -1601,7 +1601,7 @@ class View { * @return FileInfo[] */ public function searchRaw($query) { - return $this->searchCommon('search', array($query)); + return $this->searchCommon('search', [$query]); } /** @@ -1611,7 +1611,7 @@ class View { * @return FileInfo[] */ public function searchByMime($mimetype) { - return $this->searchCommon('searchByMime', array($mimetype)); + return $this->searchCommon('searchByMime', [$mimetype]); } /** @@ -1622,7 +1622,7 @@ class View { * @return FileInfo[] */ public function searchByTag($tag, $userId) { - return $this->searchCommon('searchByTag', array($tag, $userId)); + return $this->searchCommon('searchByTag', [$tag, $userId]); } /** @@ -1631,7 +1631,7 @@ class View { * @return FileInfo[] */ private function searchCommon($method, $args) { - $files = array(); + $files = []; $rootLength = strlen($this->fakeRoot); $mount = $this->getMount(''); @@ -1640,7 +1640,7 @@ class View { if ($storage) { $cache = $storage->getCache(''); - $results = call_user_func_array(array($cache, $method), $args); + $results = call_user_func_array([$cache, $method], $args); foreach ($results as $result) { if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') { $internalPath = $result['path']; @@ -1659,7 +1659,7 @@ class View { $cache = $storage->getCache(''); $relativeMountPoint = substr($mountPoint, $rootLength); - $results = call_user_func_array(array($cache, $method), $args); + $results = call_user_func_array([$cache, $method], $args); if ($results) { foreach ($results as $result) { $internalPath = $result['path']; @@ -1881,7 +1881,7 @@ class View { // remove the single file array_pop($parts); - $result = array('/'); + $result = ['/']; $resultPath = ''; foreach ($parts as $part) { if ($part) { |