mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-08 00:04:27 +02:00
fix 7 PHPStan errors in factoriy and Model
This commit is contained in:
parent
4ebabd5997
commit
6b7dfa34e9
6 changed files with 24 additions and 16 deletions
|
@ -11,7 +11,7 @@ use Friendica\App\BaseURL;
|
||||||
use Friendica\BaseFactory;
|
use Friendica\BaseFactory;
|
||||||
use Friendica\Model\Attach;
|
use Friendica\Model\Attach;
|
||||||
use Friendica\Model\Photo;
|
use Friendica\Model\Photo;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
use Friendica\Util\Proxy;
|
use Friendica\Util\Proxy;
|
||||||
|
@ -32,7 +32,7 @@ class Attachment extends BaseFactory
|
||||||
/**
|
/**
|
||||||
* @param int $uriId Uri-ID of the attachments
|
* @param int $uriId Uri-ID of the attachments
|
||||||
* @return array
|
* @return array
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function createFromUriId(int $uriId): array
|
public function createFromUriId(int $uriId): array
|
||||||
{
|
{
|
||||||
|
@ -47,21 +47,30 @@ class Attachment extends BaseFactory
|
||||||
/**
|
/**
|
||||||
* @param int $id id of the media
|
* @param int $id id of the media
|
||||||
* @return \Friendica\Object\Api\Mastodon\Attachment
|
* @return \Friendica\Object\Api\Mastodon\Attachment
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function createFromId(int $id): \Friendica\Object\Api\Mastodon\Attachment
|
public function createFromId(int $id): \Friendica\Object\Api\Mastodon\Attachment
|
||||||
{
|
{
|
||||||
$attachment = Post\Media::getById($id);
|
$attachment = Post\Media::getById($id);
|
||||||
|
|
||||||
if (empty($attachment)) {
|
if (empty($attachment)) {
|
||||||
return [];
|
$attachment = [
|
||||||
|
'id' => '',
|
||||||
|
'description' => '',
|
||||||
|
'url' => '',
|
||||||
|
'mimetype' => '',
|
||||||
|
'blurhash' => '',
|
||||||
|
'type' => Post\Media::UNKNOWN,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createFromMediaArray($attachment);
|
return $this->createFromMediaArray($attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $attachment
|
* @param array $attachment
|
||||||
* @return \Friendica\Object\Api\Mastodon\Attachment
|
* @return \Friendica\Object\Api\Mastodon\Attachment
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private function createFromMediaArray(array $attachment): \Friendica\Object\Api\Mastodon\Attachment
|
private function createFromMediaArray(array $attachment): \Friendica\Object\Api\Mastodon\Attachment
|
||||||
{
|
{
|
||||||
|
@ -100,7 +109,7 @@ class Attachment extends BaseFactory
|
||||||
* @param int $id id of the photo
|
* @param int $id id of the photo
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function createFromPhoto(int $id): array
|
public function createFromPhoto(int $id): array
|
||||||
{
|
{
|
||||||
|
@ -136,7 +145,7 @@ class Attachment extends BaseFactory
|
||||||
* @param int $id id of the attachment
|
* @param int $id id of the attachment
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function createFromAttach(int $id): array
|
public function createFromAttach(int $id): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Status extends BaseFactory
|
||||||
private $mention;
|
private $mention;
|
||||||
/** @var Activities entity */
|
/** @var Activities entity */
|
||||||
private $activities;
|
private $activities;
|
||||||
/** @var Activities entity */
|
/** @var Attachment entity */
|
||||||
private $attachment;
|
private $attachment;
|
||||||
/** @var ContentItem */
|
/** @var ContentItem */
|
||||||
private $contentItem;
|
private $contentItem;
|
||||||
|
|
|
@ -28,6 +28,8 @@ class GServer extends \Friendica\BaseRepository
|
||||||
*/
|
*/
|
||||||
public function selectOneById(int $gsid): Entity\GServer
|
public function selectOneById(int $gsid): Entity\GServer
|
||||||
{
|
{
|
||||||
return $this->_selectOne(['id' => $gsid]);
|
$fields = $this->_selectFirstRowAsArray( ['id' => $gsid]);
|
||||||
|
|
||||||
|
return $this->factory->createFromTableRow($fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,8 @@ class User
|
||||||
* Insert a user-contact for a given contact array
|
* Insert a user-contact for a given contact array
|
||||||
*
|
*
|
||||||
* @param array $contact
|
* @param array $contact
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public static function insertForContactArray(array $contact)
|
public static function insertForContactArray(array $contact): bool
|
||||||
{
|
{
|
||||||
if (empty($contact['uid'])) {
|
if (empty($contact['uid'])) {
|
||||||
// We don't create entries for the public user - by now
|
// We don't create entries for the public user - by now
|
||||||
|
@ -339,7 +338,7 @@ class User
|
||||||
{
|
{
|
||||||
$pcid = Contact::getPublicContactId($cid, $uid);
|
$pcid = Contact::getPublicContactId($cid, $uid);
|
||||||
if (!$pcid) {
|
if (!$pcid) {
|
||||||
return false;
|
return self::FREQUENCY_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
$public_contact = DBA::selectFirst('user-contact', ['channel-frequency'], ['cid' => $pcid, 'uid' => $uid]);
|
$public_contact = DBA::selectFirst('user-contact', ['channel-frequency'], ['cid' => $pcid, 'uid' => $uid]);
|
||||||
|
|
|
@ -305,7 +305,7 @@ class Event
|
||||||
Hook::callAll("event_created", $event['id']);
|
Hook::callAll("event_created", $event['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $event['id'];
|
return (int) $event['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getItemArrayForId(int $event_id, array $item = []): array
|
public static function getItemArrayForId(int $event_id, array $item = []): array
|
||||||
|
|
|
@ -2200,8 +2200,6 @@ class GServer
|
||||||
* Converts input value to a boolean value
|
* Converts input value to a boolean value
|
||||||
*
|
*
|
||||||
* @param string|integer $val
|
* @param string|integer $val
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
*/
|
||||||
private static function toBoolean($val): bool
|
private static function toBoolean($val): bool
|
||||||
{
|
{
|
||||||
|
@ -2211,7 +2209,7 @@ class GServer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $val;
|
return (bool) $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue