A free, self-hostable news aggregator…
More consistent use of iterable type (#5308)
Alexandre Alapetite62496339b6a4
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.phpindex 64371c530..895161a90 100644--- a/app/Controllers/indexController.php+++ b/app/Controllers/indexController.php@@ -246,7 +246,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {* This method returns a list of entries based on the Context object.* @return iterable<FreshRSS_Entry>*/- public static function listEntriesByContext() {+ public static function listEntriesByContext(): iterable {$entryDAO = FreshRSS_Factory::createEntryDao();$get = FreshRSS_Context::currentGet(true);diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.phpindex 29593ce5f..4855a43d9 100644--- a/app/Models/CategoryDAO.php+++ b/app/Models/CategoryDAO.php@@ -214,8 +214,8 @@ SQL;}}- /** @return iterator<array<string,string|int>> */- public function selectAll() {+ /** @return iterable<array<string,string|int>> */+ public function selectAll(): iterable {$sql = 'SELECT id, name, kind, `lastUpdate`, error, attributes FROM `_category`';$stm = $this->pdo->query($sql);if ($stm != false) {diff --git a/app/Models/Entry.php b/app/Models/Entry.phpindex 20f17d1c7..b5a742535 100644--- a/app/Models/Entry.php+++ b/app/Models/Entry.php@@ -221,7 +221,7 @@ HTML;}/** @return iterable<array{'url':string,'type'?:string,'medium'?:string,'length'?:int,'title'?:string,'description'?:string,'credit'?:string,'height'?:int,'width'?:int,'thumbnails'?:array<string>}> */- public function enclosures(bool $searchBodyImages = false) {+ public function enclosures(bool $searchBodyImages = false): iterable {$attributeEnclosures = $this->attributes('enclosures');if (is_array($attributeEnclosures)) {// FreshRSS 1.20.1+: The enclosures are saved as attributesdiff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.phpindex 1661bfd13..ab71fb0c3 100644--- a/app/Models/EntryDAO.php+++ b/app/Models/EntryDAO.php@@ -696,8 +696,8 @@ SQL;}}- /** @return iterator<array<string,string|int>> */- public function selectAll() {+ /** @return iterable<array<string,string|int>> */+ public function selectAll(): iterable {$sql = 'SELECT id, guid, title, author, '. (static::isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content'). ', link, date, `lastSeen`, ' . static::sqlHexEncode('hash') . ' AS hash, is_read, is_favorite, id_feed, tags, attributes '@@ -1153,7 +1153,7 @@ SQL;*/public function listWhere(string $type = 'a', int $id = 0, int $state = FreshRSS_Entry::STATE_ALL,string $order = 'DESC', int $limit = 1, string $firstId = '',- ?FreshRSS_BooleanSearch $filters = null, int $date_min = 0) {+ ?FreshRSS_BooleanSearch $filters = null, int $date_min = 0): iterable {$stm = $this->listWhereRaw($type, $id, $state, $order, $limit, $firstId, $filters, $date_min);if ($stm) {while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {@@ -1166,7 +1166,7 @@ SQL;* @param array<string> $ids* @return iterable<FreshRSS_Entry>*/- public function listByIds(array $ids, string $order = 'DESC') {+ public function listByIds(array $ids, string $order = 'DESC'): iterable {if (count($ids) < 1) {return;}diff --git a/app/Models/Feed.php b/app/Models/Feed.phpindex ecf875723..0d7c35739 100644--- a/app/Models/Feed.php+++ b/app/Models/Feed.php@@ -478,10 +478,8 @@ class FreshRSS_Feed extends Minz_Model {return $guids;}- /**- * @return iterable<FreshRSS_Entry>- */- public function loadEntries(SimplePie $simplePie) {+ /** @return iterable<FreshRSS_Entry> */+ public function loadEntries(SimplePie $simplePie): iterable {$hasBadGuids = $this->attributes('hasBadGuids');$items = $simplePie->get_items();diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.phpindex 837fef7f1..f4a75a73a 100644--- a/app/Models/FeedDAO.php+++ b/app/Models/FeedDAO.php@@ -286,8 +286,8 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {}}- /** @return iterator<array<string,string|int>> */- public function selectAll() {+ /** @return iterable<array<string,string|int>> */+ public function selectAll(): iterable {$sql = <<<'SQL'SELECT id, url, kind, category, name, website, description, `lastUpdate`,priority, `pathEntries`, `httpAuth`, error, ttl, attributesdiff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.phpindex 0f491e706..9dc664607 100644--- a/app/Models/TagDAO.php+++ b/app/Models/TagDAO.php@@ -153,8 +153,8 @@ SQL;}}- /** @return iterator<array{'id':int,'name':string,'attributes':string}> */- public function selectAll() {+ /** @return iterable<array{'id':int,'name':string,'attributes':string}> */+ public function selectAll(): iterable {$sql = 'SELECT id, name, attributes FROM `_tag`';$stm = $this->pdo->query($sql);while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {@@ -162,8 +162,8 @@ SQL;}}- /** @return iterator<array{'id_tag':int,'id_entry':string}> */- public function selectEntryTag() {+ /** @return iterable<array{'id_tag':int,'id_entry':string}> */+ public function selectEntryTag(): iterable {$sql = 'SELECT id_tag, id_entry FROM `_entrytag`';$stm = $this->pdo->query($sql);while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {