diff options
| author | 2025-06-15 01:17:20 +0200 | |
|---|---|---|
| committer | 2025-06-15 01:17:20 +0200 | |
| commit | 67c42b0e7c4250d7befe61e35994d8f6e439ca7a (patch) | |
| tree | 83a9a20d05a928fc9b1ee94803e05506437178a9 /app/Models/FeedDAO.php | |
| parent | f620f16e2b62cc12e8b2a155d8f764dd8bafefe8 (diff) | |
Remove several PHPStan ignore (#7665)
* Remove several PHPStan ignore
* One syntax error
* PDO returns int, not bool (MySQL and SQLite Boolean types are aliases for tinyint).
* A few missing type hints
* Revert strange PHPStan bug
Diffstat (limited to 'app/Models/FeedDAO.php')
| -rw-r--r-- | app/Models/FeedDAO.php | 30 |
1 files changed, 22 insertions, 8 deletions
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; } |
