From 7e66b35b4626fa84f12dfd4a63dd416d37b9177e Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 13 Mar 2025 11:39:02 +0000 Subject: [PATCH] Fix 10 PHPStan errors --- src/Core/Storage/Type/Database.php | 2 +- src/Core/System.php | 8 +++----- src/Core/Update.php | 4 ++-- src/Core/Worker.php | 7 ++++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Core/Storage/Type/Database.php b/src/Core/Storage/Type/Database.php index 39b84528e5..6ed8527533 100644 --- a/src/Core/Storage/Type/Database.php +++ b/src/Core/Storage/Type/Database.php @@ -80,7 +80,7 @@ class Database implements ICanWriteToStorage throw new StorageException(sprintf('Database storage failed to update %s', $reference), 500, new Exception($this->dba->errorMessage(), $this->dba->errorNo())); } - return $this->dba->lastInsertId(); + return (string) $this->dba->lastInsertId(); } } diff --git a/src/Core/System.php b/src/Core/System.php index df494bec5d..d7367e871c 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -452,19 +452,17 @@ class System /** * Returns the current Load of the System - * - * @return integer */ - public static function currentLoad() + public static function currentLoad(): float { if (!function_exists('sys_getloadavg')) { - return false; + return (float) 0; } $load_arr = sys_getloadavg(); if (!is_array($load_arr)) { - return false; + return (float) 0; } return round(max($load_arr[0], $load_arr[1]), 2); diff --git a/src/Core/Update.php b/src/Core/Update.php index 7aeefc3793..dc68f280cc 100644 --- a/src/Core/Update.php +++ b/src/Core/Update.php @@ -217,7 +217,7 @@ class Update ->set('system', 'maintenance', false) ->delete('system', 'maintenance_reason') ->commit(); - return $r; + return 'Pre update failed'; } else { DI::logger()->notice('Pre update executed.', ['version' => $version]); } @@ -262,7 +262,7 @@ class Update ->set('system', 'maintenance', false) ->delete('system', 'maintenance_reason') ->commit(); - return $r; + return 'Post update failed'; } else { DI::config()->set('system', 'build', $version); DI::logger()->notice('Post update executed.', ['version' => $version]); diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 995239cde9..75a457f38e 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -271,12 +271,13 @@ class Worker * * @param integer $priority The priority that should be checked * - * @return integer Is there a process running with that priority? + * @return bool Is there a process running with that priority? * @throws \Exception */ - private static function processWithPriorityActive(int $priority): int + private static function processWithPriorityActive(int $priority): bool { $condition = ["`priority` <= ? AND `pid` != 0 AND NOT `done`", $priority]; + return DBA::exists('workerqueue', $condition); } @@ -955,7 +956,7 @@ class Worker /** * Returns the priority of the next workerqueue job * - * @return string|bool priority or FALSE on failure + * @return int|false priority or FALSE on failure * @throws \Exception */ private static function nextPriority()