diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-05-03 12:15:24 +0300 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-05-12 16:06:18 +0300 |
commit | ec6b83cc1891214c7fa3a236626807b4335f9a2f (patch) | |
tree | b5f12993172528ddec15b7b8ae6a09a0080fedd7 /apps/files_external | |
parent | 5a0b28d603e142051967175f023b698ff7e262db (diff) |
Add stricter psalm type for CappedMemoryCachecleanup/cappedmemorycache
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/files_external')
-rw-r--r-- | apps/files_external/lib/Lib/Storage/AmazonS3.php | 28 | ||||
-rw-r--r-- | apps/files_external/lib/Lib/Storage/SMB.php | 8 |
2 files changed, 15 insertions, 21 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php index d3e9605e5a1..e7a8c5f9329 100644 --- a/apps/files_external/lib/Lib/Storage/AmazonS3.php +++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php @@ -54,6 +54,7 @@ use OCP\Files\IMimeTypeDetector; use OCP\ICacheFactory; use OCP\IMemcache; use OCP\Server; +use OCP\ICache; class AmazonS3 extends \OC\Files\Storage\Common { use S3ConnectionTrait; @@ -63,23 +64,18 @@ class AmazonS3 extends \OC\Files\Storage\Common { return false; } - /** @var CappedMemoryCache|Result[] */ - private $objectCache; + /** @var CappedMemoryCache<array|false> */ + private CappedMemoryCache $objectCache; - /** @var CappedMemoryCache|bool[] */ - private $directoryCache; + /** @var CappedMemoryCache<bool> */ + private CappedMemoryCache $directoryCache; - /** @var CappedMemoryCache|array */ - private $filesCache; + /** @var CappedMemoryCache<array> */ + private CappedMemoryCache $filesCache; - /** @var IMimeTypeDetector */ - private $mimeDetector; - - /** @var bool|null */ - private $versioningEnabled = null; - - /** @var IMemcache */ - private $memCache; + private IMimeTypeDetector $mimeDetector; + private ?bool $versioningEnabled = null; + private ICache $memCache; public function __construct($parameters) { parent::__construct($parameters); @@ -146,10 +142,9 @@ class AmazonS3 extends \OC\Files\Storage\Common { } /** - * @param $key * @return array|false */ - private function headObject($key) { + private function headObject(string $key) { if (!isset($this->objectCache[$key])) { try { $this->objectCache[$key] = $this->getConnection()->headObject([ @@ -165,6 +160,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { } if (is_array($this->objectCache[$key]) && !isset($this->objectCache[$key]["Key"])) { + /** @psalm-suppress InvalidArgument Psalm doesn't understand nested arrays well */ $this->objectCache[$key]["Key"] = $key; } return $this->objectCache[$key]; diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php index c2555f87b93..bdb9b4f9c8f 100644 --- a/apps/files_external/lib/Lib/Storage/SMB.php +++ b/apps/files_external/lib/Lib/Storage/SMB.php @@ -84,10 +84,8 @@ class SMB extends Common implements INotifyStorage { */ protected $root; - /** - * @var IFileInfo[] - */ - protected $statCache; + /** @var CappedMemoryCache<IFileInfo> */ + protected CappedMemoryCache $statCache; /** @var ILogger */ protected $logger; @@ -527,7 +525,7 @@ class SMB extends Common implements INotifyStorage { } try { - $this->statCache = []; + $this->statCache = new CappedMemoryCache(); $content = $this->share->dir($this->buildPath($path)); foreach ($content as $file) { if ($file->isDirectory()) { |