]> git.mxchange.org Git - friendica.git/commitdiff
Fix 27 PHPStan errors
authorArt4 <art4@wlabs.de>
Tue, 25 Feb 2025 13:51:13 +0000 (13:51 +0000)
committerArt4 <art4@wlabs.de>
Tue, 25 Feb 2025 13:51:13 +0000 (13:51 +0000)
src/Navigation/Notifications/Entity/Notify.php
src/Object/Api/Mastodon/Status.php
src/Object/Api/Twitter/DirectMessage.php
src/Object/Api/Twitter/Media.php
src/Object/Api/Twitter/Mention.php
src/Object/Api/Twitter/Status.php
src/Object/Log/ParsedLogLine.php
src/Object/Post.php
src/Object/Thread.php
src/Profile/ProfileField/Collection/ProfileFields.php

index 3ff478633e1def873faa293b286b5e5dcd0423fc..297ecbdd985874c447a73e84251ceeecd6691571 100644 (file)
@@ -33,7 +33,8 @@ use Psr\Http\Message\UriInterface;
  * @property-read int|null $parentUriId
  * @property-read int|null $id
  *
- * @deprecated since 2022.05 Use \Friendica\Navigation\Notifications\Entity\Notification instead
+ * @deprecated 2022.05 Use \Friendica\Navigation\Notifications\Entity\Notification instead
+ * @see \Friendica\Navigation\Notifications\Entity\Notification
  */
 class Notify extends BaseEntity
 {
index 0e487a989c0246101663d0ffd8814d1bc89cffb0..474db28dc0ba47b7c591a07f5b8a902ba262c854 100644 (file)
@@ -30,7 +30,7 @@ class Status extends BaseDataTransferObject
        protected $edited_at;
        /** @var string|null */
        protected $in_reply_to_id = null;
-       /** @var Status|null - Fedilab extension, see issue https://github.com/friendica/friendica/issues/12672 */
+       /** @var Status[]|null - Fedilab extension, see issue https://github.com/friendica/friendica/issues/12672 */
        protected $in_reply_to_status = null;
        /** @var string|null */
        protected $in_reply_to_account_id = null;
@@ -64,25 +64,25 @@ class Status extends BaseDataTransferObject
        protected $pinned = false;
        /** @var string */
        protected $content;
-       /** @var Status|null */
+       /** @var Status[]|null */
        protected $reblog = null;
-       /** @var Status|null - Akkoma extension, see issue https://github.com/friendica/friendica/issues/12603 */
+       /** @var Status[]|null - Akkoma extension, see issue https://github.com/friendica/friendica/issues/12603 */
        protected $quote = null;
        /** @var Application */
        protected $application = null;
-       /** @var Account */
+       /** @var array */
        protected $account;
-       /** @var Attachment */
+       /** @var Attachment[] */
        protected $media_attachments = [];
-       /** @var Mention */
+       /** @var Mention[] */
        protected $mentions = [];
-       /** @var Tag */
+       /** @var Tag[] */
        protected $tags = [];
        /** @var Emoji[] */
        protected $emojis = [];
-       /** @var Card|null */
+       /** @var array|null */
        protected $card = null;
-       /** @var Poll|null */
+       /** @var array|null */
        protected $poll = null;
        /** @var FriendicaExtension */
        protected $friendica;
index 10bea34290f0c159b8fbd1379af3bdfddd90ddad..199d9462edeb3298306c850eabfbd407f21d2339 100644 (file)
@@ -29,9 +29,9 @@ class DirectMessage extends BaseDataTransferObject
        protected $sender_screen_name = null;
        /** @var string */
        protected $recipient_screen_name = null;
-       /** @var User */
+       /** @var array */
        protected $sender;
-       /** @var User */
+       /** @var array */
        protected $recipient;
        /** @var string|null */
        protected $title;
index 19f98f1a29747d06e281ca036b26e7fa3a1423de..589aebcfc15fb45cc5150f9205ade2b2d09d38d4 100644 (file)
@@ -31,7 +31,7 @@ class Media extends BaseDataTransferObject
        protected $media_url;
        /** @var string */
        protected $media_url_https;
-       /** @var string */
+       /** @var array<string, array<string, mixed>> */
        protected $sizes;
        /** @var string */
        protected $type;
index e5d257e9d36091e60bcff4813520e83b3d0274dc..d2a4d5065f19dd2dcf6e8711f4fb6c76591c7438 100644 (file)
@@ -7,7 +7,6 @@
 
 namespace Friendica\Object\Api\Twitter;
 
-use Friendica\App\BaseURL;
 use Friendica\BaseDataTransferObject;
 
 /**
@@ -37,7 +36,7 @@ class Mention extends BaseDataTransferObject
         */
        public function __construct(array $tag, array $contact, array $indices)
        {
-               $this->id          = (string)($contact['id'] ?? 0);
+               $this->id          = (int)($contact['id'] ?? 0);
                $this->id_str      = (string)($contact['id'] ?? 0);
                $this->indices     = $indices;
                $this->name        = $tag['name'];
index 793f32fb019347ffbff702a1b3cd5e0085b6683c..1c8a4ef7aee715ca3836c1dd1c4103b70e5871fd 100644 (file)
@@ -45,11 +45,11 @@ class Status extends BaseDataTransferObject
        protected $geo;
        /** @var bool */
        protected $favorited = false;
-       /** @var User */
+       /** @var array */
        protected $user;
-       /** @var User */
+       /** @var array */
        protected $friendica_author;
-       /** @var User */
+       /** @var array */
        protected $friendica_owner;
        /** @var bool */
        protected $friendica_private;
@@ -67,9 +67,9 @@ class Status extends BaseDataTransferObject
        protected $friendica_html;
        /** @var int */
        protected $friendica_comments;
-       /** @var Status|null */
+       /** @var array|null */
        protected $retweeted_status = null;
-       /** @var Status|null */
+       /** @var array|null */
        protected $quoted_status = null;
        /** @var array */
        protected $attachments;
index 1d9802bb3292e73a72ab3bac38089b4e3d929370..8e552008a4bd0baa2b90901b5e8c9383881dfc86 100644 (file)
@@ -29,7 +29,7 @@ class ParsedLogLine
        /** @var string */
        public $message = null;
 
-       /** @var string */
+       /** @var string|null */
        public $data = null;
 
        /** @var string */
index b5ad33f56e80f01d760fd5884e7ae2f55a65fcaf..abf617e214d74efb28cc0e2a3f7ce887ff41c616 100644 (file)
@@ -49,7 +49,7 @@ class Post
        private $parent   = null;
 
        /**
-        * @var Thread
+        * @var Thread|null
         */
        private $thread       = null;
        private $redirect_url = null;
@@ -816,7 +816,7 @@ class Post
         * Get a child by its ID
         *
         * @param integer $id The child id
-        * @return Thread|null Thread or NULL if not found
+        * @return Post|null Post or NULL if not found
         */
        public function getChild(int $id)
        {
index 453e4c3421ef47ec8c62ce1cf3260a7c5380f300..070d8c1281e53a8c0e449bde25775024781bbbcf 100644 (file)
@@ -77,8 +77,7 @@ class Thread
                                break;
                        default:
                                DI::logger()->info('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').');
-                               return false;
-                               break;
+                               return;
                }
                $this->mode = $mode;
        }
index fa39a6f355bd48e39a54b7ff7fde07a759a074e0..dcf5498df3f2f27f6d63bebbfcf747d16488aa98 100644 (file)
@@ -8,31 +8,26 @@
 namespace Friendica\Profile\ProfileField\Collection;
 
 use Friendica\BaseCollection;
-use Friendica\Profile\ProfileField\Entity;
+use Friendica\Profile\ProfileField\Entity\ProfileField as ProfileFieldEntity;
 
 class ProfileFields extends BaseCollection
 {
-       public function current(): Entity\ProfileField
+       public function current(): ProfileFieldEntity
        {
                return parent::current();
        }
 
-       /**
-        * @param callable $callback
-        * @return ProfileFields (as an extended form of BaseCollection)
-        */
-       public function map(callable $callback): BaseCollection
+       public function map(callable $callback): ProfileFields
        {
-               return parent::map($callback);
+               $class = get_class($this);
+
+               return new $class(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
        }
 
-       /**
-        * @param callable|null $callback
-        * @param int           $flag
-        * @return ProfileFields as an extended version of BaseCollection
-        */
-       public function filter(callable $callback = null, int $flag = 0): BaseCollection
+       public function filter(?callable $callback = null, int $flag = 0): ProfileFields
        {
-               return parent::filter($callback, $flag);
+               $class = get_class($this);
+
+               return new $class(array_filter($this->getArrayCopy(), $callback, $flag));
        }
 }