From d4387d45ee9db51f0bda7d32a7e1805a32078aed Mon Sep 17 00:00:00 2001
From: Philipp <admin@philipp.info>
Date: Wed, 9 Jun 2021 00:09:32 +0200
Subject: [PATCH] Cleanup Code

---
 src/Collection/Api/Mastodon/Mentions.php   |  2 +-
 src/Factory/Api/Mastodon/Account.php       | 17 +++++-----
 src/Factory/Api/Mastodon/Application.php   |  4 +--
 src/Factory/Api/Mastodon/Attachment.php    | 24 +++++++--------
 src/Factory/Api/Mastodon/Card.php          |  5 +--
 src/Factory/Api/Mastodon/Conversation.php  |  7 ++++-
 src/Factory/Api/Mastodon/Emoji.php         |  6 ++--
 src/Factory/Api/Mastodon/Error.php         | 36 +++++++++++-----------
 src/Factory/Api/Mastodon/Field.php         |  4 +--
 src/Factory/Api/Mastodon/FollowRequest.php | 12 ++++----
 src/Factory/Api/Mastodon/ListEntity.php    |  6 +++-
 src/Factory/Api/Mastodon/Mention.php       |  9 +++---
 src/Factory/Api/Mastodon/Notification.php  |  8 ++---
 src/Factory/Api/Mastodon/Relationship.php  |  5 +--
 src/Factory/Api/Mastodon/Status.php        |  6 ++--
 src/Factory/Api/Mastodon/Tag.php           |  7 ++---
 src/Object/Api/Mastodon/Error.php          |  1 -
 src/Object/Api/Mastodon/Notification.php   |  5 +--
 18 files changed, 86 insertions(+), 78 deletions(-)

diff --git a/src/Collection/Api/Mastodon/Mentions.php b/src/Collection/Api/Mastodon/Mentions.php
index 22ebaa7472..5bc0271600 100644
--- a/src/Collection/Api/Mastodon/Mentions.php
+++ b/src/Collection/Api/Mastodon/Mentions.php
@@ -10,7 +10,7 @@ class Mentions extends BaseCollection
 	/**
 	 * @return Mention
 	 */
-	public function current()
+	public function current(): Mention
 	{
 		return parent::current();
 	}
diff --git a/src/Factory/Api/Mastodon/Account.php b/src/Factory/Api/Mastodon/Account.php
index f8474eb5e2..dd4ebcfaec 100644
--- a/src/Factory/Api/Mastodon/Account.php
+++ b/src/Factory/Api/Mastodon/Account.php
@@ -29,6 +29,7 @@ use Friendica\Model\Contact;
 use Friendica\Network\HTTPException;
 use Friendica\Repository\PermissionSet;
 use Friendica\Repository\ProfileField;
+use ImagickException;
 use Psr\Log\LoggerInterface;
 
 class Account extends BaseFactory
@@ -52,11 +53,12 @@ class Account extends BaseFactory
 	/**
 	 * @param int $contactId
 	 * @param int $uid        Public contact (=0) or owner user id
+	 *
 	 * @return \Friendica\Object\Api\Mastodon\Account
 	 * @throws HTTPException\InternalServerErrorException
-	 * @throws \ImagickException
+	 * @throws ImagickException|HTTPException\NotFoundException
 	 */
-	public function createFromContactId(int $contactId, $uid = 0)
+	public function createFromContactId(int $contactId, $uid = 0): \Friendica\Object\Api\Mastodon\Account
 	{
 		$cdata = Contact::getPublicAndUserContacID($contactId, $uid);
 		if (!empty($cdata)) {
@@ -64,7 +66,7 @@ class Account extends BaseFactory
 			$userContact   = Contact::getById($cdata['user']);
 		} else {
 			$publicContact = Contact::getById($contactId);
-			$userContact = [];
+			$userContact   = [];
 		}
 
 		if (empty($publicContact)) {
@@ -87,18 +89,17 @@ class Account extends BaseFactory
 	/**
 	 * @param int $userId
 	 * @return \Friendica\Object\Api\Mastodon\Account
-	 * @throws HTTPException\InternalServerErrorException
-	 * @throws \ImagickException
+	 * @throws ImagickException|HTTPException\InternalServerErrorException
 	 */
-	public function createFromUserId(int $userId)
+	public function createFromUserId(int $userId): \Friendica\Object\Api\Mastodon\Account
 	{
 		$publicContact = Contact::selectFirst([], ['uid' => $userId, 'self' => true]);
 
 		$profileFields = $this->profileFieldRepo->select(['uid' => $userId, 'psid' => PermissionSet::PUBLIC]);
 		$fields        = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
 
-		$apcontact     = APContact::getByURL($publicContact['url'], false);
+		$apContact = APContact::getByURL($publicContact['url'], false);
 
-		return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $publicContact, $fields, $apcontact);
+		return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $publicContact, $fields, $apContact);
 	}
 }
