]> git.mxchange.org Git - friendica.git/commitdiff
Add return type never, fix more errors
authorArt4 <art4@wlabs.de>
Sun, 17 Nov 2024 22:55:42 +0000 (22:55 +0000)
committerArt4 <art4@wlabs.de>
Sun, 17 Nov 2024 22:55:42 +0000 (22:55 +0000)
src/App/BaseURL.php
src/Core/System.php
src/Module/Photo.php
src/Module/Post/Tag/Remove.php
src/Module/Profile/Photos.php

index 953b13c791a9eae78cca4e3d57e833e7e43588c4..83416866f092e0c36fa3dccb156bd95ec99a2995 100644 (file)
@@ -103,6 +103,8 @@ class BaseURL extends Uri implements UriInterface
         * @throws HTTPException\TemporaryRedirectException
         *
         * @throws HTTPException\InternalServerErrorException In Case the given URL is not relative to the Friendica node
+        *
+        * @return never
         */
        public function redirect(string $toUrl = '', bool $ssl = false)
        {
index 4eca8bc80bb2869f771d4b17c900f84ae2f472f0..3eabf9695d037c699fd920d33ffd9241dabe27d3 100644 (file)
@@ -393,6 +393,8 @@ class System
 
        /**
         * Exit the program execution.
+        *
+        * @return never
         */
        public static function exit()
        {
@@ -506,6 +508,8 @@ class System
         * @throws TemporaryRedirectException
         *
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        *
+        * @return never
         */
        public static function externalRedirect($url, $code = 302)
        {
index c2b13e138687dd7e259394660cab735e2e24965c..30e6d5767251f463114ffa12a888b45ed7f0797c 100644 (file)
@@ -142,7 +142,9 @@ class Photo extends BaseApi
 
                $cacheable = ($photo['allow_cid'] . $photo['allow_gid'] . $photo['deny_cid'] . $photo['deny_gid'] === '') && (isset($photo['cacheable']) ? $photo['cacheable'] : true);
 
-               $stamp = microtime(true);
+               $stamp    = microtime(true);
+               $imgdata  = '';
+               $mimetype = false;
 
                if (empty($request['blur']) || empty($photo['blurhash'])) {
                        $imgdata  = MPhoto::getImageDataForPhoto($photo);
@@ -150,7 +152,9 @@ class Photo extends BaseApi
                }
                if (empty($imgdata) && empty($photo['blurhash'])) {
                        throw new HTTPException\NotFoundException();
-               } elseif (empty($imgdata) && !empty($photo['blurhash'])) {
+               }
+
+               if (empty($imgdata) && !empty($photo['blurhash'])) {
                        $image = new Image('', image_type_to_mime_type(IMAGETYPE_WEBP));
                        $image->getFromBlurHash($photo['blurhash'], $photo['width'], $photo['height']);
                        $imgdata  = $image->asString();
@@ -376,6 +380,9 @@ class Photo extends BaseApi
                                                Logger::debug('Expected Content-Type', ['mime' => $mimetext, 'url' => $url]);
                                        }
                                }
+
+                               $url = '';
+
                                if (empty($mimetext) && !empty($contact['blurhash'])) {
                                        $image = new Image('', image_type_to_mime_type(IMAGETYPE_WEBP));
                                        $image->getFromBlurHash($contact['blurhash'], $customsize, $customsize);
index 30730323364004d7912f296d5fe319bfacb0a429..1ed68e2cfa207770fc0536f664606c17bb0f7ac9 100644 (file)
@@ -78,7 +78,7 @@ class Remove extends \Friendica\BaseModule
                $tag_text = Tag::getCSVByURIId($item['uri-id']);
 
                $tags = explode(',', $tag_text);
-               if (empty($tags)) {
+               if (!is_array($tags)) {
                        $this->baseUrl->redirect($returnUrl);
                }
 
index fb89ac676dfbeb75808754e408654440ce23c15c..874e17b448b4147c35d1acc5d7ac322aec68f8ff 100644 (file)
@@ -124,7 +124,11 @@ class Photos extends \Friendica\Module\BaseProfile
                        $visible = 0;
                }
 
-               $ret = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''];
+               $ret      = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''];
+               $src      = null;
+               $filename = '';
+               $filesize = 0;
+               $type     = '';
 
                Hook::callAll('photo_post_file', $ret);
 
@@ -164,7 +168,11 @@ class Photos extends \Friendica\Module\BaseProfile
                                        $this->systemMessages->addNotice($this->t('Server can\'t accept new file upload at this time, please contact your administrator'));
                                        break;
                        }
-                       @unlink($src);
+
+                       if ($src !== null) {
+                               @unlink($src);
+                       }
+
                        $foo = 0;
                        Hook::callAll('photo_post_end', $foo);
                        return;