aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorKate <26026535+provokateurin@users.noreply.github.com>2024-10-08 15:20:17 +0200
committerGitHub <noreply@github.com>2024-10-08 15:20:17 +0200
commit614d8c23a0d628ef3d39b28c760f0988c80ad5a9 (patch)
treefa2cb84ce94538f19b841ff98e66a48c65cd6c37 /lib/public
parente11520e6af983fc234bda5f0f8290ac3424a66a1 (diff)
parent14e67345472e163be1ec28f70c4f0f2e3596f8f5 (diff)
downloadnextcloud-server-614d8c23a0d628ef3d39b28c760f0988c80ad5a9.tar.gz
nextcloud-server-614d8c23a0d628ef3d39b28c760f0988c80ad5a9.zip
Merge pull request #48494 from nextcloud/refactor/storage/strong-param-types
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/Files/Storage/IChunkedFileWrite.php9
-rw-r--r--lib/public/Files/Storage/ILockingStorage.php9
-rw-r--r--lib/public/Files/Storage/INotifyStorage.php3
-rw-r--r--lib/public/Files/Storage/ISharedStorage.php1
-rw-r--r--lib/public/Files/Storage/IStorage.php133
-rw-r--r--lib/public/Files/Storage/IStorageFactory.php9
-rw-r--r--lib/public/Files/Storage/IWriteStreamStorage.php3
7 files changed, 48 insertions, 119 deletions
diff --git a/lib/public/Files/Storage/IChunkedFileWrite.php b/lib/public/Files/Storage/IChunkedFileWrite.php
index 1095ee7cbfc..e166a7f3b1f 100644
--- a/lib/public/Files/Storage/IChunkedFileWrite.php
+++ b/lib/public/Files/Storage/IChunkedFileWrite.php
@@ -24,28 +24,19 @@ interface IChunkedFileWrite extends IStorage {
public function startChunkedWrite(string $targetPath): string;
/**
- * @param string $targetPath
- * @param string $writeToken
- * @param string $chunkId
* @param resource $data
- * @param int|null $size
* @throws GenericFileException
* @since 26.0.0
*/
public function putChunkedWritePart(string $targetPath, string $writeToken, string $chunkId, $data, ?int $size = null): ?array;
/**
- * @param string $targetPath
- * @param string $writeToken
- * @return int
* @throws GenericFileException
* @since 26.0.0
*/
public function completeChunkedWrite(string $targetPath, string $writeToken): int;
/**
- * @param string $targetPath
- * @param string $writeToken
* @throws GenericFileException
* @since 26.0.0
*/
diff --git a/lib/public/Files/Storage/ILockingStorage.php b/lib/public/Files/Storage/ILockingStorage.php
index abec7d91b83..ceedf33ceab 100644
--- a/lib/public/Files/Storage/ILockingStorage.php
+++ b/lib/public/Files/Storage/ILockingStorage.php
@@ -21,27 +21,24 @@ interface ILockingStorage {
/**
* @param string $path The path of the file to acquire the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
- * @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
* @since 9.0.0
*/
- public function acquireLock($path, $type, ILockingProvider $provider);
+ public function acquireLock(string $path, int $type, ILockingProvider $provider);
/**
* @param string $path The path of the file to acquire the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
- * @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
* @since 9.0.0
*/
- public function releaseLock($path, $type, ILockingProvider $provider);
+ public function releaseLock(string $path, int $type, ILockingProvider $provider);
/**
* @param string $path The path of the file to change the lock for
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
- * @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
* @since 9.0.0
*/
- public function changeLock($path, $type, ILockingProvider $provider);
+ public function changeLock(string $path, int $type, ILockingProvider $provider);
}
diff --git a/lib/public/Files/Storage/INotifyStorage.php b/lib/public/Files/Storage/INotifyStorage.php
index 8656f709116..0e5cf53af21 100644
--- a/lib/public/Files/Storage/INotifyStorage.php
+++ b/lib/public/Files/Storage/INotifyStorage.php
@@ -36,10 +36,9 @@ interface INotifyStorage {
/**
* Start the notification handler for this storage
*
- * @param $path
* @return INotifyHandler
*
* @since 12.0.0
*/
- public function notify($path);
+ public function notify(string $path);
}
diff --git a/lib/public/Files/Storage/ISharedStorage.php b/lib/public/Files/Storage/ISharedStorage.php
index 836c4aefcdb..69fc60750c5 100644
--- a/lib/public/Files/Storage/ISharedStorage.php
+++ b/lib/public/Files/Storage/ISharedStorage.php
@@ -19,7 +19,6 @@ interface ISharedStorage extends IStorage {
/**
* The the associated share
*
- * @return IShare
* @since 30.0.0
*/
public function getShare(): IShare;
diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php
index 924e91e8164..5f6c8a0e8a0 100644
--- a/lib/public/Files/Storage/IStorage.php
+++ b/lib/public/Files/Storage/IStorage.php
@@ -40,280 +40,243 @@ interface IStorage {
* see https://www.php.net/manual/en/function.mkdir.php
* implementations need to implement a recursive mkdir
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function mkdir($path);
+ public function mkdir(string $path);
/**
* see https://www.php.net/manual/en/function.rmdir.php
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function rmdir($path);
+ public function rmdir(string $path);
/**
* see https://www.php.net/manual/en/function.opendir.php
*
- * @param string $path
* @return resource|false
* @since 9.0.0
*/
- public function opendir($path);
+ public function opendir(string $path);
/**
* see https://www.php.net/manual/en/function.is-dir.php
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function is_dir($path);
+ public function is_dir(string $path);
/**
* see https://www.php.net/manual/en/function.is-file.php
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function is_file($path);
+ public function is_file(string $path);
/**
* see https://www.php.net/manual/en/function.stat.php
* only the following keys are required in the result: size and mtime
*
- * @param string $path
* @return array|false
* @since 9.0.0
*/
- public function stat($path);
+ public function stat(string $path);
/**
* see https://www.php.net/manual/en/function.filetype.php
*
- * @param string $path
* @return string|false
* @since 9.0.0
*/
- public function filetype($path);
+ public function filetype(string $path);
/**
* see https://www.php.net/manual/en/function.filesize.php
* The result for filesize when called on a folder is required to be 0
*
- * @param string $path
* @return int|float|false
* @since 9.0.0
*/
- public function filesize($path);
+ public function filesize(string $path);
/**
* check if a file can be created in $path
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function isCreatable($path);
+ public function isCreatable(string $path);
/**
* check if a file can be read
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function isReadable($path);
+ public function isReadable(string $path);
/**
* check if a file can be written to
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function isUpdatable($path);
+ public function isUpdatable(string $path);
/**
* check if a file can be deleted
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function isDeletable($path);
+ public function isDeletable(string $path);
/**
* check if a file can be shared
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function isSharable($path);
+ public function isSharable(string $path);
/**
* get the full permissions of a path.
* Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php
*
- * @param string $path
* @return int
* @since 9.0.0
*/
- public function getPermissions($path);
+ public function getPermissions(string $path);
/**
- * see https://www.php.net/manual/en/function.file_exists.php
+ * see https://www.php.net/manual/en/function.file-exists.php
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function file_exists($path);
+ public function file_exists(string $path);
/**
* see https://www.php.net/manual/en/function.filemtime.php
*
- * @param string $path
* @return int|false
* @since 9.0.0
*/
- public function filemtime($path);
+ public function filemtime(string $path);
/**
- * see https://www.php.net/manual/en/function.file_get_contents.php
+ * see https://www.php.net/manual/en/function.file-get-contents.php
*
- * @param string $path
* @return string|false
* @since 9.0.0
*/
- public function file_get_contents($path);
+ public function file_get_contents(string $path);
/**
- * see https://www.php.net/manual/en/function.file_put_contents.php
+ * see https://www.php.net/manual/en/function.file-put-contents.php
*
- * @param string $path
- * @param mixed $data
* @return int|float|false
* @since 9.0.0
*/
- public function file_put_contents($path, $data);
+ public function file_put_contents(string $path, mixed $data);
/**
* see https://www.php.net/manual/en/function.unlink.php
*
- * @param string $path
* @return bool
* @since 9.0.0
*/
- public function unlink($path);
+ public function unlink(string $path);
/**
* see https://www.php.net/manual/en/function.rename.php
*
- * @param string $source
- * @param string $target
* @return bool
* @since 9.0.0
*/
- public function rename($source, $target);
+ public function rename(string $source, string $target);
/**
* see https://www.php.net/manual/en/function.copy.php
*
- * @param string $source
- * @param string $target
* @return bool
* @since 9.0.0
*/
- public function copy($source, $target);
+ public function copy(string $source, string $target);
/**
* see https://www.php.net/manual/en/function.fopen.php
*
- * @param string $path
- * @param string $mode
* @return resource|false
* @since 9.0.0
*/
- public function fopen($path, $mode);
+ public function fopen(string $path, string $mode);
/**
* get the mimetype for a file or folder
* The mimetype for a folder is required to be "httpd/unix-directory"
*
- * @param string $path
* @return string|false
* @since 9.0.0
*/
- public function getMimeType($path);
+ public function getMimeType(string $path);
/**
* see https://www.php.net/manual/en/function.hash-file.php
*
- * @param string $type
- * @param string $path
- * @param bool $raw
* @return string|false
* @since 9.0.0
*/
- public function hash($type, $path, $raw = false);
+ public function hash(string $type, string $path, bool $raw = false);
/**
* see https://www.php.net/manual/en/function.disk-free-space.php
*
- * @param string $path
* @return int|float|false
* @since 9.0.0
*/
- public function free_space($path);
+ public function free_space(string $path);
/**
* see https://www.php.net/manual/en/function.touch.php
* If the backend does not support the operation, false should be returned
*
- * @param string $path
- * @param int $mtime
* @return bool
* @since 9.0.0
*/
- public function touch($path, $mtime = null);
+ public function touch(string $path, ?int $mtime = null);
/**
* get the path to a local version of the file.
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
- * @param string $path
* @return string|false
* @since 9.0.0
*/
- public function getLocalFile($path);
+ public function getLocalFile(string $path);
/**
* check if a file or folder has been updated since $time
*
- * @param string $path
- * @param int $time
* @return bool
* @since 9.0.0
*
* hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed.
* returning true for other changes in the folder is optional
*/
- public function hasUpdated($path, $time);
+ public function hasUpdated(string $path, int $time);
/**
* get the ETag for a file or folder
*
- * @param string $path
* @return string|false
* @since 9.0.0
*/
- public function getETag($path);
+ public function getETag(string $path);
/**
* Returns whether the storage is local, which means that files
@@ -331,51 +294,41 @@ interface IStorage {
* Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
*
* @template T of IStorage
- * @param string $class
* @psalm-param class-string<T> $class
* @return bool
* @since 9.0.0
* @psalm-assert-if-true T $this
*/
- public function instanceOfStorage($class);
+ public function instanceOfStorage(string $class);
/**
* A custom storage implementation can return an url for direct download of a give file.
*
* For now the returned array can hold the parameter url - in future more attributes might follow.
*
- * @param string $path
* @return array|false
* @since 9.0.0
*/
- public function getDirectDownload($path);
+ public function getDirectDownload(string $path);
/**
- * @param string $path the path of the target folder
- * @param string $fileName the name of the file itself
* @return void
* @throws InvalidPathException
* @since 9.0.0
*/
- public function verifyPath($path, $fileName);
+ public function verifyPath(string $path, string $fileName);
/**
- * @param IStorage $sourceStorage
- * @param string $sourceInternalPath
- * @param string $targetInternalPath
* @return bool
* @since 9.0.0
*/
- public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath);
+ public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath);
/**
- * @param IStorage $sourceStorage
- * @param string $sourceInternalPath
- * @param string $targetInternalPath
* @return bool
* @since 9.0.0
*/
- public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath);
+ public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath);
/**
* Test a storage for availability
@@ -393,10 +346,9 @@ interface IStorage {
/**
* @since 9.0.0
- * @param bool $isAvailable
* @return void
*/
- public function setAvailability($isAvailable);
+ public function setAvailability(bool $isAvailable);
/**
* @since 12.0.0
@@ -406,19 +358,16 @@ interface IStorage {
public function needsPartFile();
/**
- * @param string $path path for which to retrieve the owner
* @return string|false
* @since 9.0.0
*/
- public function getOwner($path);
+ public function getOwner(string $path);
/**
- * @param string $path
- * @param IStorage|null $storage
* @return ICache
* @since 9.0.0
*/
- public function getCache($path = '', $storage = null);
+ public function getCache(string $path = '', ?IStorage $storage = null);
/**
* @return IPropagator
@@ -450,7 +399,7 @@ interface IStorage {
* This can be used for storages that do not have a dedicated owner, where we want to
* pass the user that we setup the mountpoint for along to the storage layer
*
- * @param string|null $user Owner user id
+ * @param ?string $user Owner user id
* @return void
* @since 30.0.0
*/
diff --git a/lib/public/Files/Storage/IStorageFactory.php b/lib/public/Files/Storage/IStorageFactory.php
index 6d44b39274e..24f87d2e775 100644
--- a/lib/public/Files/Storage/IStorageFactory.php
+++ b/lib/public/Files/Storage/IStorageFactory.php
@@ -19,20 +19,15 @@ interface IStorageFactory {
*
* $callback should be a function of type (string $mountPoint, Storage $storage) => Storage
*
- * @param string $wrapperName
- * @param callable $callback
* @return bool true if the wrapper was added, false if there was already a wrapper with this
* name registered
* @since 8.0.0
*/
- public function addStorageWrapper($wrapperName, $callback);
+ public function addStorageWrapper(string $wrapperName, callable $callback);
/**
- * @param IMountPoint $mountPoint
- * @param string $class
- * @param array $arguments
* @return IStorage
* @since 8.0.0
*/
- public function getInstance(IMountPoint $mountPoint, $class, $arguments);
+ public function getInstance(IMountPoint $mountPoint, string $class, array $arguments);
}
diff --git a/lib/public/Files/Storage/IWriteStreamStorage.php b/lib/public/Files/Storage/IWriteStreamStorage.php
index 6da34563848..b03f46ef2bc 100644
--- a/lib/public/Files/Storage/IWriteStreamStorage.php
+++ b/lib/public/Files/Storage/IWriteStreamStorage.php
@@ -19,9 +19,8 @@ interface IWriteStreamStorage extends IStorage {
/**
* Write the data from a stream to a file
*
- * @param string $path
* @param resource $stream
- * @param int|null $size the size of the stream if known in advance
+ * @param ?int $size the size of the stream if known in advance
* @return int the number of bytes written
* @throws GenericFileException
* @since 15.0.0