diff --git a/src/Factory/Api/Mastodon/Application.php b/src/Factory/Api/Mastodon/Application.php
index b387a199c5..f0567f2ebd 100644
--- a/src/Factory/Api/Mastodon/Application.php
+++ b/src/Factory/Api/Mastodon/Application.php
@@ -44,11 +44,11 @@ class Application extends BaseFactory
 	 *
 	 * @throws InternalServerErrorException
 	 */
-	public function createFromApplicationId(int $id)
+	public function createFromApplicationId(int $id): \Friendica\Object\Api\Mastodon\Application
 	{
 		$application = $this->dba->selectFirst('application', ['client_id', 'client_secret', 'id', 'name', 'redirect_uri', 'website'], ['id' => $id]);
 		if (!$this->dba->isResult($application)) {
-			return [];
+			throw new InternalServerErrorException(sprintf("ID '%s' not found", $id));
 		}
 
 		return new \Friendica\Object\Api\Mastodon\Application(
diff --git a/src/Factory/Api/Mastodon/Attachment.php b/src/Factory/Api/Mastodon/Attachment.php
index 12381dbb6a..0cb4977ee1 100644
--- a/src/Factory/Api/Mastodon/Attachment.php
+++ b/src/Factory/Api/Mastodon/Attachment.php
@@ -46,13 +46,11 @@ class Attachment extends BaseFactory
 	 * @param int $uriId Uri-ID of the attachments
 	 * @return array
 	 * @throws HTTPException\InternalServerErrorException
-	 * @throws \ImagickException
 	 */
-	public function createFromUriId(int $uriId)
+	public function createFromUriId(int $uriId): array
 	{
 		$attachments = [];
 		foreach (Post\Media::getByURIId($uriId, [Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE]) as $attachment) {
-
 			$filetype = !empty($attachment['mimetype']) ? strtolower(substr($attachment['mimetype'], 0, strpos($attachment['mimetype'], '/'))) : '';
 
 			if (($filetype == 'audio') || ($attachment['type'] == Post\Media::AUDIO)) {
@@ -70,19 +68,19 @@ class Attachment extends BaseFactory
 			$remote = $attachment['url'];
 			if ($type == 'image') {
 				if (Proxy::isLocalImage($attachment['url'])) {
-					$url = $attachment['url'];
+					$url     = $attachment['url'];
 					$preview = $attachment['preview'] ?? $url;
-					$remote = '';
+					$remote  = '';
 				} else {
-					$url = Proxy::proxifyUrl($attachment['url']);
+					$url     = Proxy::proxifyUrl($attachment['url']);
 					$preview = Proxy::proxifyUrl($attachment['url'], false, Proxy::SIZE_SMALL);
 				}
 			} else {
-				$url = Proxy::proxifyUrl($attachment['url']);
+				$url     = Proxy::proxifyUrl($attachment['url     ']);
 				$preview = Proxy::proxifyUrl($attachment['preview'] ?? '');
 			}
 
-			$object = new \Friendica\Object\Api\Mastodon\Attachment($attachment, $type, $url, $preview, $remote);
+			$object        = new \Friendica\Object\Api\Mastodon\Attachment($attachment, $type, $url, $preview, $remote);
 			$attachments[] = $object->toArray();
 		}
 
@@ -91,21 +89,21 @@ class Attachment extends BaseFactory
 
 	/**
 	 * @param int $id id of the photo
+	 *
 	 * @return array
 	 * @throws HTTPException\InternalServerErrorException
-	 * @throws \ImagickException
 	 */
-	public function createFromPhoto(int $id)
+	public function createFromPhoto(int $id): array
 	{
 		$photo = Photo::selectFirst(['resource-id', 'uid', 'id', 'title', 'type'], ['id' => $id]);
 		if (empty($photo)) {
-			return null;
+			return [];
 		}
 
 		$attachment = ['id' => $photo['id'], 'description' => $photo['title']];
 
-		$phototypes = Images::supportedTypes();
-		$ext = $phototypes[$photo['type']];
+		$photoTypes = Images::supportedTypes();
+		$ext        = $photoTypes[$photo['type']];
 
 		$url = $this->baseUrl . '/photo/' . $photo['resource-id'] . '-0.' . $ext;
 
diff --git a/src/Factory/Api/Mastodon/Card.php b/src/Factory/Api/Mastodon/Card.php
index f7512b3903..0d7f7d3770 100644
--- a/src/Factory/Api/Mastodon/Card.php
+++ b/src/Factory/Api/Mastodon/Card.php
@@ -31,11 +31,12 @@ class Card extends BaseFactory
 {
 	/**
 	 * @param int $uriId Uri-ID of the item
+	 *
 	 * @return \Friendica\Object\Api\Mastodon\Card
 	 * @throws HTTPException\InternalServerErrorException
-	 * @throws \ImagickException
+	 * @throws \ImagickException*@throws \Exception
 	 */
-	public function createFromUriId(int $uriId)
+	public function createFromUriId(int $uriId): \Friendica\Object\Api\Mastodon\Card
 	{
 		$item = Post::selectFirst(['body'], ['uri-id' => $uriId]);
 		if (!empty($item['body'])) {
diff --git a/src/Factory/Api/Mastodon/Conversation.php b/src/Factory/Api/Mastodon/Conversation.php
index ad873ba9a4..9c610f7b0e 100644
--- a/src/Factory/Api/Mastodon/Conversation.php
+++ b/src/Factory/Api/Mastodon/Conversation.php
@@ -24,6 +24,8 @@ namespace Friendica\Factory\Api\Mastodon;
 use Friendica\BaseFactory;
 use Friendica\Database\Database;
 use Friendica\Model\Contact;
+use Friendica\Network\HTTPException;
+use ImagickException;
 use Psr\Log\LoggerInterface;
 
 class Conversation extends BaseFactory
@@ -43,7 +45,10 @@ class Conversation extends BaseFactory
 		$this->mstdnAccountFactory = $mstdnAccountFactoryFactory;
 	}
 
-	public function CreateFromConvId(int $id)
+	/**
+	 * @throws ImagickException|HTTPException\InternalServerErrorException|HTTPException\NotFoundException
+	 */
+	public function CreateFromConvId(int $id): \Friendica\Object\Api\Mastodon\Conversation
 	{
 		$accounts    = [];
 		$unread      = false;
diff --git a/src/Factory/Api/Mastodon/Emoji.php b/src/Factory/Api/Mastodon/Emoji.php
index c05bda7f3e..5e28f0d0d3 100644
--- a/src/Factory/Api/Mastodon/Emoji.php
+++ b/src/Factory/Api/Mastodon/Emoji.php
@@ -26,7 +26,7 @@ use Friendica\Collection\Api\Mastodon\Emojis;
 
 class Emoji extends BaseFactory
 {
-	public function create(string $shortcode, string $url)
+	public function create(string $shortcode, string $url): \Friendica\Object\Api\Mastodon\Emoji
 	{
 		return new \Friendica\Object\Api\Mastodon\Emoji($shortcode, $url);
 	}
@@ -35,7 +35,7 @@ class Emoji extends BaseFactory
 	 * @param array $smilies
 	 * @return Emojis
 	 */
-	public function createCollectionFromSmilies(array $smilies)
+	public function createCollectionFromSmilies(array $smilies): Emojis
 	{
 		$prototype = null;
 
@@ -47,7 +47,7 @@ class Emoji extends BaseFactory
 
 				if ($prototype === null) {
 					$prototype = $this->create($shortcode, $url);
-					$emojis[] = $prototype;
+					$emojis[]  = $prototype;
 				} else {
 					$emojis[] = \Friendica\Object\Api\Mastodon\Emoji::createFromPrototype($prototype, $shortcode, $url);
 				}
diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php
index a4dd66ccc5..3ab8b1c327 100644
--- a/src/Factory/Api/Mastodon/Error.php
+++ b/src/Factory/Api/Mastodon/Error.php
@@ -36,13 +36,13 @@ class Error extends BaseFactory
 	private $server;
 	/** @var L10n */
 	private $l10n;
-	
+
 	public function __construct(LoggerInterface $logger, Arguments $args, L10n $l10n, array $server)
 	{
 		parent::__construct($logger);
-		$this->args = $args;
+		$this->args   = $args;
 		$this->server = $server;
-		$this->l10n = $l10n;
+		$this->l10n   = $l10n;
 	}
 
 	private function logError(int $errorno, string $error)
@@ -52,51 +52,51 @@ class Error extends BaseFactory
 
 	public function RecordNotFound()
 	{
-		$error = $this->l10n->t('Record not found');
+		$error             = $this->l10n->t('Record not found');
 		$error_description = '';
-		$errorobj = New \Friendica\Object\Api\Mastodon\Error($error, $error_description);
+		$errorObj          = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
 
 		$this->logError(404, $error);
-		System::jsonError(404, $errorobj->toArray());
+		System::jsonError(404, $errorObj->toArray());
 	}
 
 	public function UnprocessableEntity(string $error = '')
 	{
-		$error = $error ?: $this->l10n->t('Unprocessable Entity');
+		$error             = $error ?: $this->l10n->t('Unprocessable Entity');
 		$error_description = '';
-		$errorobj = New \Friendica\Object\Api\Mastodon\Error($error, $error_description);
+		$errorObj          = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
 
 		$this->logError(422, $error);
-		System::jsonError(422, $errorobj->toArray());
+		System::jsonError(422, $errorObj->toArray());
 	}
 
 	public function Unauthorized(string $error = '')
 	{
-		$error = $error ?: $this->l10n->t('Unauthorized');
+		$error             = $error ?: $this->l10n->t('Unauthorized');
 		$error_description = '';
-		$errorobj = New \Friendica\Object\Api\Mastodon\Error($error, $error_description);
+		$errorObj          = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
 
 		$this->logError(401, $error);
-		System::jsonError(401, $errorobj->toArray());
+		System::jsonError(401, $errorObj->toArray());
 	}
 
 	public function Forbidden(string $error = '')
 	{
-		$error = $error ?: $this->l10n->t('Token is not authorized with a valid user or is missing a required scope');
+		$error             = $error ?: $this->l10n->t('Token is not authorized with a valid user or is missing a required scope');
 		$error_description = '';
-		$errorobj = New \Friendica\Object\Api\Mastodon\Error($error, $error_description);
+		$errorObj          = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
 
 		$this->logError(403, $error);
-		System::jsonError(403, $errorobj->toArray());
+		System::jsonError(403, $errorObj->toArray());
 	}
 
 	public function InternalError(string $error = '')
 	{
-		$error = $error ?: $this->l10n->t('Internal Server Error');
+		$error             = $error ?: $this->l10n->t('Internal Server Error');
 		$error_description = '';
-		$errorobj = New \Friendica\Object\Api\Mastodon\Error($error, $error_description);
+		$errorObj          = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
 
 		$this->logError(500, $error);
-		System::jsonError(500, $errorobj->toArray());
+		System::jsonError(500, $errorObj->toArray());
 	}
 }
diff --git a/src/Factory/Api/Mastodon/Field.php b/src/Factory/Api/Mastodon/Field.php
index 86c20e1f06..6ff63fb1bf 100644
--- a/src/Factory/Api/Mastodon/Field.php
+++ b/src/Factory/Api/Mastodon/Field.php
@@ -35,7 +35,7 @@ class Field extends BaseFactory
 	 * @return \Friendica\Object\Api\Mastodon\Field
 	 * @throws HTTPException\InternalServerErrorException
 	 */
-	public function createFromProfileField(ProfileField $profileField)
+	public function createFromProfileField(ProfileField $profileField): \Friendica\Object\Api\Mastodon\Field
 	{
 		return new \Friendica\Object\Api\Mastodon\Field($profileField->label, BBCode::convert($profileField->value, false, BBCode::ACTIVITYPUB));
 	}
@@ -45,7 +45,7 @@ class Field extends BaseFactory
 	 * @return Fields
 	 * @throws HTTPException\InternalServerErrorException
 	 */
-	public function createFromProfileFields(ProfileFields $profileFields)
+	public function createFromProfileFields(ProfileFields $profileFields): Fields
 	{
 		$fields = [];
 
diff --git a/src/Factory/Api/Mastodon/FollowRequest.php b/src/Factory/Api/Mastodon/FollowRequest.php
index 84c5ec7132..f0724e5f18 100644
--- a/src/Factory/Api/Mastodon/FollowRequest.php
+++ b/src/Factory/Api/Mastodon/FollowRequest.php
@@ -27,6 +27,7 @@ use Friendica\Model\APContact;
 use Friendica\Model\Contact;
 use Friendica\Model\Introduction;
 use Friendica\Network\HTTPException;
+use ImagickException;
 use Psr\Log\LoggerInterface;
 
 class FollowRequest extends BaseFactory
@@ -44,10 +45,9 @@ class FollowRequest extends BaseFactory
 	/**
 	 * @param Introduction $introduction
 	 * @return \Friendica\Object\Api\Mastodon\FollowRequest
-	 * @throws HTTPException\InternalServerErrorException
-	 * @throws \ImagickException
+	 * @throws ImagickException|HTTPException\InternalServerErrorException
 	 */
-	public function createFromIntroduction(Introduction $introduction)
+	public function createFromIntroduction(Introduction $introduction): \Friendica\Object\Api\Mastodon\FollowRequest
 	{
 		$cdata = Contact::getPublicAndUserContacID($introduction->{'contact-id'}, $introduction->uid);
 
@@ -57,10 +57,10 @@ class FollowRequest extends BaseFactory
 		}
 
 		$publicContact = Contact::getById($cdata['public']);
-		$userContact = Contact::getById($cdata['user']);
+		$userContact   = Contact::getById($cdata['user']);
 
-		$apcontact = APContact::getByURL($publicContact['url'], false);
+		$apContact = APContact::getByURL($publicContact['url'], false);
 
-		return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $publicContact, $apcontact, $userContact);
+		return new \Friendica\Object\Api\Mastodon\FollowRequest($this->baseUrl, $introduction->id, $publicContact, $apContact, $userContact);
 	}
 }
diff --git a/src/Factory/Api/Mastodon/ListEntity.php b/src/Factory/Api/Mastodon/ListEntity.php
index a766d053f6..82fbd5e652 100644
--- a/src/Factory/Api/Mastodon/ListEntity.php
+++ b/src/Factory/Api/Mastodon/ListEntity.php
@@ -23,6 +23,7 @@ namespace Friendica\Factory\Api\Mastodon;
 
 use Friendica\BaseFactory;
 use Friendica\Database\Database;
+use Friendica\Network\HTTPException\InternalServerErrorException;
 use Psr\Log\LoggerInterface;
 
 class ListEntity extends BaseFactory
@@ -36,7 +37,10 @@ class ListEntity extends BaseFactory
 		$this->dba = $dba;
 	}
 
-	public function createFromGroupId(int $id)
+	/**
+	 * @throws InternalServerErrorException
+	 */
+	public function createFromGroupId(int $id): \Friendica\Object\Api\Mastodon\ListEntity
 	{
 		$group = $this->dba->selectFirst('group', ['name'], ['id' => $id, 'deleted' => false]);
 		return new \Friendica\Object\Api\Mastodon\ListEntity($id, $group['name'] ?? '', 'list');
diff --git a/src/Factory/Api/Mastodon/Mention.php b/src/Factory/Api/Mastodon/Mention.php
index cf863472c6..597f205db8 100644
--- a/src/Factory/Api/Mastodon/Mention.php
+++ b/src/Factory/Api/Mastodon/Mention.php
@@ -45,15 +45,14 @@ class Mention extends BaseFactory
 	 * @param int $uriId Uri-ID of the item
 	 * @return Mentions
 	 * @throws HTTPException\InternalServerErrorException
-	 * @throws \ImagickException
 	 */
-	public function createFromUriId(int $uriId)
+	public function createFromUriId(int $uriId): Mentions
 	{
 		$mentions = new Mentions();
-		$tags = Tag::getByURIId($uriId, [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION]);
+		$tags     = Tag::getByURIId($uriId, [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION]);
 		foreach ($tags as $tag) {
-			$contact = Contact::getByURL($tag['url'], false);
-			$mentions->append(new \Friendica\Object\Api\Mastodon\Mention($this->baseUrl, $tag, $contact));
+			$contact    = Contact::getByURL($tag['url'], false);
+			$mentions[] = new \Friendica\Object\Api\Mastodon\Mention($this->baseUrl, $tag, $contact);
 		}
 		return $mentions;
 	}
diff --git a/src/Factory/Api/Mastodon/Notification.php b/src/Factory/Api/Mastodon/Notification.php
index ef3d2b6674..2376e58cc9 100644
--- a/src/Factory/Api/Mastodon/Notification.php
+++ b/src/Factory/Api/Mastodon/Notification.php
@@ -37,13 +37,13 @@ class Notification extends BaseFactory
 	private $mstdnAccountFactory;
 	/** @var Status */
 	private $mstdnStatusFactory;
-	
+
 	public function __construct(LoggerInterface $logger, Database $dba, Account $mstdnAccountFactory, Status $mstdnStatusFactoryFactory)
 	{
 		parent::__construct($logger);
-		$this->dba = $dba;
+		$this->dba                 = $dba;
 		$this->mstdnAccountFactory = $mstdnAccountFactory;
-		$this->mstdnStatusFactory = $mstdnStatusFactoryFactory;
+		$this->mstdnStatusFactory  = $mstdnStatusFactoryFactory;
 	}
 
 	public function createFromNotificationId(int $id)
@@ -64,7 +64,7 @@ class Notification extends BaseFactory
 
 		if (($notification['vid'] == Verb::getID(Activity::FOLLOW)) && ($notification['type'] == Post\UserNotification::NOTIF_NONE)) {
 			$contact = Contact::getById($notification['actor-id'], ['pending']);
-			$type = $contact['pending'] ? $type = 'follow_request' : 'follow';
+			$type    = $contact['pending'] ? $type    = 'follow_request' : 'follow';
 		} elseif (($notification['vid'] == Verb::getID(Activity::ANNOUNCE)) &&
 			in_array($notification['type'], [Post\UserNotification::NOTIF_DIRECT_COMMENT, Post\UserNotification::NOTIF_DIRECT_THREAD_COMMENT])) {
 			$type = 'reblog';
diff --git a/src/Factory/Api/Mastodon/Relationship.php b/src/Factory/Api/Mastodon/Relationship.php
index 7111148344..4d08cbb1d2 100644
--- a/src/Factory/Api/Mastodon/Relationship.php
+++ b/src/Factory/Api/Mastodon/Relationship.php
@@ -21,6 +21,7 @@
 
 namespace Friendica\Factory\Api\Mastodon;
 
+use Exception;
 use Friendica\Object\Api\Mastodon\Relationship as RelationshipEntity;
 use Friendica\BaseFactory;
 use Friendica\Model\Contact;
@@ -31,9 +32,9 @@ class Relationship extends BaseFactory
 	 * @param int $contactId Contact ID (public or user contact)
 	 * @param int $uid User ID
 	 * @return RelationshipEntity
-	 * @throws \Exception
+	 * @throws Exception
 	 */
-	public function createFromContactId(int $contactId, int $uid)
+	public function createFromContactId(int $contactId, int $uid): RelationshipEntity
 	{
 		$cdata = Contact::getPublicAndUserContacID($contactId, $uid);
 		if (!empty($cdata)) {
diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php
index 3e8e3c4a3f..69257d652b 100644
--- a/src/Factory/Api/Mastodon/Status.php
+++ b/src/Factory/Api/Mastodon/Status.php
@@ -73,7 +73,7 @@ class Status extends BaseFactory
 	 * @throws HTTPException\InternalServerErrorException
 	 * @throws ImagickException|HTTPException\NotFoundException
 	 */
-	public function createFromUriId(int $uriId, $uid = 0)
+	public function createFromUriId(int $uriId, $uid = 0): \Friendica\Object\Api\Mastodon\Status
 	{
 		$fields = ['uri-id', 'uid', 'author-id', 'author-link', 'starred', 'app', 'title', 'body', 'raw-body', 'created', 'network',
 			'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity'];
@@ -163,9 +163,9 @@ class Status extends BaseFactory
 	 *
 	 * @return \Friendica\Object\Api\Mastodon\Status
 	 * @throws HTTPException\InternalServerErrorException
-	 * @throws ImagickException
+	 * @throws ImagickException|HTTPException\NotFoundException
 	 */
-	public function createFromMailId(int $id)
+	public function createFromMailId(int $id): \Friendica\Object\Api\Mastodon\Status
 	{
 		$item = ActivityPub\Transmitter::ItemArrayFromMail($id, true);
 		if (empty($item)) {
diff --git a/src/Factory/Api/Mastodon/Tag.php b/src/Factory/Api/Mastodon/Tag.php
index 566b4c2696..c5a51c5484 100644
--- a/src/Factory/Api/Mastodon/Tag.php
+++ b/src/Factory/Api/Mastodon/Tag.php
@@ -43,14 +43,13 @@ class Tag extends BaseFactory
 	 * @param int $uriId Uri-ID of the item
 	 * @return array
 	 * @throws HTTPException\InternalServerErrorException
-	 * @throws \ImagickException
 	 */
-	public function createFromUriId(int $uriId)
+	public function createFromUriId(int $uriId): array
 	{
 		$hashtags = [];
-		$tags = TagModel::getByURIId($uriId, [TagModel::HASHTAG]);
+		$tags     = TagModel::getByURIId($uriId, [TagModel::HASHTAG]);
 		foreach ($tags as $tag) {
-			$hashtag = new \Friendica\Object\Api\Mastodon\Tag($this->baseUrl, $tag);
+			$hashtag    = new \Friendica\Object\Api\Mastodon\Tag($this->baseUrl, $tag);
 			$hashtags[] = $hashtag->toArray();
 		}
 		return $hashtags;
diff --git a/src/Object/Api/Mastodon/Error.php b/src/Object/Api/Mastodon/Error.php
index 9b0964ef79..be3ce007fb 100644
--- a/src/Object/Api/Mastodon/Error.php
+++ b/src/Object/Api/Mastodon/Error.php
@@ -40,7 +40,6 @@ class Error extends BaseDataTransferObject
 	 *
 	 * @param string $error
 	 * @param string error_description
-	 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
 	 */
 	public function __construct(string $error, string $error_description)
 	{
diff --git a/src/Object/Api/Mastodon/Notification.php b/src/Object/Api/Mastodon/Notification.php
index 579598db6d..5f39c503e2 100644
--- a/src/Object/Api/Mastodon/Notification.php
+++ b/src/Object/Api/Mastodon/Notification.php
@@ -21,7 +21,9 @@
 
 namespace Friendica\Object\Api\Mastodon;
 
+use Exception;
 use Friendica\BaseDataTransferObject;
+use Friendica\Network\HTTPException;
 use Friendica\Util\DateTimeFormat;
 
 /**
@@ -45,8 +47,7 @@ class Notification extends BaseDataTransferObject
 	/**
 	 * Creates a notification record
 	 *
-	 * @param array   $item
-	 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+	 * @throws HttpException\InternalServerErrorException|Exception
 	 */
 	public function __construct(int $id, string $type, string $created_at, Account $account = null, Status $status = null)
 	{