aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-04-17 16:24:35 +0200
committerGravatar GitHub <noreply@github.com> 2023-04-17 16:24:35 +0200
commit62496339b6a43fcbb8267fb0f14ac2b165bf5826 (patch)
treea7ed5fe51af404af6939814e401c002252589f5c /app/Models
parent5185bcef13862ee86298cd38b83da145d03055b5 (diff)
More consistent use of iterable type (#5308)
For `yield`
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/CategoryDAO.php4
-rw-r--r--app/Models/Entry.php2
-rw-r--r--app/Models/EntryDAO.php8
-rw-r--r--app/Models/Feed.php6
-rw-r--r--app/Models/FeedDAO.php4
-rw-r--r--app/Models/TagDAO.php8
6 files changed, 15 insertions, 17 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index 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.php
index 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 attributes
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 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.php
index 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.php
index 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, attributes
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index 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)) {