]> source.dussan.org Git - nextcloud-server.git/commitdiff
Attempt at reducing psalm errors
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 13 Dec 2022 07:54:49 +0000 (08:54 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Fri, 20 Jan 2023 10:22:09 +0000 (11:22 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/files_external/lib/Command/Notify.php
build/psalm-baseline.xml
lib/private/AppFramework/OCS/V1Response.php
lib/private/legacy/OC_API.php

index bba698fb25f192aaf47cd57646ff41d69c9aefb1..60639f7dbe478404a8c4cb55a1e7f7620175f1ba 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+declare(strict_types=1);
+
 /**
  * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
  *
@@ -108,9 +111,9 @@ class Notify extends Base {
                if ($input->getOption('user')) {
                        return (string)$input->getOption('user');
                } elseif (isset($_ENV['NOTIFY_USER'])) {
-                       return (string)$_ENV['NOTIFY_USER'];
+                       return $_ENV['NOTIFY_USER'];
                } elseif (isset($_SERVER['NOTIFY_USER'])) {
-                       return (string)$_SERVER['NOTIFY_USER'];
+                       return $_SERVER['NOTIFY_USER'];
                } else {
                        return null;
                }
@@ -120,9 +123,9 @@ class Notify extends Base {
                if ($input->getOption('password')) {
                        return (string)$input->getOption('password');
                } elseif (isset($_ENV['NOTIFY_PASSWORD'])) {
-                       return (string)$_ENV['NOTIFY_PASSWORD'];
+                       return $_ENV['NOTIFY_PASSWORD'];
                } elseif (isset($_SERVER['NOTIFY_PASSWORD'])) {
-                       return (string)$_SERVER['NOTIFY_PASSWORD'];
+                       return $_SERVER['NOTIFY_PASSWORD'];
                } else {
                        return null;
                }
index cca5d29909c49a55e2122b4e4be7695a73583f15..5c8b4d7e67b20d0d73fc3f5261d513a2de246f51 100644 (file)
     </RedundantCondition>
   </file>
   <file src="lib/private/Authentication/Token/PublicKeyToken.php">
-    <UndefinedMethod occurrences="16">
+    <UndefinedMagicMethod occurrences="16">
       <code>parent::getExpires()</code>
       <code>parent::getLastCheck()</code>
       <code>parent::getLoginName()</code>
       <code>parent::setScope(json_encode($scope))</code>
       <code>parent::setToken($token)</code>
       <code>parent::setType(IToken::WIPE_TOKEN)</code>
-    </UndefinedMethod>
+    </UndefinedMagicMethod>
   </file>
   <file src="lib/private/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDao.php">
     <InvalidReturnStatement occurrences="1"/>
index f4f19832fa8fc92fe67d2e5aab0b7baee6cc91c2..8c402809cc41ad847256eb058c7cfe1104e5d560 100644 (file)
@@ -68,13 +68,12 @@ class V1Response extends BaseResponse {
        public function render() {
                $meta = [
                        'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure',
-                       'statuscode' => $this->getOCSStatus(),
-                       'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage,
+                       'statuscode' => (string)$this->getOCSStatus(),
+                       'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage ?? '',
+                       'totalitems' => (string)($this->itemsCount ?? ''),
+                       'itemsperpage' => (string)($this->itemsPerPage ?? ''),
                ];
 
-               $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : '';
-               $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: '';
-
                return $this->renderResult($meta);
        }
 }
index 46ee34955721f47b34105249bde806f668a10f84..0da546f32632475ab7fb4bfead3aaeec7fdcd5c4 100644 (file)
@@ -101,7 +101,7 @@ class OC_API {
        public static function requestedFormat(): string {
                $formats = ['json', 'xml'];
 
-               $format = (isset($_GET['format']) && in_array($_GET['format'], $formats)) ? $_GET['format'] : 'xml';
+               $format = (isset($_GET['format']) && is_string($_GET['format']) && in_array($_GET['format'], $formats)) ? $_GET['format'] : 'xml';
                return $format;
        }