From a80a5f48a16e7d232168a7aaa68e9a1804235ce1 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 18 Dec 2023 17:59:16 +0100 Subject: Pass PHPStan level 8 (#5946) * Pass PHPStan level 8 And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels * Revert wrong replace in comment * Fix PHPStan level 8 * Update PHPStan and other dev dependencies * Remove obsolete comment * noVariableVariables and towards bleedingEdge https://github.com/phpstan/phpstan-strict-rules https://phpstan.org/blog/what-is-bleeding-edge * More bleedingEdge * A bit more PHPStan level 9 * More PHPStan level 9 * Prepare for booleansInConditions Ignore int and null * Revert wrong line * More fixes * Fix keep_max_n_unread * Stricter attribute functions * Stricter callHooks and more PHPStan level 9 * More typing * A tiny more --- app/Models/FeedDAO.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'app/Models/FeedDAO.php') diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index ac844217a..895d2d333 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -118,7 +118,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { // Merge existing and import attributes $existingAttributes = $feed_search->attributes(); $importAttributes = $feed->attributes(); - $feed->_attributes('', array_replace_recursive($existingAttributes, $importAttributes)); + $feed->_attributes(array_replace_recursive($existingAttributes, $importAttributes)); // Update some values of the existing feed using the import $values = [ @@ -190,11 +190,12 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { } /** + * @param non-empty-string $key * @param string|array|bool|int|null $value * @return int|false */ public function updateFeedAttribute(FreshRSS_Feed $feed, string $key, $value) { - $feed->_attributes($key, $value); + $feed->_attribute($key, $value); return $this->updateFeed( $feed->id(), ['attributes' => $feed->attributes()] @@ -236,6 +237,9 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { if ($newCat === null) { $newCat = $catDAO->getDefault(); } + if ($newCat === null) { + return false; + } $sql = 'UPDATE `_feed` SET category=? WHERE category=?'; $stm = $this->pdo->prepare($sql); @@ -305,6 +309,8 @@ SQL; return; } while ($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; } } @@ -393,12 +399,12 @@ SQL; } } - /** @return array */ + /** @return array */ public function listTitles(int $id, int $limit = 0): array { $sql = 'SELECT title FROM `_entry` WHERE id_feed=:id_feed ORDER BY id DESC' . ($limit < 1 ? '' : ' LIMIT ' . intval($limit)); $res = $this->fetchColumn($sql, 0, [':id_feed' => $id]) ?? []; - /** @var array $res */ + /** @var array $res */ return $res; } @@ -609,7 +615,7 @@ SQL; $myFeed->_httpAuth(base64_decode($dao['httpAuth'] ?? '', true) ?: ''); $myFeed->_error($dao['error'] ?? 0); $myFeed->_ttl($dao['ttl'] ?? FreshRSS_Feed::TTL_DEFAULT); - $myFeed->_attributes('', $dao['attributes'] ?? ''); + $myFeed->_attributes($dao['attributes'] ?? ''); $myFeed->_nbNotRead($dao['cache_nbUnreads'] ?? -1); $myFeed->_nbEntries($dao['cache_nbEntries'] ?? -1); if (isset($dao['id'])) { -- cgit v1.2.3