diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-03-28 16:13:19 +0100 |
---|---|---|
committer | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-04-02 14:16:21 +0200 |
commit | ec5133b739eabc76271789504b4dbb91a534f552 (patch) | |
tree | 880b81f5ebd11b289c67e4bcdd1ecaa41aedbcb4 /lib/private/Files | |
parent | b074399a87e764f506550d64f6379738186355c6 (diff) | |
download | nextcloud-server-ec5133b739eabc76271789504b4dbb91a534f552.tar.gz nextcloud-server-ec5133b739eabc76271789504b4dbb91a534f552.zip |
fix: Apply new coding standard to all files
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/Files')
29 files changed, 54 insertions, 54 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 5df4002530f..8f0f962a3b7 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -99,7 +99,7 @@ class Cache implements ICache { private IStorage $storage, // this constructor is used in to many pleases to easily do proper di // so instead we group it all together - CacheDependencies $dependencies = null, + ?CacheDependencies $dependencies = null, ) { $this->storageId = $storage->getId(); if (strlen($this->storageId) > 64) { diff --git a/lib/private/Files/Cache/CacheQueryBuilder.php b/lib/private/Files/Cache/CacheQueryBuilder.php index 365d28fc8c5..d80375e94ee 100644 --- a/lib/private/Files/Cache/CacheQueryBuilder.php +++ b/lib/private/Files/Cache/CacheQueryBuilder.php @@ -68,7 +68,7 @@ class CacheQueryBuilder extends QueryBuilder { return $this; } - public function selectFileCache(string $alias = null, bool $joinExtendedCache = true) { + public function selectFileCache(?string $alias = null, bool $joinExtendedCache = true) { $name = $alias ?: 'filecache'; $this->select("$name.fileid", 'storage', 'path', 'path_hash', "$name.parent", "$name.name", 'mimetype', 'mimepart', 'size', 'mtime', 'storage_mtime', 'encrypted', 'etag', "$name.permissions", 'checksum', 'unencrypted_size') diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index f9754e433df..e8d5fcb490a 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -50,7 +50,7 @@ class CacheJail extends CacheWrapper { public function __construct( ?ICache $cache, string $root, - CacheDependencies $dependencies = null, + ?CacheDependencies $dependencies = null, ) { parent::__construct($cache, $dependencies); $this->root = $root; @@ -88,7 +88,7 @@ class CacheJail extends CacheWrapper { * @param null|string $root * @return null|string the jailed path or null if the path is outside the jail */ - protected function getJailedPath(string $path, string $root = null) { + protected function getJailedPath(string $path, ?string $root = null) { if ($root === null) { $root = $this->getRoot(); } diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php index 31410eea798..1662c76a6b8 100644 --- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php +++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php @@ -43,7 +43,7 @@ class CacheWrapper extends Cache { */ protected $cache; - public function __construct(?ICache $cache, CacheDependencies $dependencies = null) { + public function __construct(?ICache $cache, ?CacheDependencies $dependencies = null) { $this->cache = $cache; if (!$dependencies && $cache instanceof Cache) { $this->mimetypeLoader = $cache->mimetypeLoader; diff --git a/lib/private/Files/Config/CachedMountInfo.php b/lib/private/Files/Config/CachedMountInfo.php index 19fa87aa090..3e7187a5114 100644 --- a/lib/private/Files/Config/CachedMountInfo.php +++ b/lib/private/Files/Config/CachedMountInfo.php @@ -53,7 +53,7 @@ class CachedMountInfo implements ICachedMountInfo { int $rootId, string $mountPoint, string $mountProvider, - int $mountId = null, + ?int $mountId = null, string $rootInternalPath = '' ) { $this->user = $user; diff --git a/lib/private/Files/Config/LazyPathCachedMountInfo.php b/lib/private/Files/Config/LazyPathCachedMountInfo.php index d42052c5f83..722aec60b3f 100644 --- a/lib/private/Files/Config/LazyPathCachedMountInfo.php +++ b/lib/private/Files/Config/LazyPathCachedMountInfo.php @@ -47,7 +47,7 @@ class LazyPathCachedMountInfo extends CachedMountInfo { int $rootId, string $mountPoint, string $mountProvider, - int $mountId = null, + ?int $mountId = null, callable $rootInternalPathCallback, ) { parent::__construct($user, $storageId, $rootId, $mountPoint, $mountProvider, $mountId, self::PATH_PLACEHOLDER); diff --git a/lib/private/Files/Config/MountProviderCollection.php b/lib/private/Files/Config/MountProviderCollection.php index d251199fd43..fcc151eeda0 100644 --- a/lib/private/Files/Config/MountProviderCollection.php +++ b/lib/private/Files/Config/MountProviderCollection.php @@ -119,7 +119,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { return $this->getUserMountsForProviders($user, $providers); } - public function addMountForUser(IUser $user, IMountManager $mountManager, callable $providerFilter = null) { + public function addMountForUser(IUser $user, IMountManager $mountManager, ?callable $providerFilter = null) { // shared mount provider gets to go last since it needs to know existing files // to check for name collisions $firstMounts = []; diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 8275eee7b9f..b5b07d8f29e 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -81,7 +81,7 @@ class UserMountCache implements IUserMountCache { $this->mountsForUsers = new CappedMemoryCache(); } - public function registerMounts(IUser $user, array $mounts, array $mountProviderClasses = null) { + public function registerMounts(IUser $user, array $mounts, ?array $mountProviderClasses = null) { $this->eventLogger->start('fs:setup:user:register', 'Registering mounts for user'); /** @var array<string, ICachedMountInfo> $newMounts */ $newMounts = []; diff --git a/lib/private/Files/Mount/HomeMountPoint.php b/lib/private/Files/Mount/HomeMountPoint.php index 0bec12af5c2..25a877ce644 100644 --- a/lib/private/Files/Mount/HomeMountPoint.php +++ b/lib/private/Files/Mount/HomeMountPoint.php @@ -33,11 +33,11 @@ class HomeMountPoint extends MountPoint { IUser $user, $storage, string $mountpoint, - array $arguments = null, - IStorageFactory $loader = null, - array $mountOptions = null, - int $mountId = null, - string $mountProvider = null + ?array $arguments = null, + ?IStorageFactory $loader = null, + ?array $mountOptions = null, + ?int $mountId = null, + ?string $mountProvider = null ) { parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId, $mountProvider); $this->user = $user; diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index fe6358b32f1..e9a4c5c8a4f 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -94,11 +94,11 @@ class MountPoint implements IMountPoint { public function __construct( $storage, string $mountpoint, - array $arguments = null, - IStorageFactory $loader = null, - array $mountOptions = null, - int $mountId = null, - string $mountProvider = null + ?array $arguments = null, + ?IStorageFactory $loader = null, + ?array $mountOptions = null, + ?int $mountId = null, + ?string $mountProvider = null ) { if (is_null($arguments)) { $arguments = []; diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 014b66fdf63..52e7b55676a 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -199,7 +199,7 @@ class Folder extends Node implements \OCP\Files\Folder { throw new NotPermittedException('No create permission for path "' . $path . '"'); } - private function queryFromOperator(ISearchOperator $operator, string $uid = null, int $limit = 0, int $offset = 0): ISearchQuery { + private function queryFromOperator(ISearchOperator $operator, ?string $uid = null, int $limit = 0, int $offset = 0): ISearchQuery { if ($uid === null) { $user = null; } else { diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index 4aae5cf9804..08e77d7f705 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -101,7 +101,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ - public function removeListener($scope = null, $method = null, callable $callback = null) { + public function removeListener($scope = null, $method = null, ?callable $callback = null) { $this->__call(__FUNCTION__, func_get_args()); } diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index acd91c56d3f..9f1a1e357e9 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -124,7 +124,7 @@ class Node implements INode { /** * @param string[] $hooks */ - protected function sendHooks($hooks, array $args = null) { + protected function sendHooks($hooks, ?array $args = null) { $args = !empty($args) ? $args : [$this]; /** @var IEventDispatcher $dispatcher */ $dispatcher = \OC::$server->get(IEventDispatcher::class); diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 71bc7a6da6b..7c3ff1d2867 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -137,7 +137,7 @@ class Root extends Folder implements IRootFolder { * @param string $method optional * @param callable $callback optional */ - public function removeListener($scope = null, $method = null, callable $callback = null) { + public function removeListener($scope = null, $method = null, ?callable $callback = null) { $this->emitter->removeListener($scope, $method, $callback); } diff --git a/lib/private/Files/ObjectStore/Azure.php b/lib/private/Files/ObjectStore/Azure.php index 553f593b299..c4a349294ec 100644 --- a/lib/private/Files/ObjectStore/Azure.php +++ b/lib/private/Files/ObjectStore/Azure.php @@ -100,7 +100,7 @@ class Azure implements IObjectStore { return $blob->getContentStream(); } - public function writeObject($urn, $stream, string $mimetype = null) { + public function writeObject($urn, $stream, ?string $mimetype = null) { $options = new CreateBlockBlobOptions(); if ($mimetype) { $options->setContentType($mimetype); diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 7eb284fc774..ef4d2f7ca13 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -494,7 +494,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil return $result; } - public function writeStream(string $path, $stream, int $size = null): int { + public function writeStream(string $path, $stream, ?int $size = null): int { $stat = $this->stat($path); if (empty($stat)) { // create new file diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index e0a94df1d99..b7ec047850b 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -106,7 +106,7 @@ trait S3ObjectTrait { * @param string|null $mimetype the mimetype to set for the remove object @since 22.0.0 * @throws \Exception when something goes wrong, message will be logged */ - protected function writeSingle(string $urn, StreamInterface $stream, string $mimetype = null): void { + protected function writeSingle(string $urn, StreamInterface $stream, ?string $mimetype = null): void { $this->getConnection()->putObject([ 'Bucket' => $this->bucket, 'Key' => $urn, @@ -126,7 +126,7 @@ trait S3ObjectTrait { * @param string|null $mimetype the mimetype to set for the remove object * @throws \Exception when something goes wrong, message will be logged */ - protected function writeMultiPart(string $urn, StreamInterface $stream, string $mimetype = null): void { + protected function writeMultiPart(string $urn, StreamInterface $stream, ?string $mimetype = null): void { $uploader = new MultipartUploader($this->getConnection(), $stream, [ 'bucket' => $this->bucket, 'concurrency' => $this->concurrency, @@ -159,7 +159,7 @@ trait S3ObjectTrait { * @throws \Exception when something goes wrong, message will be logged * @since 7.0.0 */ - public function writeObject($urn, $stream, string $mimetype = null) { + public function writeObject($urn, $stream, ?string $mimetype = null) { $psrStream = Utils::streamFor($stream); // ($psrStream->isSeekable() && $psrStream->getSize() !== null) evaluates to true for a On-Seekable stream diff --git a/lib/private/Files/ObjectStore/StorageObjectStore.php b/lib/private/Files/ObjectStore/StorageObjectStore.php index 85926be897e..d968adb3c29 100644 --- a/lib/private/Files/ObjectStore/StorageObjectStore.php +++ b/lib/private/Files/ObjectStore/StorageObjectStore.php @@ -64,7 +64,7 @@ class StorageObjectStore implements IObjectStore { throw new \Exception(); } - public function writeObject($urn, $stream, string $mimetype = null) { + public function writeObject($urn, $stream, ?string $mimetype = null) { $handle = $this->storage->fopen($urn, 'w'); if ($handle) { stream_copy_to_stream($stream, $handle); diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index b463cb9d44d..68618f136b2 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -45,7 +45,7 @@ class Swift implements IObjectStore { /** @var SwiftFactory */ private $swiftFactory; - public function __construct($params, SwiftFactory $connectionFactory = null) { + public function __construct($params, ?SwiftFactory $connectionFactory = null) { $this->swiftFactory = $connectionFactory ?: new SwiftFactory( \OC::$server->getMemCacheFactory()->createDistributed('swift::'), $params, @@ -74,7 +74,7 @@ class Swift implements IObjectStore { return $this->params['container']; } - public function writeObject($urn, $stream, string $mimetype = null) { + public function writeObject($urn, $stream, ?string $mimetype = null) { $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('swiftwrite'); file_put_contents($tmpFile, $stream); $handle = fopen($tmpFile, 'rb'); diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 0d4e8d29295..c236541390f 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -882,7 +882,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { * @param int $size * @return int */ - public function writeStream(string $path, $stream, int $size = null): int { + public function writeStream(string $path, $stream, ?int $size = null): int { $target = $this->fopen($path, 'w'); if (!$target) { throw new GenericFileException("Failed to open $path for writing"); diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index c49cf91dc91..909b124ff64 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -642,7 +642,7 @@ class Local extends \OC\Files\Storage\Common { } } - public function writeStream(string $path, $stream, int $size = null): int { + public function writeStream(string $path, $stream, ?int $size = null): int { /** @var int|false $result We consider here that returned size will never be a float because we write less than 4GB */ $result = $this->file_put_contents($path, $stream); if (is_resource($stream)) { diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 7ce4338256f..e68e1f65048 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -107,15 +107,15 @@ class Encryption extends Wrapper { */ public function __construct( $parameters, - IManager $encryptionManager = null, - Util $util = null, - LoggerInterface $logger = null, - IFile $fileHelper = null, + ?IManager $encryptionManager = null, + ?Util $util = null, + ?LoggerInterface $logger = null, + ?IFile $fileHelper = null, $uid = null, - IStorage $keyStorage = null, - Update $update = null, - Manager $mountManager = null, - ArrayCache $arrayCache = null + ?IStorage $keyStorage = null, + ?Update $update = null, + ?Manager $mountManager = null, + ?ArrayCache $arrayCache = null ) { $this->mountPoint = $parameters['mountPoint']; $this->mount = $parameters['mount']; @@ -1062,7 +1062,7 @@ class Encryption extends Wrapper { return $encryptionModule->shouldEncrypt($fullPath); } - public function writeStream(string $path, $stream, int $size = null): int { + public function writeStream(string $path, $stream, ?int $size = null): int { // always fall back to fopen $target = $this->fopen($path, 'w'); [$count, $result] = \OC_Helper::streamCopy($stream, $target); diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 592acd418ec..6c185112b23 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -514,7 +514,7 @@ class Jail extends Wrapper { return $this->propagator; } - public function writeStream(string $path, $stream, int $size = null): int { + public function writeStream(string $path, $stream, ?int $size = null): int { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(IWriteStreamStorage::class)) { /** @var IWriteStreamStorage $storage */ diff --git a/lib/private/Files/Storage/Wrapper/KnownMtime.php b/lib/private/Files/Storage/Wrapper/KnownMtime.php index dde209c44ab..9a71dc90367 100644 --- a/lib/private/Files/Storage/Wrapper/KnownMtime.php +++ b/lib/private/Files/Storage/Wrapper/KnownMtime.php @@ -132,7 +132,7 @@ class KnownMtime extends Wrapper { return $result; } - public function writeStream(string $path, $stream, int $size = null): int { + public function writeStream(string $path, $stream, ?int $size = null): int { $result = parent::writeStream($path, $stream, $size); if ($result) { $this->knowMtimes->set($path, $this->clock->now()->getTimestamp()); diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index 2c50bbdb11f..2e96733ec66 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -646,7 +646,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea return $this->getWrapperStorage()->needsPartFile(); } - public function writeStream(string $path, $stream, int $size = null): int { + public function writeStream(string $path, $stream, ?int $size = null): int { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(IWriteStreamStorage::class)) { /** @var IWriteStreamStorage $storage */ diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php index c57991f35a9..895126653f7 100644 --- a/lib/private/Files/Stream/Encryption.php +++ b/lib/private/Files/Stream/Encryption.php @@ -321,7 +321,7 @@ class Encryption extends Wrapper { $result .= substr($this->cache, $blockPosition, $remainingLength); $this->position += $remainingLength; $count = 0; - // otherwise remainder of current block is fetched, the block is flushed and the position updated + // otherwise remainder of current block is fetched, the block is flushed and the position updated } else { $result .= substr($this->cache, $blockPosition); $this->flush(); @@ -389,8 +389,8 @@ class Encryption extends Wrapper { $this->position += $remainingLength; $length += $remainingLength; $data = ''; - // if $data doesn't fit the current block, the fill the current block and reiterate - // after the block is filled, it is flushed and $data is updatedxxx + // if $data doesn't fit the current block, the fill the current block and reiterate + // after the block is filled, it is flushed and $data is updatedxxx } else { $this->cache = substr($this->cache, 0, $blockPosition) . substr($data, 0, $this->unencryptedBlockSize - $blockPosition); diff --git a/lib/private/Files/Template/TemplateManager.php b/lib/private/Files/Template/TemplateManager.php index 9d9f6416208..3f3c36de5f1 100644 --- a/lib/private/Files/Template/TemplateManager.php +++ b/lib/private/Files/Template/TemplateManager.php @@ -262,7 +262,7 @@ class TemplateManager implements ITemplateManager { return $this->config->getUserValue($this->userId, 'core', 'templateDirectory', ''); } - public function initializeTemplateDirectory(string $path = null, string $userId = null, $copyTemplates = true): string { + public function initializeTemplateDirectory(?string $path = null, ?string $userId = null, $copyTemplates = true): string { if ($userId !== null) { $this->userId = $userId; } diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index ae6a0a33d2b..997d6e1a34e 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -198,7 +198,7 @@ class Scanner extends PublicEmitter { * @throws ForbiddenException * @throws NotFoundException */ - public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECURSIVE, callable $mountFilter = null) { + public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECURSIVE, ?callable $mountFilter = null) { if (!Filesystem::isValidPath($dir)) { throw new \InvalidArgumentException('Invalid path to scan'); } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 5ad48e26cc5..98b597dbd4d 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -802,14 +802,14 @@ class View { } else { $result = false; } - // moving a file/folder within the same mount point + // moving a file/folder within the same mount point } elseif ($storage1 === $storage2) { if ($storage1) { $result = $storage1->rename($internalPath1, $internalPath2); } else { $result = false; } - // moving a file/folder between storages (from $storage1 to $storage2) + // moving a file/folder between storages (from $storage1 to $storage2) } else { $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2); } @@ -1428,7 +1428,7 @@ class View { * @param string $mimetype_filter limit returned content to this mimetype or mimepart * @return FileInfo[] */ - public function getDirectoryContent($directory, $mimetype_filter = '', \OCP\Files\FileInfo $directoryInfo = null) { + public function getDirectoryContent($directory, $mimetype_filter = '', ?\OCP\Files\FileInfo $directoryInfo = null) { $this->assertPathLength($directory); if (!Filesystem::isValidPath($directory)) { return []; @@ -1733,7 +1733,7 @@ class View { * @return string * @throws NotFoundException */ - public function getPath($id, int $storageId = null) { + public function getPath($id, ?int $storageId = null) { $id = (int)$id; $manager = Filesystem::getMountManager(); $mounts = $manager->findIn($this->fakeRoot); |