Fix errors in Model namespace

This commit is contained in:
Art4 2024-12-03 22:46:40 +00:00
parent 06e3051ad1
commit 2c801abb06
6 changed files with 99 additions and 105 deletions

View file

@ -7,10 +7,10 @@
namespace Friendica\Model;
use Exception;
use Friendica\Contact\Avatar;
use Friendica\Contact\Header;
use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException;
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
use Friendica\Content\Conversation as ConversationContent;
use Friendica\Content\Pager;
use Friendica\Content\Text\HTML;
@ -25,7 +25,8 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
@ -104,7 +105,7 @@ class Contact
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array
* @throws \Exception
* @throws Exception
*/
public static function selectToArray(array $fields = [], array $condition = [], array $params = []): array
{
@ -116,7 +117,7 @@ class Contact
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array|bool
* @throws \Exception
* @throws Exception
*/
public static function selectFirst(array $fields = [], array $condition = [], array $params = [])
{
@ -130,7 +131,7 @@ class Contact
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array
* @throws \Exception
* @throws Exception
*/
public static function selectAccountToArray(array $fields = [], array $condition = [], array $params = []): array
{
@ -142,7 +143,7 @@ class Contact
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array|bool
* @throws \Exception
* @throws Exception
*/
public static function selectFirstAccount(array $fields = [], array $condition = [], array $params = [])
{
@ -162,7 +163,7 @@ class Contact
* @param int $duplicate_mode Do an update on a duplicate entry
*
* @return int id of the created contact
* @throws \Exception
* @throws Exception
*/
public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT): int
{
@ -233,7 +234,7 @@ class Contact
* @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields)
*
* @return boolean was the update successful?
* @throws \Exception
* @throws Exception
* @todo Let's get rid of boolean type of $old_fields
*/
public static function update(array $fields, array $condition, $old_fields = []): bool
@ -249,7 +250,7 @@ class Contact
* @param integer $id Contact ID
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception
* @throws Exception
*/
public static function getAccountById(int $id, array $fields = [])
{
@ -260,7 +261,7 @@ class Contact
* @param integer $id Contact ID
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception
* @throws Exception
*/
public static function getById(int $id, array $fields = [])
{
@ -273,7 +274,7 @@ class Contact
* @param integer $uri_id uri-id of the contact
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception
* @throws Exception
*/
public static function getByUriId(int $uri_id, array $fields = [])
{
@ -288,7 +289,7 @@ class Contact
*
* @return array all remote contacts
*
* @throws \Exception
* @throws Exception
*/
public static function getVisitorByUrl(string $url, array $fields = ['id', 'uid']): array
{
@ -432,7 +433,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact id a follower?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isFollower(int $cid, int $uid, bool $strict = false): bool
@ -461,7 +462,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact id a follower?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isFollowerByURL(string $url, int $uid, bool $strict = false): bool
@ -483,7 +484,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact sharing with given user?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isSharing(int $cid, int $uid, bool $strict = false): bool
@ -512,7 +513,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact url being followed?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isSharingByURL(string $url, int $uid, bool $strict = false): bool
@ -544,7 +545,7 @@ class Contact
* @param boolean $dont_update Don't update the contact
*
* @return string basepath
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getBasepath(string $url, bool $dont_update = false): string
@ -594,7 +595,7 @@ class Contact
/**
* Check if the given contact ID is on the same server
*
* @param string $url The contact link
* @param int $cid The contact link
* @return boolean Is it the same server?
*/
public static function isLocalById(int $cid): bool
@ -619,7 +620,7 @@ class Contact
* @param integer $uid User ID
*
* @return integer|boolean Public contact id for given user id
* @throws \Exception
* @throws Exception
*/
public static function getPublicIdByUserId(int $uid)
{
@ -634,7 +635,7 @@ class Contact
* @param int $uid User ID
*
* @return array with public and user's contact id
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getPublicAndUserContactID(int $cid, int $uid): array
@ -700,7 +701,7 @@ class Contact
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return array with public and user's contact id
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
private static function legacyGetPublicAndUserContactID(int $cid, int $uid): array
@ -741,7 +742,7 @@ class Contact
* @param array $fields The selected fields for the contact
* @return array The contact details
*
* @throws \Exception
* @throws Exception
*/
public static function getContactForUser(int $cid, int $uid, array $fields = []): array
{
@ -759,7 +760,7 @@ class Contact
*
* @param int $uid
* @return bool Operation success
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function createSelfFromUserId(int $uid): bool
{
@ -822,7 +823,7 @@ class Contact
* @param int $uid
* @param bool $update_avatar Force the avatar update
* @return bool "true" if updated
* @throws \Exception
* @throws Exception
*/
public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool
{
@ -943,7 +944,7 @@ class Contact
*
* @param int $id contact id
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function remove(int $id)
{
@ -973,7 +974,7 @@ class Contact
*
* @param array $contact Target user-specific contact (uid != 0) array
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function unfollow(array $contact): void
@ -1003,7 +1004,7 @@ class Contact
*
* @param array $contact User-specific contact array (uid != 0) to revoke the follow from
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function revokeFollow(array $contact): void
@ -1031,7 +1032,7 @@ class Contact
*
* @param array $contact User-specific contact (uid != 0) array
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function terminateFriendship(array $contact)
@ -1078,7 +1079,7 @@ class Contact
*
* @param array $contact contact to mark for archival
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function markForArchival(array $contact)
{
@ -1129,7 +1130,7 @@ class Contact
*
* @param array $contact contact to be unmarked for archival
* @return void
* @throws \Exception
* @throws Exception
*/
public static function unmarkForArchival(array $contact)
{
@ -1169,7 +1170,7 @@ class Contact
* @param array $contact contact
* @param int $uid Visitor user id
* @return array
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function photoMenu(array $contact, int $uid): array
@ -1301,7 +1302,7 @@ class Contact
* @param array $default Default value for creating the contact when everything else fails
*
* @return integer Contact ID
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getIdForURL(string $url = null, int $uid = 0, $update = null, array $default = []): int
@ -1442,7 +1443,7 @@ class Contact
if ($data['network'] == Protocol::DIASPORA) {
try {
DI::dsprContact()->updateFromProbeArray($data);
} catch (HTTPException\NotFoundException $e) {
} catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
@ -1450,7 +1451,7 @@ class Contact
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
} catch (HTTPException\NotFoundException $e) {
} catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
@ -1475,7 +1476,7 @@ class Contact
* @param int $cid contact id
*
* @return boolean Is the contact archived?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function isArchived(int $cid): bool
{
@ -1518,7 +1519,7 @@ class Contact
*
* @param int $cid contact id
* @return boolean Is the contact blocked?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function isBlocked(int $cid): bool
{
@ -1543,7 +1544,7 @@ class Contact
*
* @param int $cid contact id
* @return boolean Is the contact hidden?
* @throws \Exception
* @throws Exception
*/
public static function isHidden(int $cid): bool
{
@ -1566,7 +1567,7 @@ class Contact
* @param bool $only_media Only display media content
* @param string $last_created Newest creation date, used for paging
* @return string posts in HTML
* @throws \Exception
* @throws Exception
*/
public static function getPostsFromUrl(string $contact_url, int $uid, bool $only_media = false, string $last_created = null): string
{
@ -1581,7 +1582,7 @@ class Contact
* @param bool $only_media Only display media content
* @param string $last_created Newest creation date, used for paging
* @return string posts in HTML
* @throws \Exception
* @throws Exception
*/
public static function getPostsFromId(int $cid, int $uid, bool $only_media = false, string $last_created = null): string
{
@ -1653,7 +1654,7 @@ class Contact
* @param int $update Update mode
* @param int $parent Item parent ID for the update mode
* @return string posts in HTML
* @throws \Exception
* @throws Exception
*/
public static function getThreadsFromId(int $cid, int $uid, int $update = 0, int $parent = 0, string $last_created = ''): string
{
@ -2286,8 +2287,8 @@ class Contact
* @param bool $create_cache Enforces the creation of cached avatar fields
*
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws NotFoundException
* @throws \ImagickException
*/
public static function updateAvatar(int $cid, string $avatar, bool $force = false, bool $create_cache = false)
@ -2486,7 +2487,7 @@ class Contact
* @param integer $id contact id
* @param string $url The new URL to use for polling
*
* @throws \Exception
* @throws Exception
*/
public static function updatePollUrl(int $id, string $url)
{
@ -2502,7 +2503,7 @@ class Contact
* @param string $url The profile URL of the contact
* @param array $fields The fields that are updated
*
* @throws \Exception
* @throws Exception
*/
private static function updateContact(int $id, int $uid, int $uri_id, string $url, array $fields)
{
@ -2595,7 +2596,7 @@ class Contact
* @param string $nurl Normalised contact url
* @param integer $uid User id
* @return boolean
* @throws \Exception
* @throws Exception
*/
public static function removeDuplicates(string $nurl, int $uid)
{
@ -2673,7 +2674,7 @@ class Contact
* @param integer $id contact id
* @param string $network Optional network we are probing for
* @return boolean
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function updateFromProbe(int $id, string $network = ''): bool
@ -2696,7 +2697,7 @@ class Contact
if ($data['network'] == Protocol::DIASPORA) {
try {
DI::dsprContact()->updateFromProbeArray($data);
} catch (HTTPException\NotFoundException $e) {
} catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
@ -2704,7 +2705,7 @@ class Contact
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
} catch (HTTPException\NotFoundException $e) {
} catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
@ -2760,7 +2761,7 @@ class Contact
* @param integer $id contact id
* @param array $ret Probed data
* @return boolean
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
private static function updateFromProbeArray(int $id, array $ret): bool
@ -3012,9 +3013,9 @@ class Contact
/**
* Updates contact record by provided URL
*
* @param integer $url contact url
* @return integer Contact id
* @throws HTTPException\InternalServerErrorException
* @param string $url contact url
* @return int Contact id
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function updateFromProbeByURL(string $url): int
@ -3069,8 +3070,8 @@ class Contact
* @param string $url The profile URL of the contact
* @param string $network
* @return array
* @throws HTTPException\InternalServerErrorException
* @throws HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws NotFoundException
* @throws \ImagickException
*/
public static function createFromProbeForUser(int $uid, string $url, string $network = ''): array
@ -3258,7 +3259,7 @@ class Contact
* @param bool $sharing True: Contact is now sharing with Owner; False: Contact is now following Owner (default)
* @param string $note Introduction additional message
* @return bool|null True: follow request is accepted; False: relationship is rejected; Null: relationship is pending
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function addRelationship(array $importer, array $contact, array $datarray, bool $sharing = false, string $note = '')
@ -3415,7 +3416,7 @@ class Contact
* @param array $contact User-specific contact (uid != 0) array
* @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a follower
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function removeFollower(array $contact, bool $delete = true)
@ -3449,7 +3450,7 @@ class Contact
*
* @param array $contact User-specific contact (uid != 0) array
* @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a sharer
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function removeSharer(array $contact, bool $delete = true)
{
@ -3512,7 +3513,7 @@ class Contact
*
* @param array $contact_ids Contact id list
* @return array
* @throws \Exception
* @throws Exception
*/
public static function pruneUnavailable(array $contact_ids): array
{
@ -3554,7 +3555,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLink(string $contact_url, string $url = ''): string
@ -3581,7 +3582,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLinkById(int $cid, string $url = ''): string
@ -3605,7 +3606,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLinkByContact(array $contact, string $url = ''): string
@ -3810,7 +3811,7 @@ class Contact
* @param array $condition
*
* @return bool
* @throws \Exception
* @throws Exception
*/
public static function exists(array $condition): bool
{