diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-05-03 11:15:24 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-05-12 15:06:18 +0200 |
commit | ec6b83cc1891214c7fa3a236626807b4335f9a2f (patch) | |
tree | b5f12993172528ddec15b7b8ae6a09a0080fedd7 /lib | |
parent | 5a0b28d603e142051967175f023b698ff7e262db (diff) | |
download | nextcloud-server-ec6b83cc1891214c7fa3a236626807b4335f9a2f.tar.gz nextcloud-server-ec6b83cc1891214c7fa3a236626807b4335f9a2f.zip |
Add stricter psalm type for CappedMemoryCache
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Cache/CappedMemoryCache.php | 2 | ||||
-rw-r--r-- | lib/private/Diagnostics/QueryLogger.php | 16 | ||||
-rw-r--r-- | lib/private/Encryption/File.php | 8 | ||||
-rw-r--r-- | lib/private/Encryption/Util.php | 2 | ||||
-rw-r--r-- | lib/private/Files/AppData/AppData.php | 21 | ||||
-rw-r--r-- | lib/private/Files/Config/UserMountCache.php | 27 |
6 files changed, 25 insertions, 51 deletions
diff --git a/lib/private/Cache/CappedMemoryCache.php b/lib/private/Cache/CappedMemoryCache.php index 0a3300435eb..6063b5e7110 100644 --- a/lib/private/Cache/CappedMemoryCache.php +++ b/lib/private/Cache/CappedMemoryCache.php @@ -88,7 +88,7 @@ class CappedMemoryCache implements ICache, \ArrayAccess { } /** - * @param string $key + * @param string $offset * @param T $value * @return void */ diff --git a/lib/private/Diagnostics/QueryLogger.php b/lib/private/Diagnostics/QueryLogger.php index 499947178a3..40d68d94ae3 100644 --- a/lib/private/Diagnostics/QueryLogger.php +++ b/lib/private/Diagnostics/QueryLogger.php @@ -28,15 +28,10 @@ use OC\Cache\CappedMemoryCache; use OCP\Diagnostics\IQueryLogger; class QueryLogger implements IQueryLogger { - /** - * @var \OC\Diagnostics\Query - */ - protected $activeQuery; - - /** - * @var CappedMemoryCache - */ - protected $queries; + protected int $index = 0; + protected ?Query $activeQuery = null; + /** @var CappedMemoryCache<Query> */ + protected CappedMemoryCache $queries; /** * QueryLogger constructor. @@ -74,7 +69,8 @@ class QueryLogger implements IQueryLogger { public function stopQuery() { if ($this->activated && $this->activeQuery) { $this->activeQuery->end(microtime(true)); - $this->queries[] = $this->activeQuery; + $this->queries[(string)$this->index] = $this->activeQuery; + $this->index++; $this->activeQuery = null; } } diff --git a/lib/private/Encryption/File.php b/lib/private/Encryption/File.php index 2c486dfade6..2d7e23a8883 100644 --- a/lib/private/Encryption/File.php +++ b/lib/private/Encryption/File.php @@ -47,9 +47,9 @@ class File implements \OCP\Encryption\IFile { /** * cache results of already checked folders * - * @var array + * @var CappedMemoryCache<array> */ - protected $cache; + protected CappedMemoryCache $cache; public function __construct(Util $util, IRootFolder $rootFolder, @@ -62,10 +62,10 @@ class File implements \OCP\Encryption\IFile { /** - * get list of users with access to the file + * Get list of users with access to the file * * @param string $path to the file - * @return array ['users' => $uniqueUserIds, 'public' => $public] + * @return array{users: string[], public: bool} */ public function getAccessList($path) { diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php index dc878ba8fc1..693e24c4721 100644 --- a/lib/private/Encryption/Util.php +++ b/lib/private/Encryption/Util.php @@ -220,7 +220,7 @@ class Util { * get the owner and the path for the file relative to the owners files folder * * @param string $path - * @return array + * @return array{0: string, 1: string} * @throws \BadMethodCallException */ public function getUidAndFilename($path) { diff --git a/lib/private/Files/AppData/AppData.php b/lib/private/Files/AppData/AppData.php index 53f69be7127..471de799c2f 100644 --- a/lib/private/Files/AppData/AppData.php +++ b/lib/private/Files/AppData/AppData.php @@ -38,21 +38,12 @@ use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFolder; class AppData implements IAppData { - - /** @var IRootFolder */ - private $rootFolder; - - /** @var SystemConfig */ - private $config; - - /** @var string */ - private $appId; - - /** @var Folder */ - private $folder; - - /** @var (ISimpleFolder|NotFoundException)[]|CappedMemoryCache */ - private $folders; + private IRootFolder $rootFolder; + private SystemConfig $config; + private string $appId; + private ?Folder $folder = null; + /** @var CappedMemoryCache<ISimpleFolder|NotFoundException> */ + private CappedMemoryCache $folders; /** * AppData constructor. diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index a5fe04c2cac..c326eeb0b6c 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -36,7 +36,6 @@ use OCP\Files\Config\ICachedMountInfo; use OCP\Files\Config\IUserMountCache; use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; -use OCP\ICache; use OCP\IDBConnection; use OCP\IUser; use OCP\IUserManager; @@ -46,30 +45,17 @@ use Psr\Log\LoggerInterface; * Cache mounts points per user in the cache so we can easilly look them up */ class UserMountCache implements IUserMountCache { - /** - * @var IDBConnection - */ - private $connection; - - /** - * @var IUserManager - */ - private $userManager; + private IDBConnection $connection; + private IUserManager $userManager; /** * Cached mount info. - * Map of $userId to ICachedMountInfo. - * - * @var ICache + * @var CappedMemoryCache<ICachedMountInfo[]> **/ - private $mountsForUsers; - + private CappedMemoryCache $mountsForUsers; private LoggerInterface $logger; - - /** - * @var ICache - */ - private $cacheInfoCache; + /** @var CappedMemoryCache<array> */ + private CappedMemoryCache $cacheInfoCache; /** * UserMountCache constructor. @@ -132,6 +118,7 @@ class UserMountCache implements IUserMountCache { foreach ($addedMounts as $mount) { $this->addToCache($mount); + /** @psalm-suppress InvalidArgument */ $this->mountsForUsers[$user->getUID()][] = $mount; } foreach ($removedMounts as $mount) { |