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 $parentUriId
* @property-read int|null $id * @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 class Notify extends BaseEntity
{ {

View file

@ -30,7 +30,7 @@ class Status extends BaseDataTransferObject
protected $edited_at; protected $edited_at;
/** @var string|null */ /** @var string|null */
protected $in_reply_to_id = 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; protected $in_reply_to_status = null;
/** @var string|null */ /** @var string|null */
protected $in_reply_to_account_id = null; protected $in_reply_to_account_id = null;
@ -64,25 +64,25 @@ class Status extends BaseDataTransferObject
protected $pinned = false; protected $pinned = false;
/** @var string */ /** @var string */
protected $content; protected $content;
/** @var Status|null */ /** @var Status[]|null */
protected $reblog = 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; protected $quote = null;
/** @var Application */ /** @var Application */
protected $application = null; protected $application = null;
/** @var Account */ /** @var array */
protected $account; protected $account;
/** @var Attachment */ /** @var Attachment[] */
protected $media_attachments = []; protected $media_attachments = [];
/** @var Mention */ /** @var Mention[] */
protected $mentions = []; protected $mentions = [];
/** @var Tag */ /** @var Tag[] */
protected $tags = []; protected $tags = [];
/** @var Emoji[] */ /** @var Emoji[] */
protected $emojis = []; protected $emojis = [];
/** @var Card|null */ /** @var array|null */
protected $card = null; protected $card = null;
/** @var Poll|null */ /** @var array|null */
protected $poll = null; protected $poll = null;
/** @var FriendicaExtension */ /** @var FriendicaExtension */
protected $friendica; protected $friendica;

View file

@ -29,9 +29,9 @@ class DirectMessage extends BaseDataTransferObject
protected $sender_screen_name = null; protected $sender_screen_name = null;
/** @var string */ /** @var string */
protected $recipient_screen_name = null; protected $recipient_screen_name = null;
/** @var User */ /** @var array */
protected $sender; protected $sender;
/** @var User */ /** @var array */
protected $recipient; protected $recipient;
/** @var string|null */ /** @var string|null */
protected $title; protected $title;

View file

@ -31,7 +31,7 @@ class Media extends BaseDataTransferObject
protected $media_url; protected $media_url;
/** @var string */ /** @var string */
protected $media_url_https; protected $media_url_https;
/** @var string */ /** @var array<string, array<string, mixed>> */
protected $sizes; protected $sizes;
/** @var string */ /** @var string */
protected $type; protected $type;

View file

@ -7,7 +7,6 @@
namespace Friendica\Object\Api\Twitter; namespace Friendica\Object\Api\Twitter;
use Friendica\App\BaseURL;
use Friendica\BaseDataTransferObject; use Friendica\BaseDataTransferObject;
/** /**
@ -37,7 +36,7 @@ class Mention extends BaseDataTransferObject
*/ */
public function __construct(array $tag, array $contact, array $indices) 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->id_str = (string)($contact['id'] ?? 0);
$this->indices = $indices; $this->indices = $indices;
$this->name = $tag['name']; $this->name = $tag['name'];

View file

@ -45,11 +45,11 @@ class Status extends BaseDataTransferObject
protected $geo; protected $geo;
/** @var bool */ /** @var bool */
protected $favorited = false; protected $favorited = false;
/** @var User */ /** @var array */
protected $user; protected $user;
/** @var User */ /** @var array */
protected $friendica_author; protected $friendica_author;
/** @var User */ /** @var array */
protected $friendica_owner; protected $friendica_owner;
/** @var bool */ /** @var bool */
protected $friendica_private; protected $friendica_private;
@ -67,9 +67,9 @@ class Status extends BaseDataTransferObject
protected $friendica_html; protected $friendica_html;
/** @var int */ /** @var int */
protected $friendica_comments; protected $friendica_comments;
/** @var Status|null */ /** @var array|null */
protected $retweeted_status = null; protected $retweeted_status = null;
/** @var Status|null */ /** @var array|null */
protected $quoted_status = null; protected $quoted_status = null;
/** @var array */ /** @var array */
protected $attachments; protected $attachments;

View file

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

View file

@ -49,7 +49,7 @@ class Post
private $parent = null; private $parent = null;
/** /**
* @var Thread * @var Thread|null
*/ */
private $thread = null; private $thread = null;
private $redirect_url = null; private $redirect_url = null;
@ -816,7 +816,7 @@ class Post
* Get a child by its ID * Get a child by its ID
* *
* @param integer $id The child 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) public function getChild(int $id)
{ {

View file

@ -77,8 +77,7 @@ class Thread
break; break;
default: default:
DI::logger()->info('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').'); DI::logger()->info('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').');
return false; return;
break;
} }
$this->mode = $mode; $this->mode = $mode;
} }

View file

@ -8,31 +8,26 @@
namespace Friendica\Profile\ProfileField\Collection; namespace Friendica\Profile\ProfileField\Collection;
use Friendica\BaseCollection; use Friendica\BaseCollection;
use Friendica\Profile\ProfileField\Entity; use Friendica\Profile\ProfileField\Entity\ProfileField as ProfileFieldEntity;
class ProfileFields extends BaseCollection class ProfileFields extends BaseCollection
{ {
public function current(): Entity\ProfileField public function current(): ProfileFieldEntity
{ {
return parent::current(); return parent::current();
} }
/** public function map(callable $callback): ProfileFields
* @param callable $callback
* @return ProfileFields (as an extended form of BaseCollection)
*/
public function map(callable $callback): BaseCollection
{ {
return parent::map($callback); $class = get_class($this);
return new $class(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
} }
/** public function filter(?callable $callback = null, int $flag = 0): ProfileFields
* @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
{ {
return parent::filter($callback, $flag); $class = get_class($this);
return new $class(array_filter($this->getArrayCopy(), $callback, $flag));
} }
} }