diff options
-rw-r--r-- | apps/files_sharing/lib/Cache.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/Capabilities.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php | 11 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 8 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareInfoController.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Cache.php | 4 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 7 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Mount.php | 5 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Storage.php | 8 | ||||
-rw-r--r-- | build/psalm-baseline.xml | 61 | ||||
-rw-r--r-- | lib/private/Files/Cache/Wrapper/CacheJail.php | 2 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 2 | ||||
-rw-r--r-- | lib/private/Template/Base.php | 2 | ||||
-rw-r--r-- | lib/public/Share/IManager.php | 2 |
15 files changed, 28 insertions, 96 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/Capabilities.php b/apps/files_sharing/lib/Capabilities.php index c5421fe779a..58104864631 100644 --- a/apps/files_sharing/lib/Capabilities.php +++ b/apps/files_sharing/lib/Capabilities.php @@ -116,7 +116,7 @@ class Capabilities implements ICapability { $res['group'] = []; $res['group']['enabled'] = $this->shareManager->allowGroupSharing(); $res['group']['expire_date']['enabled'] = true; - $res['default_permissions'] = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL); + $res['default_permissions'] = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL); } //Federated sharing 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/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 26584f6d178..ae8559870f3 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -478,7 +478,7 @@ class ShareAPIController extends OCSController { $share = $this->shareManager->newShare(); if ($permissions === null) { - $permissions = $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL); + $permissions = (int)$this->config->getAppValue('core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL); } // Verify path @@ -581,7 +581,7 @@ class ShareAPIController extends OCSController { } // TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones - if (($permissions & Constants::PERMISSION_READ) && $this->shareManager->outgoingServer2ServerSharesAllowed()) { + if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { $permissions |= Constants::PERMISSION_SHARE; } @@ -1271,7 +1271,7 @@ class ShareAPIController extends OCSController { $share = $this->shareManager->updateShare($share); } catch (GenericShareException $e) { $code = $e->getCode() === 0 ? 403 : $e->getCode(); - throw new OCSException($e->getHint(), $code); + throw new OCSException($e->getHint(), (int)$code); } catch (\Exception $e) { throw new OCSBadRequestException($e->getMessage(), $e); } @@ -1353,7 +1353,7 @@ class ShareAPIController extends OCSController { $this->shareManager->acceptShare($share, $this->currentUser); } catch (GenericShareException $e) { $code = $e->getCode() === 0 ? 403 : $e->getCode(); - throw new OCSException($e->getHint(), $code); + throw new OCSException($e->getHint(), (int)$code); } catch (\Exception $e) { throw new OCSBadRequestException($e->getMessage(), $e); } 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/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php index 429eb91bc92..b090e6efcf1 100644 --- a/apps/files_sharing/lib/Controller/ShareInfoController.php +++ b/apps/files_sharing/lib/Controller/ShareInfoController.php @@ -61,11 +61,11 @@ class ShareInfoController extends ApiController { * @BruteForceProtection(action=shareinfo) * * @param string $t - * @param null $password - * @param null $dir + * @param ?string $password + * @param ?string $dir * @return JSONResponse */ - public function info($t, $password = null, $dir = null) { + public function info(string $t, ?string $password = null, ?string $dir = null) { try { $share = $this->shareManager->getShareByToken($t); } catch (ShareNotFound $e) { diff --git a/apps/files_sharing/lib/External/Cache.php b/apps/files_sharing/lib/External/Cache.php index f8d9a2548a8..f353022d067 100644 --- a/apps/files_sharing/lib/External/Cache.php +++ b/apps/files_sharing/lib/External/Cache.php @@ -58,8 +58,8 @@ class Cache extends \OC\Files\Cache\Cache { return $result; } - public function getFolderContentsById($id) { - $results = parent::getFolderContentsById($id); + public function getFolderContentsById($fileId) { + $results = parent::getFolderContentsById($fileId); foreach ($results as &$file) { $file['displayname_owner'] = $this->cloudId->getDisplayId(); } 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/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 296e7ddf85b..43568ea6a2b 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -355,18 +355,18 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, return $this->cloudId->getDisplayId(); } - public function isSharable($path) { + public function isSharable($path): bool { if (\OCP\Util::isSharingDisabledForUser() || !\OC\Share\Share::isResharingAllowed()) { return false; } - return ($this->getPermissions($path) & Constants::PERMISSION_SHARE); + return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE); } - public function getPermissions($path) { + public function getPermissions($path): int { $response = $this->propfind($path); // old federated sharing permissions if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) { - $permissions = $response['{http://open-collaboration-services.org/ns}share-permissions']; + $permissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions']; } elseif (isset($response['{http://open-cloud-mesh.org/ns}share-permissions'])) { // permissions provided by the OCM API $permissions = $this->ocmPermissions2ncPermissions($response['{http://open-collaboration-services.org/ns}share-permissions'], $path); diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index e5c2ce9b992..dc2b8a8f10a 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -829,7 +829,6 @@ </RedundantCondition> <TypeDoesNotContainType occurrences="2"> <code>get_class($res) === 'OpenSSLAsymmetricKey'</code> - <code>is_object($res)</code> </TypeDoesNotContainType> </file> <file src="apps/encryption/lib/Crypto/EncryptAll.php"> @@ -1286,36 +1285,7 @@ <code>addServiceListener</code> </InvalidArgument> </file> - <file src="apps/files_sharing/lib/Cache.php"> - <FalsableReturnStatement occurrences="1"> - <code>false</code> - </FalsableReturnStatement> - <NullArgument occurrences="1"> - <code>null</code> - </NullArgument> - </file> - <file src="apps/files_sharing/lib/Capabilities.php"> - <InvalidScalarArgument occurrences="1"> - <code>Constants::PERMISSION_ALL</code> - </InvalidScalarArgument> - </file> - <file src="apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php"> - <UndefinedInterfaceMethod occurrences="1"> - <code>getUserFolder</code> - </UndefinedInterfaceMethod> - </file> <file src="apps/files_sharing/lib/Controller/ShareAPIController.php"> - <InvalidOperand occurrences="1"> - <code>$permissions</code> - </InvalidOperand> - <InvalidScalarArgument occurrences="3"> - <code>$code</code> - <code>$code</code> - <code>Constants::PERMISSION_ALL</code> - </InvalidScalarArgument> - <RedundantCondition occurrences="1"> - <code>$permissions & Constants::PERMISSION_READ</code> - </RedundantCondition> <UndefinedClass occurrences="2"> <code>\OCA\Circles\Api\v1\Circles</code> <code>\OCA\Circles\Api\v1\Circles</code> @@ -1331,8 +1301,7 @@ <InvalidArgument occurrences="1"> <code>$files_list</code> </InvalidArgument> - <InvalidScalarArgument occurrences="3"> - <code>$freeSpace</code> + <InvalidScalarArgument occurrences="1"> <code>$maxUploadFilesize</code> <code>$maxUploadFilesize</code> </InvalidScalarArgument> @@ -1340,39 +1309,11 @@ <code>null</code> </NullArgument> </file> - <file src="apps/files_sharing/lib/Controller/ShareInfoController.php"> - <NullArgument occurrences="1"> - <code>$password</code> - </NullArgument> - </file> - <file src="apps/files_sharing/lib/External/Cache.php"> - <ParamNameMismatch occurrences="1"> - <code>$id</code> - </ParamNameMismatch> - </file> - <file src="apps/files_sharing/lib/External/Manager.php"> - <InvalidScalarArgument occurrences="1"> - <code>(int) $remoteShare</code> - </InvalidScalarArgument> - </file> - <file src="apps/files_sharing/lib/External/Mount.php"> - <InvalidDocblock occurrences="1"> - <code>public function removeMount() {</code> - </InvalidDocblock> - </file> <file src="apps/files_sharing/lib/External/Scanner.php"> <MoreSpecificImplementedParamType occurrences="1"> <code>$cacheData</code> </MoreSpecificImplementedParamType> </file> - <file src="apps/files_sharing/lib/External/Storage.php"> - <InvalidReturnStatement occurrences="1"> - <code>$this->getPermissions($path) & Constants::PERMISSION_SHARE</code> - </InvalidReturnStatement> - <InvalidReturnType occurrences="1"> - <code>isSharable</code> - </InvalidReturnType> - </file> <file src="apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php"> <InvalidArgument occurrences="1"> <code>$legacyEvent</code> 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/Share20/Manager.php b/lib/private/Share20/Manager.php index 2ef61cf3404..ffd779707df 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1562,7 +1562,7 @@ class Manager implements IManager { * Verify the password of a public share * * @param IShare $share - * @param string $password + * @param ?string $password * @return bool */ public function checkPassword(IShare $share, $password) { 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 diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 0810acc673a..82a92428b31 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -211,7 +211,7 @@ interface IManager { * Verify the password of a public share * * @param IShare $share - * @param string $password + * @param ?string $password * @return bool * @since 9.0.0 */ |