]> git.mxchange.org Git - friendica.git/commitdiff
Fix 10 PHPStan errors
authorArt4 <art4@wlabs.de>
Thu, 13 Mar 2025 11:39:02 +0000 (11:39 +0000)
committerArt4 <art4@wlabs.de>
Thu, 13 Mar 2025 11:39:02 +0000 (11:39 +0000)
src/Core/Storage/Type/Database.php
src/Core/System.php
src/Core/Update.php
src/Core/Worker.php

index 39b84528e52ec3fd0ee8fd34ad7dfddc66e71eed..6ed8527533f3ce8144f2f20a4f43cb0cff77cc1f 100644 (file)
@@ -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();
                }
        }
 
index df494bec5df0186971a5906e02dece7beebc692a..d7367e871c2503c57e802698598620ef650a78dc 100644 (file)
@@ -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);
index 7aeefc37939f2c7b2eb29172050a8eacd55adae3..dc68f280cccb662d8a60efee60d2dce7c6d85c16 100644 (file)
@@ -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]);
index 995239cde926fd6fbb48b9c92627cbf9522d3054..75a457f38e38c2c7616fe77d89d806502cca4d92 100644 (file)
@@ -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()