]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix various other small psalm issues 34628/head
authorCarl Schwan <carl@carlschwan.eu>
Mon, 17 Oct 2022 10:40:35 +0000 (12:40 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Mon, 17 Oct 2022 10:40:35 +0000 (12:40 +0200)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
apps/files_sharing/lib/Cache.php
apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php
apps/files_sharing/lib/Controller/ShareController.php
apps/files_sharing/lib/External/Manager.php
apps/files_sharing/lib/External/Mount.php
build/psalm-baseline.xml
lib/private/Files/Cache/Wrapper/CacheJail.php
lib/private/Template/Base.php

index aa45b6ab43e0d466ae428c6a62fe6e855874fad0..b99a511312e4f2269d854b0ce2c211e1b0cd188c 100644 (file)
@@ -109,7 +109,7 @@ class Cache extends CacheJail {
                if (isset($this->numericId)) {
                        return $this->numericId;
                } else {
-                       return false;
+                       return -1;
                }
        }
 
index 28d0d26c5beeca2d1d8bd36491df9c8523746e87..2fd35b20a0f5a5051bdf254088162d88fd991275 100644 (file)
@@ -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';
        }
 
index 4a9ace47146597626389e0096d4b4a17a42de6fb..6a6fd1c9f7fdb31c046434c3980df84d4a6204b9 100644 (file)
@@ -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
                        }
index b9ed4acd57f2db0dc1e32f36108c990b9ed9f000..68bc6801e4673fe878bcc43580006dd38bbe7d8a 100644 (file)
@@ -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);
        }
 
index 2047dede39bf6e79203f094d862a6b10274cc6a9..ccd31147f26fc18ac91d637bba4a1cc875bfe047 100644 (file)
@@ -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);
        }
 
index 3b4d30cf9ab47865e0036b64367cdab61190acf5..bdb4d24715cbcc5876a2b74e162990f1025183c4 100644 (file)
     </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">
       <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 &amp; Constants::PERMISSION_READ</code>
-    </RedundantCondition>
     <UndefinedClass occurrences="2">
       <code>\OCA\Circles\Api\v1\Circles</code>
       <code>\OCA\Circles\Api\v1\Circles</code>
     <InvalidArgument occurrences="1">
       <code>$files_list</code>
     </InvalidArgument>
-    <InvalidScalarArgument occurrences="3">
-      <code>$freeSpace</code>
+    <InvalidScalarArgument occurrences="1">
       <code>$maxUploadFilesize</code>
       <code>$maxUploadFilesize</code>
     </InvalidScalarArgument>
       <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-&gt;getPermissions($path) &amp; 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>
index 996f0c026030d02a3787660c6676ae1da2de04d2..c0a6acd118b860fb693635d8c8c444a3f7b9fef7 100644 (file)
@@ -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) {
index 2de8c7ad5b18cd711d95c6a78000566485a947d9..71ce2ed9d860830bc1010a78ce66c46e8939ad51 100644 (file)
@@ -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