diff options
| author | 2025-04-02 00:46:28 +0200 | |
|---|---|---|
| committer | 2025-04-02 00:46:28 +0200 | |
| commit | 78dfb44060921a15f820d5794efcf2898f4333c2 (patch) | |
| tree | 82547cf584bc055b6382fe472e40ff357456d54f /app/Models | |
| parent | ca2693441c531f96389c49c9240b4239f0006de5 (diff) | |
Pass phpstan-strict-rules 2.0.4 (#7488)
New check for Boolean in while conditions
Replace https://github.com/FreshRSS/FreshRSS/pull/7481
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/CategoryDAO.php | 2 | ||||
| -rw-r--r-- | app/Models/EntryDAO.php | 24 | ||||
| -rw-r--r-- | app/Models/FeedDAO.php | 2 | ||||
| -rw-r--r-- | app/Models/TagDAO.php | 4 |
4 files changed, 14 insertions, 18 deletions
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index ee0d02d6c..7dfb32076 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -226,7 +226,7 @@ SQL; $sql = 'SELECT id, name, kind, `lastUpdate`, error, attributes FROM `_category`'; $stm = $this->pdo->query($sql); if ($stm !== false) { - while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { + while (is_array($row = $stm->fetch(PDO::FETCH_ASSOC))) { /** @var array{id:int,name:string,kind:int,lastUpdate:int,error:int,attributes?:array<string,mixed>} $row */ yield $row; } diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index a234dce91..f6c327364 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -748,8 +748,8 @@ SQL; $sql .= ' ORDER BY id DESC LIMIT ' . $limit; } $stm = $this->pdo->query($sql); - if ($stm != false) { - while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { + if ($stm !== false) { + while (is_array($row = $stm->fetch(PDO::FETCH_ASSOC))) { /** @var array{id:string,guid:string,title:string,author:string,content:string,link:string,date:int,lastSeen:int, * hash:string,is_read:bool,is_favorite:bool,id_feed:int,tags:string,attributes:?string} $row */ yield $row; @@ -1394,12 +1394,10 @@ SQL; $stm = $this->listWhereRaw($type, $id, $state, $filters, id_min: $id_min, id_max: $id_max, sort: $sort, order: $order, continuation_id: $continuation_id, continuation_value: $continuation_value, limit: $limit, offset: $offset); if ($stm !== false) { - while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { - if (is_array($row)) { - /** @var array{'id':string,'id_feed':int,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int, - * 'hash':string,'is_read':int,'is_favorite':int,'tags':string,'attributes'?:?string} $row */ - yield FreshRSS_Entry::fromArray($row); - } + while (is_array($row = $stm->fetch(PDO::FETCH_ASSOC))) { + /** @var array{'id':string,'id_feed':int,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int, + * 'hash':string,'is_read':int,'is_favorite':int,'tags':string,'attributes'?:?string} $row */ + yield FreshRSS_Entry::fromArray($row); } } } @@ -1438,12 +1436,10 @@ SQL; if ($stm === false || !$stm->execute($ids)) { return; } - while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { - if (is_array($row)) { - /** @var array{'id':string,'id_feed':int,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int, - * 'hash':string,'is_read':int,'is_favorite':int,'tags':string,'attributes':?string} $row */ - yield FreshRSS_Entry::fromArray($row); - } + while (is_array($row = $stm->fetch(PDO::FETCH_ASSOC))) { + /** @var array{'id':string,'id_feed':int,'guid':string,'title':string,'author':string,'content':string,'link':string,'date':int, + * 'hash':string,'is_read':int,'is_favorite':int,'tags':string,'attributes':?string} $row */ + yield FreshRSS_Entry::fromArray($row); } } diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 6b5f7f96a..464d3fe06 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -305,7 +305,7 @@ FROM `_feed` SQL; $stm = $this->pdo->query($sql); if ($stm !== false) { - while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { + 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 */ yield $row; diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php index c2a653238..65e322d5a 100644 --- a/app/Models/TagDAO.php +++ b/app/Models/TagDAO.php @@ -125,7 +125,7 @@ SQL; Minz_Log::error('SQL error ' . __METHOD__ . json_encode($this->pdo->errorInfo())); return; } - while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { + while (is_array($row = $stm->fetch(PDO::FETCH_ASSOC))) { /** @var array{id:int,name:string,attributes?:array<string,mixed>} $row */ yield $row; } @@ -139,7 +139,7 @@ SQL; Minz_Log::error('SQL error ' . __METHOD__ . json_encode($this->pdo->errorInfo())); return; } - while ($row = $stm->fetch(PDO::FETCH_ASSOC)) { + 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 } |
