diff options
author | Robin Appelman <robin@icewind.nl> | 2022-02-10 14:15:07 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2022-03-04 16:28:11 +0100 |
commit | 7630d7a934c8e8036313824d95e5aa9de80dab96 (patch) | |
tree | 4fd8a8f406a17e9d0a48fb02fed84f88cbb01b18 | |
parent | 69a6efba477685f0f0c66c06d06ae27675acbf96 (diff) | |
download | nextcloud-server-7630d7a934c8e8036313824d95e5aa9de80dab96.tar.gz nextcloud-server-7630d7a934c8e8036313824d95e5aa9de80dab96.zip |
more type hints for ICachedMountInfo and IMountManager
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Files/Config/CachedMountFileInfo.php | 3 | ||||
-rw-r--r-- | lib/private/Files/Config/CachedMountInfo.php | 55 | ||||
-rw-r--r-- | lib/private/Files/Config/LazyStorageMountInfo.php | 16 | ||||
-rw-r--r-- | lib/private/Files/Mount/Manager.php | 12 | ||||
-rw-r--r-- | lib/public/Files/Config/ICachedMountFileInfo.php | 4 | ||||
-rw-r--r-- | lib/public/Files/Config/ICachedMountInfo.php | 16 | ||||
-rw-r--r-- | lib/public/Files/Mount/IMountManager.php | 14 |
7 files changed, 46 insertions, 74 deletions
diff --git a/lib/private/Files/Config/CachedMountFileInfo.php b/lib/private/Files/Config/CachedMountFileInfo.php index 71a6ddb9ea9..11a9a505808 100644 --- a/lib/private/Files/Config/CachedMountFileInfo.php +++ b/lib/private/Files/Config/CachedMountFileInfo.php @@ -27,8 +27,7 @@ use OCP\Files\Config\ICachedMountFileInfo; use OCP\IUser; class CachedMountFileInfo extends CachedMountInfo implements ICachedMountFileInfo { - /** @var string */ - private $internalPath; + private string $internalPath; public function __construct( IUser $user, diff --git a/lib/private/Files/Config/CachedMountInfo.php b/lib/private/Files/Config/CachedMountInfo.php index c70dba100a4..43c9fae63ec 100644 --- a/lib/private/Files/Config/CachedMountInfo.php +++ b/lib/private/Files/Config/CachedMountInfo.php @@ -28,38 +28,13 @@ use OCP\Files\Node; use OCP\IUser; class CachedMountInfo implements ICachedMountInfo { - /** - * @var IUser - */ - protected $user; - - /** - * @var int - */ - protected $storageId; - - /** - * @var int - */ - protected $rootId; - - /** - * @var string - */ - protected $mountPoint; - - /** - * @var int|null - */ - protected $mountId; - - /** - * @var string - */ - protected $rootInternalPath; - - /** @var string */ - protected $mountProvider; + protected IUser $user; + protected int $storageId; + protected int $rootId; + protected string $mountPoint; + protected ?int $mountId; + protected string $rootInternalPath; + protected string $mountProvider; /** * CachedMountInfo constructor. @@ -95,28 +70,28 @@ class CachedMountInfo implements ICachedMountInfo { /** * @return IUser */ - public function getUser() { + public function getUser(): IUser { return $this->user; } /** * @return int the numeric storage id of the mount */ - public function getStorageId() { + public function getStorageId(): int { return $this->storageId; } /** * @return int the fileid of the root of the mount */ - public function getRootId() { + public function getRootId(): int { return $this->rootId; } /** - * @return Node the root node of the mount + * @return Node|null the root node of the mount */ - public function getMountPointNode() { + public function getMountPointNode(): ?Node { // TODO injection etc Filesystem::initMountPoints($this->getUser()->getUID()); $userNode = \OC::$server->getUserFolder($this->getUser()->getUID()); @@ -131,7 +106,7 @@ class CachedMountInfo implements ICachedMountInfo { /** * @return string the mount point of the mount for the user */ - public function getMountPoint() { + public function getMountPoint(): string { return $this->mountPoint; } @@ -141,7 +116,7 @@ class CachedMountInfo implements ICachedMountInfo { * @return int|null mount id or null if not applicable * @since 9.1.0 */ - public function getMountId() { + public function getMountId(): ?int { return $this->mountId; } @@ -150,7 +125,7 @@ class CachedMountInfo implements ICachedMountInfo { * * @return string */ - public function getRootInternalPath() { + public function getRootInternalPath(): string { return $this->rootInternalPath; } diff --git a/lib/private/Files/Config/LazyStorageMountInfo.php b/lib/private/Files/Config/LazyStorageMountInfo.php index fd3bbcbe0fb..78055a2cdb8 100644 --- a/lib/private/Files/Config/LazyStorageMountInfo.php +++ b/lib/private/Files/Config/LazyStorageMountInfo.php @@ -25,8 +25,7 @@ use OCP\Files\Mount\IMountPoint; use OCP\IUser; class LazyStorageMountInfo extends CachedMountInfo { - /** @var IMountPoint */ - private $mount; + private IMountPoint $mount; /** * CachedMountInfo constructor. @@ -37,12 +36,15 @@ class LazyStorageMountInfo extends CachedMountInfo { public function __construct(IUser $user, IMountPoint $mount) { $this->user = $user; $this->mount = $mount; + $this->rootId = 0; + $this->storageId = 0; + $this->mountPoint = ''; } /** * @return int the numeric storage id of the mount */ - public function getStorageId() { + public function getStorageId(): int { if (!$this->storageId) { $this->storageId = $this->mount->getNumericStorageId(); } @@ -52,7 +54,7 @@ class LazyStorageMountInfo extends CachedMountInfo { /** * @return int the fileid of the root of the mount */ - public function getRootId() { + public function getRootId(): int { if (!$this->rootId) { $this->rootId = $this->mount->getStorageRootId(); } @@ -62,14 +64,14 @@ class LazyStorageMountInfo extends CachedMountInfo { /** * @return string the mount point of the mount for the user */ - public function getMountPoint() { + public function getMountPoint(): string { if (!$this->mountPoint) { $this->mountPoint = $this->mount->getMountPoint(); } return parent::getMountPoint(); } - public function getMountId() { + public function getMountId(): ?int { return $this->mount->getMountId(); } @@ -78,7 +80,7 @@ class LazyStorageMountInfo extends CachedMountInfo { * * @return string */ - public function getRootInternalPath() { + public function getRootInternalPath(): string { return $this->mount->getInternalPath($this->mount->getMountPoint()); } diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php index 22b05b1f384..cfb008a94d1 100644 --- a/lib/private/Files/Mount/Manager.php +++ b/lib/private/Files/Mount/Manager.php @@ -35,13 +35,9 @@ use OCP\Files\Mount\IMountPoint; class Manager implements IMountManager { /** @var MountPoint[] */ - private $mounts = []; - - /** @var CappedMemoryCache */ - private $pathCache; - - /** @var CappedMemoryCache */ - private $inPathCache; + private array $mounts = []; + private CappedMemoryCache $pathCache; + private CappedMemoryCache $inPathCache; public function __construct() { $this->pathCache = new CappedMemoryCache(); @@ -99,7 +95,7 @@ class Manager implements IMountManager { * @param string $path * @return MountPoint|null */ - public function find(string $path) { + public function find(string $path): ?MountPoint { $this->setupForFind($path); $path = Filesystem::normalizePath($path); diff --git a/lib/public/Files/Config/ICachedMountFileInfo.php b/lib/public/Files/Config/ICachedMountFileInfo.php index 4de0a1218b4..e6aa2ec38c8 100644 --- a/lib/public/Files/Config/ICachedMountFileInfo.php +++ b/lib/public/Files/Config/ICachedMountFileInfo.php @@ -34,11 +34,11 @@ interface ICachedMountFileInfo extends ICachedMountInfo { * @return string * @since 13.0.0 */ - public function getInternalPath(); + public function getInternalPath(): string; /** * @return string * @since 13.0.0 */ - public function getPath(); + public function getPath(): string; } diff --git a/lib/public/Files/Config/ICachedMountInfo.php b/lib/public/Files/Config/ICachedMountInfo.php index 812e79cdbc8..dafd2423fdc 100644 --- a/lib/public/Files/Config/ICachedMountInfo.php +++ b/lib/public/Files/Config/ICachedMountInfo.php @@ -35,31 +35,31 @@ interface ICachedMountInfo { * @return IUser * @since 9.0.0 */ - public function getUser(); + public function getUser(): IUser; /** * @return int the numeric storage id of the mount * @since 9.0.0 */ - public function getStorageId(); + public function getStorageId(): int; /** * @return int the fileid of the root of the mount * @since 9.0.0 */ - public function getRootId(); + public function getRootId(): int; /** - * @return Node the root node of the mount + * @return Node|null the root node of the mount * @since 9.0.0 */ - public function getMountPointNode(); + public function getMountPointNode(): ?Node; /** * @return string the mount point of the mount for the user * @since 9.0.0 */ - public function getMountPoint(); + public function getMountPoint(): string; /** * Get the id of the configured mount @@ -67,7 +67,7 @@ interface ICachedMountInfo { * @return int|null mount id or null if not applicable * @since 9.1.0 */ - public function getMountId(); + public function getMountId(): ?int; /** * Get the internal path (within the storage) of the root of the mount @@ -75,7 +75,7 @@ interface ICachedMountInfo { * @return string * @since 11.0.0 */ - public function getRootInternalPath(); + public function getRootInternalPath(): string; /** * Get the class of the mount provider that this mount originates from diff --git a/lib/public/Files/Mount/IMountManager.php b/lib/public/Files/Mount/IMountManager.php index 1e8c674f8f5..eb8adc3223a 100644 --- a/lib/public/Files/Mount/IMountManager.php +++ b/lib/public/Files/Mount/IMountManager.php @@ -37,7 +37,7 @@ interface IMountManager { /** * Add a new mount * - * @param \OCP\Files\Mount\IMountPoint $mount + * @param IMountPoint $mount * @since 8.2.0 */ public function addMount(IMountPoint $mount); @@ -63,16 +63,16 @@ interface IMountManager { * Find the mount for $path * * @param string $path - * @return \OCP\Files\Mount\IMountPoint|null + * @return IMountPoint|null * @since 8.2.0 */ - public function find(string $path); + public function find(string $path): ?IMountPoint; /** * Find all mounts in $path * * @param string $path - * @return \OCP\Files\Mount\IMountPoint[] + * @return IMountPoint[] * @since 8.2.0 */ public function findIn(string $path): array; @@ -88,13 +88,13 @@ interface IMountManager { * Find mounts by storage id * * @param string $id - * @return \OCP\Files\Mount\IMountPoint[] + * @return IMountPoint[] * @since 8.2.0 */ public function findByStorageId(string $id): array; /** - * @return \OCP\Files\Mount\IMountPoint[] + * @return IMountPoint[] * @since 8.2.0 */ public function getAll(): array; @@ -103,7 +103,7 @@ interface IMountManager { * Find mounts by numeric storage id * * @param int $id - * @return \OCP\Files\Mount\IMountPoint[] + * @return IMountPoint[] * @since 8.2.0 */ public function findByNumericId(int $id): array; |