Fix 27 PHPStan errors

This commit is contained in:
Art4 2025-02-25 13:51:13 +00:00
parent c1653877fb
commit cea8cf1f6c
10 changed files with 34 additions and 40 deletions

View 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
{

View 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;

View 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;

View 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;

View 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'];

View 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;

View file

@ -29,7 +29,7 @@ class ParsedLogLine
/** @var string */
public $message = null;
/** @var string */
/** @var string|null */
public $data = null;
/** @var string */

View 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)
{

View 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;
}

View 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));
}
}