From 54031e370ac05b127d4bc799de99ce1b643adcbb Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 17 Oct 2022 12:40:35 +0200 Subject: [PATCH] Fix various other small psalm issues Signed-off-by: Carl Schwan --- apps/files_sharing/lib/Cache.php | 2 +- .../Collaboration/ShareRecipientSorter.php | 11 ++-- .../lib/Controller/ShareController.php | 2 +- apps/files_sharing/lib/External/Manager.php | 7 +-- apps/files_sharing/lib/External/Mount.php | 5 +- build/psalm-baseline.xml | 61 +------------------ lib/private/Files/Cache/Wrapper/CacheJail.php | 2 +- lib/private/Template/Base.php | 2 +- 8 files changed, 12 insertions(+), 80 deletions(-) diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php index aa45b6ab43e..b99a511312e 100644 --- a/apps/files_sharing/lib/Cache.php +++ b/apps/files_sharing/lib/Cache.php @@ -109,7 +109,7 @@ class Cache extends CacheJail { if (isset($this->numericId)) { return $this->numericId; } else { - return false; + return -1; } } diff --git a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php index 28d0d26c5be..2fd35b20a0f 100644 --- a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php +++ b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php @@ -32,12 +32,9 @@ use OCP\Share\IManager; class ShareRecipientSorter implements ISorter { - /** @var IManager */ - private $shareManager; - /** @var Folder */ - private $rootFolder; - /** @var IUserSession */ - private $userSession; + private IManager $shareManager; + private IRootFolder $rootFolder; + private IUserSession $userSession; public function __construct(IManager $shareManager, IRootFolder $rootFolder, IUserSession $userSession) { $this->shareManager = $shareManager; @@ -45,7 +42,7 @@ class ShareRecipientSorter implements ISorter { $this->userSession = $userSession; } - public function getId() { + public function getId(): string { return 'share-recipients'; } diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 4a9ace47146..6a6fd1c9f7f 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -429,7 +429,7 @@ class ShareController extends AuthPublicShareController { */ $freeSpace = $share->getNode()->getStorage()->free_space($share->getNode()->getInternalPath()); if ($freeSpace < \OCP\Files\FileInfo::SPACE_UNLIMITED) { - $freeSpace = max($freeSpace, 0); + $freeSpace = (int)max($freeSpace, 0); } else { $freeSpace = (INF > 0) ? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188 } diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index b9ed4acd57f..68bc6801e46 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -447,14 +447,11 @@ class Manager { return $result; } - /** - * @param int $remoteShare - */ - public function processNotification($remoteShare) { + public function processNotification(int $remoteShare): void { $filter = $this->notificationManager->createNotification(); $filter->setApp('files_sharing') ->setUser($this->uid) - ->setObject('remote_share', (int) $remoteShare); + ->setObject('remote_share', (string)$remoteShare); $this->notificationManager->markProcessed($filter); } diff --git a/apps/files_sharing/lib/External/Mount.php b/apps/files_sharing/lib/External/Mount.php index 2047dede39b..ccd31147f26 100644 --- a/apps/files_sharing/lib/External/Mount.php +++ b/apps/files_sharing/lib/External/Mount.php @@ -61,11 +61,8 @@ class Mount extends MountPoint implements MoveableMount { /** * Remove the mount points - * - * @return mixed - * @return bool */ - public function removeMount() { + public function removeMount(): bool { return $this->manager->removeShare($this->mountPoint); } diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 3b4d30cf9ab..bdb4d24715c 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -837,7 +837,6 @@ get_class($res) === 'OpenSSLAsymmetricKey' - is_object($res) @@ -1294,36 +1293,7 @@ addServiceListener - - - false - - - null - - - - - Constants::PERMISSION_ALL - - - - - getUserFolder - - - - $permissions - - - $code - $code - Constants::PERMISSION_ALL - - - $permissions & Constants::PERMISSION_READ - \OCA\Circles\Api\v1\Circles \OCA\Circles\Api\v1\Circles @@ -1339,8 +1309,7 @@ $files_list - - $freeSpace + $maxUploadFilesize $maxUploadFilesize @@ -1348,39 +1317,11 @@ null - - - $password - - - - - $id - - - - - (int) $remoteShare - - - - - public function removeMount() { - - $cacheData - - - $this->getPermissions($path) & Constants::PERMISSION_SHARE - - - isSharable - - $legacyEvent diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 996f0c02603..c0a6acd118b 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -46,7 +46,7 @@ class CacheJail extends CacheWrapper { protected $unjailedRoot; /** - * @param \OCP\Files\Cache\ICache $cache + * @param ?\OCP\Files\Cache\ICache $cache * @param string $root */ public function __construct($cache, $root) { diff --git a/lib/private/Template/Base.php b/lib/private/Template/Base.php index 2de8c7ad5b1..71ce2ed9d86 100644 --- a/lib/private/Template/Base.php +++ b/lib/private/Template/Base.php @@ -92,7 +92,7 @@ class Base { /** * Assign variables * @param string $key key - * @param array|bool|integer|string|Throwable $value value + * @param float|array|bool|integer|string|Throwable $value value * @return bool * * This function assigns a variable. It can be accessed via $_[$key] in -- 2.39.5