aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-04-23 11:58:15 +0200
committerGravatar GitHub <noreply@github.com> 2023-04-23 11:58:15 +0200
commit115724622fa32e1b7981e378e87ccfb770450cb1 (patch)
tree4d7072768076fd76f2f1877757f3e2e395ab2ded /app/Models
parent8abe53d879ef188a5c1cc394894ce211fcfa9f92 (diff)
PHPStan Level 7 for ten more files (#5327)
* PHPStan Level 7 for nine more files * Minor syntax * One more
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/CategoryDAO.php4
-rw-r--r--app/Models/Entry.php4
-rw-r--r--app/Models/EntryDAO.php12
-rw-r--r--app/Models/Feed.php4
-rw-r--r--app/Models/FeedDAO.php6
-rw-r--r--app/Models/ReadingMode.php14
-rw-r--r--app/Models/TagDAO.php8
-rw-r--r--app/Models/Themes.php6
-rw-r--r--app/Models/View.php4
9 files changed, 28 insertions, 34 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index 4855a43d9..e5301cb2c 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -214,8 +214,8 @@ SQL;
}
}
- /** @return iterable<array<string,string|int>> */
- public function selectAll(): iterable {
+ /** @return Traversable<array<string,string|int>> */
+ public function selectAll(): Traversable {
$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 b5a742535..accd13c27 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -220,8 +220,8 @@ HTML;
return $content;
}
- /** @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): iterable {
+ /** @return Traversable<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): Traversable {
$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 365ee67fa..19547ac31 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -696,8 +696,8 @@ SQL;
}
}
- /** @return iterable<array<string,string|int>> */
- public function selectAll(): iterable {
+ /** @return Traversable<array<string,string|int>> */
+ public function selectAll(): Traversable {
$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 '
@@ -1149,11 +1149,11 @@ SQL;
/**
* @param int $id category/feed/tag ID
- * @return iterable<FreshRSS_Entry>
+ * @return Traversable<FreshRSS_Entry>
*/
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): iterable {
+ ?FreshRSS_BooleanSearch $filters = null, int $date_min = 0): Traversable {
$stm = $this->listWhereRaw($type, $id, $state, $order, $limit, $firstId, $filters, $date_min);
if ($stm) {
while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
@@ -1164,9 +1164,9 @@ SQL;
/**
* @param array<string> $ids
- * @return iterable<FreshRSS_Entry>
+ * @return Traversable<FreshRSS_Entry>
*/
- public function listByIds(array $ids, string $order = 'DESC'): iterable {
+ public function listByIds(array $ids, string $order = 'DESC'): Traversable {
if (count($ids) < 1) {
return;
}
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index a877786b4..c0fce6e4a 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -480,8 +480,8 @@ class FreshRSS_Feed extends Minz_Model {
return $hasUniqueGuids ? $guids : $links;
}
- /** @return iterable<FreshRSS_Entry> */
- public function loadEntries(SimplePie $simplePie): iterable {
+ /** @return Traversable<FreshRSS_Entry> */
+ public function loadEntries(SimplePie $simplePie): Traversable {
$hasBadGuids = $this->attributes('hasBadGuids');
$items = $simplePie->get_items();
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index 42cb59063..a4d76fb62 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -286,8 +286,8 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
}
}
- /** @return iterable<array<string,string|int>> */
- public function selectAll(): iterable {
+ /** @return Traversable<array<string,string|int>> */
+ public function selectAll(): Traversable {
$sql = <<<'SQL'
SELECT id, url, kind, category, name, website, description, `lastUpdate`,
priority, `pathEntries`, `httpAuth`, error, ttl, attributes
@@ -321,7 +321,7 @@ SQL;
return $feed == false ? null : $feed;
}
- /** @return array<string>|false */
+ /** @return array<int>|false */
public function listFeedsIds() {
$sql = 'SELECT id FROM `_feed`';
$stm = $this->pdo->query($sql);
diff --git a/app/Models/ReadingMode.php b/app/Models/ReadingMode.php
index 6f2fc889c..30ab13aad 100644
--- a/app/Models/ReadingMode.php
+++ b/app/Models/ReadingMode.php
@@ -17,9 +17,7 @@ class FreshRSS_ReadingMode {
* @var string
*/
protected $title;
- /**
- * @var string[]
- */
+ /** @var array{'c':string,'a':string,'params':array<string,mixed>} */
protected $urlParams;
/**
* @var bool
@@ -28,7 +26,7 @@ class FreshRSS_ReadingMode {
/**
* ReadingMode constructor.
- * @param array<string> $urlParams
+ * @param array{'c':string,'a':string,'params':array<string,mixed>} $urlParams
*/
public function __construct(string $id, string $title, array $urlParams, bool $active) {
$this->id = $id;
@@ -60,16 +58,12 @@ class FreshRSS_ReadingMode {
return $this;
}
- /**
- * @return array<string>
- */
+ /** @return array{'c':string,'a':string,'params':array<string,mixed>} */
public function getUrlParams(): array {
return $this->urlParams;
}
- /**
- * @param array<string> $urlParams
- */
+ /** @param array{'c':string,'a':string,'params':array<string,mixed>} $urlParams */
public function setUrlParams(array $urlParams): FreshRSS_ReadingMode {
$this->urlParams = $urlParams;
return $this;
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index 9dc664607..c0d6e3a36 100644
--- a/app/Models/TagDAO.php
+++ b/app/Models/TagDAO.php
@@ -153,8 +153,8 @@ SQL;
}
}
- /** @return iterable<array{'id':int,'name':string,'attributes':string}> */
- public function selectAll(): iterable {
+ /** @return Traversable<array{'id':int,'name':string,'attributes':string}> */
+ public function selectAll(): Traversable {
$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 iterable<array{'id_tag':int,'id_entry':string}> */
- public function selectEntryTag(): iterable {
+ /** @return Traversable<array{'id_tag':int,'id_entry':string}> */
+ public function selectEntryTag(): Traversable {
$sql = 'SELECT id_tag, id_entry FROM `_entrytag`';
$stm = $this->pdo->query($sql);
while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
diff --git a/app/Models/Themes.php b/app/Models/Themes.php
index ce63b24b2..20d825e4b 100644
--- a/app/Models/Themes.php
+++ b/app/Models/Themes.php
@@ -11,7 +11,7 @@ class FreshRSS_Themes extends Minz_Model {
/** @return array<string> */
public static function getList(): array {
return array_values(array_diff(
- scandir(PUBLIC_PATH . self::$themesUrl),
+ scandir(PUBLIC_PATH . self::$themesUrl) ?: [],
array('..', '.')
));
}
@@ -37,7 +37,7 @@ class FreshRSS_Themes extends Minz_Model {
if (is_dir($theme_dir)) {
$json_filename = $theme_dir . '/metadata.json';
if (file_exists($json_filename)) {
- $content = file_get_contents($json_filename);
+ $content = file_get_contents($json_filename) ?: '';
$res = json_decode($content, true);
if ($res &&
!empty($res['name']) &&
@@ -75,7 +75,7 @@ class FreshRSS_Themes extends Minz_Model {
}
self::$themeIconsUrl = self::$themesUrl . $theme_id . '/icons/';
self::$themeIcons = is_dir(PUBLIC_PATH . self::$themeIconsUrl) ? array_fill_keys(array_diff(
- scandir(PUBLIC_PATH . self::$themeIconsUrl),
+ scandir(PUBLIC_PATH . self::$themeIconsUrl) ?: [],
array('..', '.')
), 1) : array();
return $infos;
diff --git a/app/Models/View.php b/app/Models/View.php
index 87302a4e1..c5415c58e 100644
--- a/app/Models/View.php
+++ b/app/Models/View.php
@@ -15,7 +15,7 @@ class FreshRSS_View extends Minz_View {
public $category;
/** @var string */
public $current_user;
- /** @var array<FreshRSS_Entry> */
+ /** @var iterable<FreshRSS_Entry> */
public $entries;
/** @var FreshRSS_Entry */
public $entry;
@@ -49,7 +49,7 @@ class FreshRSS_View extends Minz_View {
public $signalError;
// Manage users
- /** @var array<string,string|int|bool> */
+ /** @var array{'feed_count':int|false,'article_count':int|false,'database_size':int,'language':string,'mail_login':string,'enabled':bool,'is_admin':bool,'last_user_activity':string,'is_default':bool} */
public $details;
/** @var bool */
public $disable_aside;