]> git.mxchange.org Git - friendica.git/commitdiff
Fix 11 errors
authorArt4 <art4@wlabs.de>
Mon, 24 Feb 2025 15:15:26 +0000 (15:15 +0000)
committerArt4 <art4@wlabs.de>
Mon, 24 Feb 2025 15:15:26 +0000 (15:15 +0000)
src/Util/HTTPSignature.php
src/Util/JsonLD.php
src/Util/ReversedFileReader.php
src/Util/Strings.php
src/Util/Temporal.php
src/Util/XML.php

index bb5d8c6b5afde232842b2b70c652f3e5bb24be60..058d83d62a0f00b2f1f3b9d5e2c3bdbbe4d8be46 100644 (file)
@@ -7,6 +7,7 @@
 
 namespace Friendica\Util;
 
+use Exception;
 use Friendica\Core\Protocol;
 use Friendica\Database\Database;
 use Friendica\Database\DBA;
@@ -213,7 +214,7 @@ class HTTPSignature
 
                $headers = [];
                foreach ($matches as $match) {
-                       $headers[$match[1]] = trim($match[2] ?: $match[3], '"');
+                       $headers[$match[1]] = trim((string) $match[2], '"');
                }
 
                // if the header is encrypted, decrypt with (default) site private key and continue
@@ -537,14 +538,12 @@ class HTTPSignature
 
                if (!empty($uid)) {
                        $owner = User::getOwnerDataById($uid);
-                       if (!$owner) {
-                               return;
-                       }
                } else {
                        $owner = User::getSystemAccount();
-                       if (!$owner) {
-                               return;
-                       }
+               }
+
+               if (!$owner) {
+                       throw new Exception('Could not find owner for uid ' . $uid);
                }
 
                if (!empty($owner['uprvkey'])) {
index 3301ca1b40be8d94d761ace76d6256edac34a826..afca8d79ba164e91d663284a5c8f995c35ed609b 100644 (file)
@@ -243,14 +243,11 @@ class JsonLD
 
                return json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
        }
+
        /**
         * Fetches an element array from a JSON array
         *
-        * @param $array
-        * @param $element
-        * @param $key
-        *
-        * @return array fetched element
+        * @return array|null fetched element or null
         */
        public static function fetchElementArray($array, $element, $key = null, $type = null, $type_value = null)
        {
index 779933cbc6c37ab1d6b71d87b5677eacdc782125..57800ab561895a11662d9c32f0c50235a1232afd 100644 (file)
@@ -26,13 +26,13 @@ class ReversedFileReader implements \Iterator
        /** @var int */
        private $pos = -1;
 
-       /** @var array */
+       /** @var array|null */
        private $buffer = null;
 
        /** @var int */
        private $key = -1;
 
-       /** @var string */
+       /** @var string|null */
        private $value = null;
 
        /**
@@ -53,6 +53,7 @@ class ReversedFileReader implements \Iterator
                $this->buffer   = null;
                $this->key      = -1;
                $this->value    = null;
+
                return $this;
        }
 
index efa0994ec37be7f322b10f7123280d08139dd275..9dbf36176135684066fa0b3f031ca6d353d85708 100644 (file)
@@ -209,7 +209,7 @@ class Strings
        {
                // If this method is called for an infinite (== unlimited) amount of bytes:
                if ($bytes == INF) {
-                       return INF;
+                       return 'INF';
                }
 
                $units = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
@@ -509,7 +509,7 @@ class Strings
                        function ($matches) use ($blocks) {
                                $return = $matches[0];
                                if (isset($blocks[intval($matches[1])])) {
-                                       $return = $blocks[$matches[1]];
+                                       $return = $blocks[intval($matches[1])];
                                }
                                return $return;
                        },
index 3e9ea157d5f2b08cead31c91cf39f1cce2b654ed..cc9baa53a99df21c30d13a5bcac7e41b56b20a0b 100644 (file)
@@ -405,7 +405,7 @@ class Temporal
         */
        public static function getDaysInMonth(int $y, int $m): int
        {
-               return date('t', mktime(0, 0, 0, $m, 1, $y));
+               return (int) date('t', mktime(0, 0, 0, $m, 1, $y));
        }
 
        /**
index cf5689c3616fe866ab811172407922317976c21f..4c099fb78e123a52f18e9180f8de7683d500766b 100644 (file)
@@ -184,7 +184,7 @@ class XML
         * @param integer $recursion_depth recursion counter for internal use - default 0
         *                                 internal use, recursion counter
         *
-        * @return array | string The array from the xml element or the string
+        * @return array|string|null The array from the xml element or the string
         */
        public static function elementToArray($xml_element, int &$recursion_depth = 0)
        {