]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix psalm errors fron the end of the baseline file 32413/head
authorCarl Schwan <carl@carlschwan.eu>
Mon, 16 May 2022 08:58:26 +0000 (10:58 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Mon, 16 May 2022 08:58:26 +0000 (10:58 +0200)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
apps/files_trashbin/lib/Trashbin.php
build/psalm-baseline.xml
lib/private/legacy/OC_Helper.php
lib/private/legacy/OC_Util.php
lib/public/Search/SearchResult.php
lib/public/Share.php
lib/public/Util.php

index 4631f9e9d5bfef34138eb7ceec286aa74fea52b2..72072a2588c671b0e7ff519ee6bafbd0be7aae84 100644 (file)
@@ -801,7 +801,7 @@ class Trashbin {
                        $availableSpace = $quota;
                }
 
-               return $availableSpace;
+               return (int)$availableSpace;
        }
 
        /**
index 7eedc007f540341e900195defb6818a7450e6cd1..d88e616032ba56a65ed248fd745e208177a511a7 100644 (file)
     <InvalidOperand occurrences="1">
       <code>$matches[1][$last_match][0]</code>
     </InvalidOperand>
-    <InvalidReturnStatement occurrences="4">
+    <InvalidReturnStatement occurrences="2">
       <code>(INF &gt; 0)? INF: PHP_INT_MAX</code>
       <code>INF</code>
-      <code>max($upload_max_filesize, $post_max_size)</code>
-      <code>min($upload_max_filesize, $post_max_size)</code>
     </InvalidReturnStatement>
     <InvalidReturnType occurrences="1">
       <code>int</code>
       <code>\Test\Util\User\Dummy</code>
     </UndefinedClass>
   </file>
-  <file src="lib/private/legacy/OC_Util.php">
-    <InvalidReturnStatement occurrences="1">
-      <code>OC_Helper::computerFileSize($userQuota)</code>
-    </InvalidReturnStatement>
-    <InvalidReturnType occurrences="1">
-      <code>float</code>
-    </InvalidReturnType>
-    <RedundantCondition occurrences="1">
-      <code>is_string($expected)</code>
-    </RedundantCondition>
-    <TypeDoesNotContainType occurrences="3">
-      <code>is_bool($expected)</code>
-      <code>is_bool($setting[1])</code>
-      <code>is_int($expected)</code>
-    </TypeDoesNotContainType>
-  </file>
   <file src="lib/public/Server.php">
     <InvalidThrow occurrences="2">
       <code>ContainerExceptionInterface</code>
       <code>PreconditionNotMetException</code>
     </InvalidClass>
   </file>
-  <file src="lib/public/Search/SearchResult.php">
-    <InvalidArgument occurrences="1">
-      <code>$cursor</code>
-    </InvalidArgument>
-  </file>
-  <file src="lib/public/Share.php">
-    <InvalidReturnType occurrences="3">
-      <code>array</code>
-      <code>array|bool</code>
-      <code>mixed</code>
-    </InvalidReturnType>
-  </file>
-  <file src="lib/public/Util.php">
-    <InvalidReturnStatement occurrences="1">
-      <code>\OC_Helper::computerFileSize($str)</code>
-    </InvalidReturnStatement>
-    <InvalidReturnType occurrences="1">
-      <code>float</code>
-    </InvalidReturnType>
-  </file>
   <file src="remote.php">
     <InvalidScalarArgument occurrences="1">
       <code>$e-&gt;getCode()</code>
index 6aa0b582c216a9e36a2d7140aa6befeb974a3693..226f73a07111e6625f0cfe2c2f5e3b01c7c617c7 100644 (file)
@@ -95,7 +95,7 @@ class OC_Helper {
        /**
         * Make a computer file size
         * @param string $str file size in human readable format
-        * @return float|bool a file size in bytes
+        * @return float|false a file size in bytes
         *
         * Makes 2kB to 2048.
         *
@@ -420,11 +420,11 @@ class OC_Helper {
         */
        public static function uploadLimit() {
                $ini = \OC::$server->get(IniGetWrapper::class);
-               $upload_max_filesize = OCP\Util::computerFileSize($ini->get('upload_max_filesize'));
-               $post_max_size = OCP\Util::computerFileSize($ini->get('post_max_size'));
-               if ((int)$upload_max_filesize === 0 and (int)$post_max_size === 0) {
+               $upload_max_filesize = (int)OCP\Util::computerFileSize($ini->get('upload_max_filesize'));
+               $post_max_size = (int)OCP\Util::computerFileSize($ini->get('post_max_size'));
+               if ($upload_max_filesize === 0 && $post_max_size === 0) {
                        return INF;
-               } elseif ((int)$upload_max_filesize === 0 or (int)$post_max_size === 0) {
+               } elseif ($upload_max_filesize === 0 || $post_max_size === 0) {
                        return max($upload_max_filesize, $post_max_size); //only the non 0 value counts
                } else {
                        return min($upload_max_filesize, $post_max_size);
index ee7fb517d98b88e70ba9c85fde94ab60b4d48783..516ccc8283c01633ba155e05084b4c833b955165 100644 (file)
@@ -158,7 +158,7 @@ class OC_Util {
         * Get the quota of a user
         *
         * @param IUser|null $user
-        * @return float Quota bytes
+        * @return float|\OCP\Files\FileInfo::SPACE_UNLIMITED|false Quota bytes
         */
        public static function getUserQuota(?IUser $user) {
                if (is_null($user)) {
@@ -657,20 +657,8 @@ class OC_Util {
                        }
                }
                foreach ($dependencies['ini'] as $setting => $expected) {
-                       if (is_bool($expected)) {
-                               if ($iniWrapper->getBool($setting) !== $expected) {
-                                       $invalidIniSettings[] = [$setting, $expected];
-                               }
-                       }
-                       if (is_int($expected)) {
-                               if ($iniWrapper->getNumeric($setting) !== $expected) {
-                                       $invalidIniSettings[] = [$setting, $expected];
-                               }
-                       }
-                       if (is_string($expected)) {
-                               if (strtolower($iniWrapper->getString($setting)) !== strtolower($expected)) {
-                                       $invalidIniSettings[] = [$setting, $expected];
-                               }
+                       if (strtolower($iniWrapper->getString($setting)) !== strtolower($expected)) {
+                               $invalidIniSettings[] = [$setting, $expected];
                        }
                }
 
@@ -682,9 +670,6 @@ class OC_Util {
                        $webServerRestart = true;
                }
                foreach ($invalidIniSettings as $setting) {
-                       if (is_bool($setting[1])) {
-                               $setting[1] = $setting[1] ? 'on' : 'off';
-                       }
                        $errors[] = [
                                'error' => $l->t('PHP setting "%s" is not set to "%s".', [$setting[0], var_export($setting[1], true)]),
                                'hint' => $l->t('Adjusting this setting in php.ini will make Nextcloud run again')
index 685dad0f0ca944c2f6ccceaf26d1a580a461bd0c..5371b77ef0a56d4a41bc5a957e9b7146117e7484 100644 (file)
@@ -50,7 +50,7 @@ final class SearchResult implements JsonSerializable {
         * @param string $name the translated name of the result section or group, e.g. "Mail"
         * @param bool $isPaginated
         * @param SearchResultEntry[] $entries
-        * @param null $cursor
+        * @param ?int|?string $cursor
         *
         * @since 20.0.0
         */
index 6aeadb3a6ed889e5d99e76d54035ec5e5b692ed8..cb6b145bcfb2525e637c1c19cd34859a978a0252 100644 (file)
@@ -64,7 +64,7 @@ class Share extends \OC\Share\Constants {
         * @param int $format (optional) Format type must be defined by the backend
         * @param mixed $parameters
         * @param bool $includeCollections
-        * @return array
+        * @return void
         * @since 5.0.0
         * @deprecated 17.0.0
         */
@@ -77,7 +77,7 @@ class Share extends \OC\Share\Constants {
         * Based on the given token the share information will be returned - password protected shares will be verified
         * @param string $token
         * @param bool $checkPasswordProtection
-        * @return array|bool false will be returned in case the token is unknown or unauthorized
+        * @return void
         * @since 5.0.0 - parameter $checkPasswordProtection was added in 7.0.0
         * @deprecated 17.0.0
         */
@@ -93,7 +93,7 @@ class Share extends \OC\Share\Constants {
         * @param mixed $parameters
         * @param int $limit Number of items to return (optional) Returns all by default
         * @param bool $includeCollections
-        * @return mixed Return depends on format
+        * @return void
         * @since 5.0.0
         * @deprecated 17.0.0
         */
index c8b55bb10e2c292d85978b5a43e30139c3e83ced..e5bb2a955ae93fb4dc7874f9475ee5b4ef5ea1ee 100644 (file)
@@ -372,7 +372,7 @@ class Util {
        /**
         * Make a computer file size (2 kB to 2048)
         * @param string $str file size in a fancy format
-        * @return float a file size in bytes
+        * @return float|false a file size in bytes
         *
         * Inspired by: https://www.php.net/manual/en/function.filesize.php#92418
         * @since 4.0.0