aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Models/CategoryDAO.php22
-rw-r--r--app/Models/FeedDAO.php30
-rw-r--r--app/Models/TagDAO.php6
3 files changed, 36 insertions, 22 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index 7dfb32076..3a714afed 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -244,16 +244,16 @@ SQL;
public function searchById(int $id): ?FreshRSS_Category {
$sql = 'SELECT * FROM `_category` WHERE id=:id';
$res = $this->fetchAssoc($sql, ['id' => $id]) ?? [];
- /** @var array<array{name:string,id:int,kind:int,lastUpdate?:int,error:int|bool,attributes?:string}> $res */
- $categories = self::daoToCategories($res); // @phpstan-ignore varTag.type
+ /** @var list<array{name:string,id:int,kind:int,lastUpdate?:int,error:int,attributes?:string}> $res */
+ $categories = self::daoToCategories($res);
return reset($categories) ?: null;
}
public function searchByName(string $name): ?FreshRSS_Category {
$sql = 'SELECT * FROM `_category` WHERE name=:name';
$res = $this->fetchAssoc($sql, ['name' => $name]) ?? [];
- /** @var array<array{name:string,id:int,kind:int,lastUpdate:int,error:int|bool,attributes:string}> $res */
- $categories = self::daoToCategories($res); // @phpstan-ignore varTag.type
+ /** @var list<array{name:string,id:int,kind:int,lastUpdate:int,error:int,attributes:string}> $res */
+ $categories = self::daoToCategories($res);
return reset($categories) ?: null;
}
@@ -290,8 +290,8 @@ SQL;
$stm = $this->pdo->prepare($sql);
$values = [ ':priority' => FreshRSS_Feed::PRIORITY_CATEGORY ];
if ($stm !== false && $stm->execute($values) && ($res = $stm->fetchAll(PDO::FETCH_ASSOC)) !== false) {
- /** @var list<array{c_name:string,c_id:int,c_kind:int,c_last_update:int,c_error:int|bool,c_attributes?:string,
- * id?:int,name?:string,url?:string,kind?:int,category?:int,website?:string,priority?:int,error?:int|bool,attributes?:string,cache_nbEntries?:int,cache_nbUnreads?:int,ttl?:int}> $res */
+ /** @var list<array{c_name:string,c_id:int,c_kind:int,c_last_update:int,c_error:int,c_attributes?:string,
+ * id?:int,name?:string,url?:string,kind?:int,category?:int,website?:string,priority?:int,error?:int,attributes?:string,cache_nbEntries?:int,cache_nbUnreads?:int,ttl?:int}> $res */
return self::daoToCategoriesPrepopulated($res);
} else {
$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
@@ -304,8 +304,8 @@ SQL;
}
} else {
$res = $this->fetchAssoc('SELECT * FROM `_category` ORDER BY name') ?? [];
- /** @var list<array{name:string,id:int,kind:int,lastUpdate?:int,error?:int|bool,attributes?:string}> $res */
- return empty($res) ? [] : self::daoToCategories($res); // @phpstan-ignore varTag.type
+ /** @var list<array{name:string,id:int,kind:int,lastUpdate?:int,error?:int,attributes?:string}> $res */
+ return empty($res) ? [] : self::daoToCategories($res);
}
}
@@ -319,7 +319,7 @@ SQL;
$stm->bindValue(':lu', time() - $defaultCacheDuration, PDO::PARAM_INT) &&
$stm->execute()) {
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
- /** @var list<array{name:string,id:int,kind:int,lastUpdate:int,error?:int|bool,attributes?:string}> $res */
+ /** @var list<array{name:string,id:int,kind:int,lastUpdate:int,error?:int,attributes?:string}> $res */
return self::daoToCategories($res);
} else {
$info = $stm !== false ? $stm->errorInfo() : $this->pdo->errorInfo();
@@ -335,8 +335,8 @@ SQL;
public function getDefault(): ?FreshRSS_Category {
$sql = 'SELECT * FROM `_category` WHERE id=:id';
$res = $this->fetchAssoc($sql, [':id' => self::DEFAULTCATEGORYID]) ?? [];
- /** @var array<array{name:string,id:int,kind:int,lastUpdate?:int,error?:int|bool,attributes?:string}> $res */
- $categories = self::daoToCategories($res); // @phpstan-ignore varTag.type
+ /** @var list<array{name:string,id:int,kind:int,lastUpdate?:int,error?:int,attributes?:string}> $res */
+ $categories = self::daoToCategories($res);
if (isset($categories[self::DEFAULTCATEGORYID])) {
return $categories[self::DEFAULTCATEGORYID];
} else {
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index 464d3fe06..e6e5d2940 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -307,7 +307,7 @@ SQL;
if ($stm !== false) {
while (is_array($row = $stm->fetch(PDO::FETCH_ASSOC))) {
/** @var array{id:int,url:string,kind:int,category:int,name:string,website:string,description:string,lastUpdate:int,priority?:int,
- * pathEntries?:string,httpAuth:string,error:int|bool,ttl?:int,attributes?:string} $row */
+ * pathEntries?:string,httpAuth:string,error:int,ttl?:int,attributes?:string} $row */
yield $row;
}
} else {
@@ -327,14 +327,21 @@ SQL;
if (!is_array($res)) {
return null;
}
- $feeds = self::daoToFeeds($res); // @phpstan-ignore argument.type
+ /** @var list<array{id:int,url:string,kind:int,category:int,name:string,website:string,description:string,lastUpdate:int,priority:int,
+ * pathEntries:string,httpAuth:string,error:int,ttl:int,attributes?:string,cache_nbUnreads:int,cache_nbEntries:int}> $res */
+ $feeds = self::daoToFeeds($res);
return $feeds[$id] ?? null;
}
public function searchByUrl(string $url): ?FreshRSS_Feed {
$sql = 'SELECT * FROM `_feed` WHERE url=:url';
$res = $this->fetchAssoc($sql, [':url' => $url]);
- return empty($res[0]) ? null : (current(self::daoToFeeds($res)) ?: null); // @phpstan-ignore argument.type
+ if (!is_array($res)) {
+ return null;
+ }
+ /** @var list<array{id:int,url:string,kind:int,category:int,name:string,website:string,description:string,lastUpdate:int,priority:int,
+ * pathEntries:string,httpAuth:string,error:int,ttl:int,attributes?:string,cache_nbUnreads:int,cache_nbEntries:int}> $res */
+ return empty($res[0]) ? null : (current(self::daoToFeeds($res)) ?: null);
}
/** @return list<int> */
@@ -349,7 +356,12 @@ SQL;
public function listFeeds(): array {
$sql = 'SELECT * FROM `_feed` ORDER BY name';
$res = $this->fetchAssoc($sql);
- return $res == null ? [] : self::daoToFeeds($res); // @phpstan-ignore argument.type
+ if (!is_array($res)) {
+ return [];
+ }
+ /** @var list<array{id:int,url:string,kind:int,category:int,name:string,website:string,description:string,lastUpdate:int,priority:int,
+ * pathEntries:string,httpAuth:string,error:int,ttl:int,attributes?:string,cache_nbUnreads:int,cache_nbEntries:int}> $res */
+ return self::daoToFeeds($res);
}
/** @return array<string,string> */
@@ -361,8 +373,8 @@ SQL;
$sql .= 'WHERE id_feed=' . intval($id_feed);
}
$res = $this->fetchAssoc($sql);
- /** @var list<array{'id_feed':int,'newest_item_us':string}>|null $res */
- if ($res == null) {
+ /** @var list<array{id_feed:int,newest_item_us:string}>|null $res */
+ if ($res === null) {
return [];
}
$newestItemUsec = [];
@@ -386,7 +398,7 @@ SQL;
$stm = $this->pdo->query($sql);
if ($stm !== false && ($res = $stm->fetchAll(PDO::FETCH_ASSOC)) !== false) {
/** @var list<array{id?:int,url?:string,kind?:int,category?:int,name?:string,website?:string,description?:string,lastUpdate?:int,priority?:int,
- * pathEntries?:string,httpAuth?:string,error?:int|bool,ttl?:int,attributes?:string,cache_nbUnreads?:int,cache_nbEntries?:int}> $res */
+ * pathEntries?:string,httpAuth?:string,error?:int,ttl?:int,attributes?:string,cache_nbUnreads?:int,cache_nbEntries?:int}> $res */
return self::daoToFeeds($res);
} else {
$info = $this->pdo->errorInfo();
@@ -425,7 +437,9 @@ SQL;
if (!is_array($res)) {
return [];
}
- $feeds = self::daoToFeeds($res); // @phpstan-ignore argument.type
+ /** @var list<array{id:int,url:string,kind:int,category:int,name:string,website:string,description:string,lastUpdate:int,priority:int,
+ * pathEntries:string,httpAuth:string,error:int,ttl:int,attributes?:string,cache_nbUnreads:int,cache_nbEntries:int}> $res */
+ $feeds = self::daoToFeeds($res);
uasort($feeds, static fn(FreshRSS_Feed $a, FreshRSS_Feed $b) => strnatcasecmp($a->name(), $b->name()));
return $feeds;
}
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index a253f37c1..05b01f94a 100644
--- a/app/Models/TagDAO.php
+++ b/app/Models/TagDAO.php
@@ -140,8 +140,8 @@ SQL;
return;
}
while (is_array($row = $stm->fetch(PDO::FETCH_ASSOC))) {
- /** @var array{id_tag:int,id_entry:int|numeric-string}> $row */
- yield $row; // @phpstan-ignore generator.valueType
+ /** @var array{id_tag:int,id_entry:int|numeric-string} $row */
+ yield $row;
}
}
@@ -336,7 +336,7 @@ SQL;
if ($stm !== false && $stm->execute($values) && ($lines = $stm->fetchAll(PDO::FETCH_ASSOC)) !== false) {
$result = [];
foreach ($lines as $line) {
- /** @var array{id:int,name:string,checked:bool|int} $line */
+ /** @var array{id:int,name:string,checked:int} $line */
$result[] = [
'id' => (int)($line['id']),
'name' => $line['name'],