diff options
| author | 2023-11-18 23:21:20 +0100 | |
|---|---|---|
| committer | 2023-11-18 23:21:20 +0100 | |
| commit | b65ea979010eb488cc9c1fb1d0f082e868c191d5 (patch) | |
| tree | be2c1b06aa5fcea8d33d43ba76acbfff3e4f0f0e /app/Models/StatsDAO.php | |
| parent | 445e49db15ea7ae41dc55efea2d67903557f9182 (diff) | |
Fix PHP 7 compatibility strict_types (#5893)
* Fix PHP 7 compatibility
https://github.com/FreshRSS/FreshRSS/discussions/5892
* Multiple PHP 7 fixes
* PHPStan
Diffstat (limited to 'app/Models/StatsDAO.php')
| -rw-r--r-- | app/Models/StatsDAO.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index 2cef6c183..0e0bad623 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -49,8 +49,13 @@ WHERE e.id_feed = f.id {$filter} SQL; $res = $this->fetchAssoc($sql); - /** @var array<array{'total':int,'count_unreads':int,'count_reads':int,'count_favorites':int}>|null $res */ - return $res[0] ?? false; + if (!empty($res[0])) { + $dao = $res[0]; + /** @var array<array{'total':int,'count_unreads':int,'count_reads':int,'count_favorites':int}> $res */ + FreshRSS_DatabaseDAO::pdoInt($dao, ['total', 'count_unreads', 'count_reads', 'count_favorites']); + return $dao; + } + return false; } /** @@ -286,7 +291,13 @@ LIMIT 10 SQL; $res = $this->fetchAssoc($sql); /** @var array<array{'id':int,'name':string,'category':string,'count':int}>|null $res */ - return $res == null ? [] : $res; + if (is_array($res)) { + foreach ($res as &$dao) { + FreshRSS_DatabaseDAO::pdoInt($dao, ['id', 'count']); + } + return $res; + } + return []; } /** @@ -306,7 +317,13 @@ ORDER BY name SQL; $res = $this->fetchAssoc($sql); /** @var array<array{'id':int,'name':string,'last_date':int,'nb_articles':int}>|null $res */ - return $res == null ? [] : $res; + if (is_array($res)) { + foreach ($res as &$dao) { + FreshRSS_DatabaseDAO::pdoInt($dao, ['id', 'last_date', 'nb_articles']); + } + return $res; + } + return []; } /** |
