]> git.mxchange.org Git - friendica.git/commitdiff
Fix errors in Factory namespace
authorArt4 <art4@wlabs.de>
Tue, 3 Dec 2024 21:44:35 +0000 (21:44 +0000)
committerArt4 <art4@wlabs.de>
Tue, 3 Dec 2024 21:44:35 +0000 (21:44 +0000)
src/BaseEntity.php
src/DI.php
src/Factory/Api/Mastodon/Card.php
src/Factory/Api/Mastodon/Notification.php
src/Factory/Api/Mastodon/Status.php
src/Factory/Api/Mastodon/StatusSource.php
src/Factory/Api/Mastodon/Subscription.php
src/Factory/Api/Twitter/Status.php
src/Navigation/Notifications/Entity/Notification.php
src/Object/Api/Mastodon/Status/Counts.php

index 6f61872548703f563aeaa69e8e22407ffa797810..09a2562c8e214dcdcffad8caf8ee9124e80614bd 100644 (file)
@@ -7,7 +7,7 @@
 
 namespace Friendica;
 
-use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
 
 /**
  * The Entity classes directly inheriting from this abstract class are meant to represent a single business entity.
@@ -23,18 +23,29 @@ use Friendica\Network\HTTPException;
  *
  * Since these objects aren't meant to be using any dependency, including logging, unit tests can and must be
  * written for each and all of their methods
+ *
+ * @property-read int $id
+ * @property-read int $uid
+ * @property-read string $verb
+ * @property-read int $type
+ * @property-read int $actorId
+ * @property-read int $targetUriId
+ * @property-read int $parentUriId
+ * @property-read \DateTime $created
+ * @property-read bool $seen
+ * @property-read bool $dismissed
  */
 abstract class BaseEntity extends BaseDataTransferObject
 {
        /**
         * @param string $name
         * @return mixed
-        * @throws HTTPException\InternalServerErrorException
+        * @throws InternalServerErrorException
         */
        public function __get(string $name)
        {
                if (!property_exists($this, $name)) {
-                       throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
+                       throw new InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
                }
 
                return $this->$name;
@@ -43,12 +54,12 @@ abstract class BaseEntity extends BaseDataTransferObject
        /**
         * @param mixed $name
         * @return bool
-        * @throws HTTPException\InternalServerErrorException
+        * @throws InternalServerErrorException
         */
        public function __isset($name): bool
        {
                if (!property_exists($this, $name)) {
-                       throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class);
+                       throw new InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class);
                }
 
                return !empty($this->$name);
index 8e422a129e1521cb2932eef0bd2282b1a8f6e020..56a94d9b97c48266f6d3e59ed9d01638a07e63bc 100644 (file)
@@ -525,7 +525,7 @@ abstract class DI
        //
 
        /**
-        * @return Contact\FriendSuggest\Repository\FriendSuggest;
+        * @return Contact\FriendSuggest\Repository\FriendSuggest
         */
        public static function fsuggest()
        {
@@ -533,7 +533,7 @@ abstract class DI
        }
 
        /**
-        * @return Contact\FriendSuggest\Factory\FriendSuggest;
+        * @return Contact\FriendSuggest\Factory\FriendSuggest
         */
        public static function fsuggestFactory()
        {
index 1a517dea20ac997b82f1f48547144b59fad984e0..32388b4776a084ca76c8d28d15692260284c9a7a 100644 (file)
@@ -8,10 +8,8 @@
 namespace Friendica\Factory\Api\Mastodon;
 
 use Friendica\BaseFactory;
-use Friendica\Content\Text\BBCode;
 use Friendica\Model\Post;
 use Friendica\Network\HTTPException;
-use Friendica\Util\Strings;
 
 class Card extends BaseFactory
 {
@@ -21,7 +19,8 @@ class Card extends BaseFactory
         *
         * @return \Friendica\Object\Api\Mastodon\Card
         * @throws HTTPException\InternalServerErrorException
-        * @throws \ImagickException*@throws \Exception
+        * @throws \ImagickException
+        * @throws \Exception
         */
        public function createFromUriId(int $uriId, array $history = []): \Friendica\Object\Api\Mastodon\Card
        {
index 452cc18ceace29747ad464d47f4301f272b7a498..4b78a90b8af7937561eba0b72a4189a4797c9f98 100644 (file)
@@ -9,7 +9,7 @@ namespace Friendica\Factory\Api\Mastodon;
 
 use Friendica\BaseFactory;
 use Friendica\Model\Contact;
-use Friendica\Navigation\Notifications;
+use Friendica\Navigation\Notifications\Entity\Notification as NotificationEntity;
 use Friendica\Navigation\Notifications\Exception\UnexpectedNotificationTypeException;
 use Friendica\Object\Api\Mastodon\Notification as MstdnNotification;
 use Friendica\Protocol\Activity;
@@ -32,16 +32,17 @@ class Notification extends BaseFactory
        }
 
        /**
-        * @param Notifications\Entity\Notification $Notification
-        * @param bool $display_quote Display quoted posts
+        * @param NotificationEntity $Notification
+        * @param bool $display_quotes Display quoted posts
         *
         * @return MstdnNotification
         * @throws UnexpectedNotificationTypeException
         */
-       public function createFromNotification(Notifications\Entity\Notification $Notification, bool $display_quotes): MstdnNotification
+       public function createFromNotification(NotificationEntity $Notification, bool $display_quotes): MstdnNotification
        {
                $type = self::getType($Notification);
-               if (empty($type)) {
+
+               if ($type === '') {
                        throw new UnexpectedNotificationTypeException();
                }
 
index 3e55b427b5bc37c9f56fd19163178cdb8394e22a..8cf9f3d8e70b0f7bab8ea2e6955007c009f62f9e 100644 (file)
@@ -20,7 +20,8 @@ use Friendica\DI;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Model\Verb;
-use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Network\HTTPException\NotFoundException;
 use Friendica\Object\Api\Mastodon\Status\FriendicaDeliveryData;
 use Friendica\Object\Api\Mastodon\Status\FriendicaExtension;
 use Friendica\Object\Api\Mastodon\Status\FriendicaVisibility;
@@ -87,8 +88,8 @@ class Status extends BaseFactory
         * @param bool $in_reply_status Add an "in_reply_status" element
         *
         * @return \Friendica\Object\Api\Mastodon\Status
-        * @throws HTTPException\InternalServerErrorException
-        * @throws ImagickException|HTTPException\NotFoundException
+        * @throws InternalServerErrorException
+        * @throws ImagickException|NotFoundException
         */
        public function createFromUriId(int $uriId, int $uid = 0, bool $display_quote = false, bool $reblog = true, bool $in_reply_status = true): \Friendica\Object\Api\Mastodon\Status
        {
@@ -101,7 +102,7 @@ class Status extends BaseFactory
                        if ($mail) {
                                return $this->createFromMailId($mail['id']);
                        }
-                       throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
+                       throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
                }
 
                $activity_fields = ['uri-id', 'thr-parent-id', 'uri', 'author-id', 'author-uri-id', 'author-link', 'app', 'created', 'network', 'parent-author-id', 'private'];
@@ -113,7 +114,7 @@ class Status extends BaseFactory
                        $activity   = $item;
                        $item       = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
                        if (!$item) {
-                               throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
+                               throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
                        }
                        foreach ($activity_fields as $field) {
                                $item[$field] = $activity[$field];
@@ -202,7 +203,7 @@ class Status extends BaseFactory
                $sensitive = (bool)$item['sensitive'];
 
                $network  = ContactSelector::networkToName($item['network']);
-               $sitename = ''; 
+               $sitename = '';
                $platform = '';
                $version  = '';
 
@@ -211,7 +212,7 @@ class Status extends BaseFactory
                        if (!empty($gserver)) {
                                $platform = ucfirst($gserver['platform']);
                                $version  = $gserver['version'];
-                               $sitename = $gserver['site_name']; 
+                               $sitename = $gserver['site_name'];
                        }
                }
 
@@ -370,17 +371,17 @@ class Status extends BaseFactory
        }
 
        /**
-        * @param int $uriId id of the mail
+        * @param int $id id of the mail
         *
         * @return \Friendica\Object\Api\Mastodon\Status
-        * @throws HTTPException\InternalServerErrorException
-        * @throws ImagickException|HTTPException\NotFoundException
+        * @throws InternalServerErrorException
+        * @throws ImagickException|NotFoundException
         */
        public function createFromMailId(int $id): \Friendica\Object\Api\Mastodon\Status
        {
                $item = ActivityPub\Transmitter::getItemArrayFromMail($id, true);
                if (empty($item)) {
-                       throw new HTTPException\NotFoundException('Mail record not found with id: ' . $id);
+                       throw new NotFoundException('Mail record not found with id: ' . $id);
                }
 
                $account = $this->mstdnAccountFactory->createFromContactId($item['author-id']);
index b0d2511156145eef30a3943688b47cb4fa764671..67a0526bee3b9b8089610fa742bbb8338d517c3d 100644 (file)
@@ -20,7 +20,8 @@ class StatusSource extends BaseFactory
         *
         * @return \Friendica\Object\Api\Mastodon\StatusSource
         * @throws HTTPException\InternalServerErrorException
-        * @throws \ImagickException*@throws \Exception
+        * @throws \ImagickException
+        * @throws \Exception
         */
        public function createFromUriId(int $uriId, int $uid): \Friendica\Object\Api\Mastodon\StatusSource
        {
index 61d71850e3ddcc62053292cb9b36b7a705cb339f..b0aa56f96470086dcb6595464896f7d27227e005 100644 (file)
@@ -10,18 +10,17 @@ namespace Friendica\Factory\Api\Mastodon;
 use Friendica\BaseFactory;
 use Friendica\Database\DBA;
 use Friendica\Model\Subscription as ModelSubscription;
+use Friendica\Object\Api\Mastodon\Subscription as SubscriptionObject;
 
 class Subscription extends BaseFactory
 {
        /**
         * @param int $applicationid Application Id
         * @param int $uid           Item user
-        *
-        * @return \Friendica\Object\Api\Mastodon\Status
         */
-       public function createForApplicationIdAndUserId(int $applicationid, int $uid): \Friendica\Object\Api\Mastodon\Subscription
+       public function createForApplicationIdAndUserId(int $applicationid, int $uid): SubscriptionObject
        {
                $subscription = DBA::selectFirst('subscription', [], ['application-id' => $applicationid, 'uid' => $uid]);
-               return new \Friendica\Object\Api\Mastodon\Subscription($subscription, ModelSubscription::getPublicVapidKey());
+               return new SubscriptionObject($subscription, ModelSubscription::getPublicVapidKey());
        }
 }
index 084156b38275b419358d2bb3878ba4ffd53f5eaf..b31a89fc4469c1fd9114190a52d1197ea7da2001 100644 (file)
@@ -17,7 +17,8 @@ use Friendica\Factory\Api\Twitter\User as TwitterUser;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Model\Verb;
-use Friendica\Network\HTTPException;
+use Friendica\Network\HTTPException\InternalServerErrorException;
+use Friendica\Network\HTTPException\NotFoundException;
 use Friendica\Protocol\Activity;
 use ImagickException;
 use Psr\Log\LoggerInterface;
@@ -58,13 +59,13 @@ class Status extends BaseFactory
        }
 
        /**
-        * @param int $uriId Uri-ID of the item
+        * @param int $id    Uri-ID of the item
         * @param int $uid   Item user
         * @param bool $include_entities Whether to include entities
         *
         * @return \Friendica\Object\Api\Twitter\Status
-        * @throws HTTPException\InternalServerErrorException
-        * @throws ImagickException|HTTPException\NotFoundException
+        * @throws InternalServerErrorException
+        * @throws ImagickException|NotFoundException
         */
        public function createFromItemId(int $id, int $uid, bool $include_entities = false): \Friendica\Object\Api\Twitter\Status
        {
@@ -73,7 +74,7 @@ class Status extends BaseFactory
                        'thr-parent-id', 'parent-author-id', 'parent-author-nick', 'uri', 'plink', 'private', 'vid', 'coord', 'quote-uri-id'];
                $item = Post::selectFirst($fields, ['id' => $id], ['order' => ['uid' => true]]);
                if (!$item) {
-                       throw new HTTPException\NotFoundException('Item with ID ' . $id . ' not found.');
+                       throw new NotFoundException('Item with ID ' . $id . ' not found.');
                }
                return $this->createFromArray($item, $uid, $include_entities);
        }
@@ -84,8 +85,8 @@ class Status extends BaseFactory
         * @param bool $include_entities Whether to include entities
         *
         * @return \Friendica\Object\Api\Twitter\Status
-        * @throws HTTPException\InternalServerErrorException
-        * @throws ImagickException|HTTPException\NotFoundException
+        * @throws InternalServerErrorException
+        * @throws ImagickException|NotFoundException
         */
        public function createFromUriId(int $uriId, int $uid = 0, bool $include_entities = false): \Friendica\Object\Api\Twitter\Status
        {
@@ -94,7 +95,7 @@ class Status extends BaseFactory
                        'thr-parent-id', 'parent-author-id', 'parent-author-nick', 'uri', 'plink', 'private', 'vid', 'coord'];
                $item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
                if (!$item) {
-                       throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
+                       throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
                }
                return $this->createFromArray($item, $uid, $include_entities);
        }
@@ -105,8 +106,8 @@ class Status extends BaseFactory
         * @param bool $include_entities Whether to include entities
         *
         * @return \Friendica\Object\Api\Twitter\Status
-        * @throws HTTPException\InternalServerErrorException
-        * @throws ImagickException|HTTPException\NotFoundException
+        * @throws InternalServerErrorException
+        * @throws ImagickException|NotFoundException
         */
        private function createFromArray(array $item, int $uid, bool $include_entities): \Friendica\Object\Api\Twitter\Status
        {
@@ -161,8 +162,8 @@ class Status extends BaseFactory
                if ($include_entities) {
                        $hashtags = $this->hashtag->createFromUriId($item['uri-id'], $text);
                        $medias   = $this->media->createFromUriId($item['uri-id'], $text);
-                       $urls     = $this->url->createFromUriId($item['uri-id'], $text);
-                       $mentions = $this->mention->createFromUriId($item['uri-id'], $text);
+                       $urls     = $this->url->createFromUriId($item['uri-id']);
+                       $mentions = $this->mention->createFromUriId($item['uri-id']);
                } else {
                        $attachments = $this->attachment->createFromUriId($item['uri-id'], $text);
                }
@@ -176,8 +177,8 @@ class Status extends BaseFactory
                        if ($include_entities) {
                                $hashtags = array_merge($hashtags, $this->hashtag->createFromUriId($shared_uri_id, $text));
                                $medias   = array_merge($medias, $this->media->createFromUriId($shared_uri_id, $text));
-                               $urls     = array_merge($urls, $this->url->createFromUriId($shared_uri_id, $text));
-                               $mentions = array_merge($mentions, $this->mention->createFromUriId($shared_uri_id, $text));
+                               $urls     = array_merge($urls, $this->url->createFromUriId($shared_uri_id));
+                               $mentions = array_merge($mentions, $this->mention->createFromUriId($shared_uri_id));
                        } else {
                                $attachments = array_merge($attachments, $this->attachment->createFromUriId($shared_uri_id, $text));
                        }
index 21cf897893c3daf0334db5a038e75c18311cfda3..a75b55eea4d780259a9c189b6b12c3395c9d4a30 100644 (file)
@@ -11,16 +11,16 @@ use DateTime;
 use Friendica\BaseEntity;
 
 /**
- * @property-read $id
- * @property-read $uid
- * @property-read $verb
- * @property-read $type
- * @property-read $actorId
- * @property-read $targetUriId
- * @property-read $parentUriId
- * @property-read $created
- * @property-read $seen
- * @property-read $dismissed
+ * @property-read int $id
+ * @property-read int $uid
+ * @property-read string $verb
+ * @property-read int $type
+ * @property-read int $actorId
+ * @property-read int $targetUriId
+ * @property-read int $parentUriId
+ * @property-read DateTime $created
+ * @property-read bool $seen
+ * @property-read bool $dismissed
  */
 class Notification extends BaseEntity
 {
@@ -31,7 +31,7 @@ class Notification extends BaseEntity
        /** @var string */
        protected $verb;
        /**
-        * @var int One of the \Friendica\Model\Post\UserNotification::TYPE_* constant values
+        * @var int $type One of the \Friendica\Model\Post\UserNotification::TYPE_* constant values
         * @see \Friendica\Model\Post\UserNotification
         */
        protected $type;
index 959c973c5f9f6013a2a6b7b77d66278b1d700a73..f273b342e7f52d57341f5600349f32035110f08f 100644 (file)
@@ -11,6 +11,8 @@ namespace Friendica\Object\Api\Mastodon\Status;
  * Class Counts
  *
  * @see https://docs.joinmastodon.org/entities/status
+ *
+ * @property-read int $dislikes
  */
 class Counts
 {