From b65ea979010eb488cc9c1fb1d0f082e868c191d5 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 18 Nov 2023 23:21:20 +0100 Subject: Fix PHP 7 compatibility strict_types (#5893) * Fix PHP 7 compatibility https://github.com/FreshRSS/FreshRSS/discussions/5892 * Multiple PHP 7 fixes * PHPStan --- app/Models/StatsDAO.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'app/Models/StatsDAO.php') 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|null $res */ - return $res[0] ?? false; + if (!empty($res[0])) { + $dao = $res[0]; + /** @var array $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|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|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 []; } /** -- cgit v1.2.3