From 1c5cf718599f698836fef3f8f88748757a7e85b5 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 6 Feb 2022 14:31:36 +0100 Subject: Fix Fever 32 bit ID issue + more PHP type hints (#4201) * Fix Fever 32 bit ID issue + more PHP type hints #fix https://github.com/FreshRSS/FreshRSS/issues/4200 Follow up and fix regression from https://github.com/FreshRSS/FreshRSS/pull/4110 * More PHP type hints with PHPStan * Fix pull problem * Avoid more nulls --- app/Models/Entry.php | 103 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 40 deletions(-) (limited to 'app/Models/Entry.php') diff --git a/app/Models/Entry.php b/app/Models/Entry.php index c4f69211b..3e0c3f37a 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -7,23 +7,46 @@ class FreshRSS_Entry extends Minz_Model { const STATE_FAVORITE = 4; const STATE_NOT_FAVORITE = 8; - private $id = 0; + /** + * @var string + */ + private $id = '0'; + + /** + * @var string + */ private $guid; + private $title; private $authors; private $content; private $link; private $date; private $date_added = 0; //In microseconds - private $hash = null; - private $is_read; //Nullable boolean + /** + * @var string + */ + private $hash = ''; + /** + * @var bool|null + */ + private $is_read; private $is_favorite; + + /** + * @var int + */ private $feedId; + + /** + * @var FreshRSS_Feed|null + */ private $feed; + private $tags; - public function __construct($feedId = '', $guid = '', $title = '', $authors = '', $content = '', - $link = '', $pubdate = 0, $is_read = false, $is_favorite = false, $tags = '') { + public function __construct(int $feedId = 0, string $guid = '', string $title = '', string $authors = '', string $content = '', + string $link = '', $pubdate = 0, bool $is_read = false, bool $is_favorite = false, string $tags = '') { $this->_title($title); $this->_authors($authors); $this->_content($content); @@ -36,31 +59,31 @@ class FreshRSS_Entry extends Minz_Model { $this->_guid($guid); } - public function id() { + public function id(): string { return $this->id; } - public function guid() { + public function guid(): string { return $this->guid; } - public function title() { + public function title(): string { return $this->title == '' ? $this->guid() : $this->title; } - public function author() { + public function author(): string { //Deprecated return $this->authors(true); } - public function authors($asString = false) { + public function authors(bool $asString = false) { if ($asString) { return $this->authors == null ? '' : ';' . implode('; ', $this->authors); } else { return $this->authors; } } - public function content() { + public function content(): string { return $this->content; } - public function enclosures($searchBodyImages = false) { + public function enclosures(bool $searchBodyImages = false): array { $results = []; try { $searchEnclosures = strpos($this->content, '