diff options
| author | 2024-09-06 09:06:46 +0200 | |
|---|---|---|
| committer | 2024-09-06 09:06:46 +0200 | |
| commit | a81656c3ed5b8fe0f31794a4fbe0d1a907fca8e8 (patch) | |
| tree | 8bf49bd876aaebc985a9fb1214863190a799cbee /app/Models/EntryDAO.php | |
| parent | 8f7c3473a76809efc88814253722c76f0cc8eb04 (diff) | |
Upgrade to PHP 8.1 (#6711)
* Upgrade to PHP 8.1
As discussed in https://github.com/FreshRSS/FreshRSS/discussions/5474
https://www.php.net/releases/8.0/en.php
https://www.php.net/releases/8.1/en.php
Upgrade to available native type declarations
https://php.net/language.types.declarations
Upgrade to https://phpunit.de/announcements/phpunit-10.html which requires PHP 8.1+ (good timing, as version 9 was not maintained anymore)
Upgrade `:oldest` Docker dev image to oldest Alpine version supporting PHP 8.1: Alpine 3.16, which includes PHP 8.1.22.
* Include 6736
https://github.com/FreshRSS/FreshRSS/pull/6736
Diffstat (limited to 'app/Models/EntryDAO.php')
| -rw-r--r-- | app/Models/EntryDAO.php | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index a90b98a60..175df15c3 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -291,9 +291,8 @@ SQL; * there is an other way to do that. * * @param numeric-string|array<numeric-string> $ids - * @return int|false */ - public function markFavorite($ids, bool $is_favorite = true) { + public function markFavorite($ids, bool $is_favorite = true): int|false { if (!is_array($ids)) { $ids = [$ids]; } @@ -369,10 +368,9 @@ SQL; * Then the cache is updated. * * @param numeric-string|array<numeric-string> $ids - * @param bool $is_read * @return int|false affected rows */ - public function markRead($ids, bool $is_read = true) { + public function markRead(array|string $ids, bool $is_read = true): int|false { if (is_array($ids)) { //Many IDs at once if (count($ids) < 6) { //Speed heuristics $affected = 0; @@ -438,7 +436,7 @@ SQL; * @param numeric-string $idMax fail safe article ID * @return int|false affected rows */ - public function markReadEntries(string $idMax = '0', bool $onlyFavorites = false, ?int $priorityMin = null, ?int $prioritMax = null, + public function markReadEntries(string $idMax = '0', bool $onlyFavorites = false, ?int $priorityMin = null, ?int $priorityMax = null, ?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true) { FreshRSS_UserDAO::touch(); if ($idMax == '0') { @@ -451,15 +449,15 @@ SQL; if ($onlyFavorites) { $sql .= ' AND is_favorite=1'; } - if ($priorityMin !== null || $prioritMax !== null) { + if ($priorityMin !== null || $priorityMax !== null) { $sql .= ' AND id_feed IN (SELECT f.id FROM `_feed` f WHERE 1=1'; if ($priorityMin !== null) { $sql .= ' AND f.priority >= ?'; $values[] = $priorityMin; } - if ($prioritMax !== null) { + if ($priorityMax !== null) { $sql .= ' AND f.priority < ?'; - $values[] = $prioritMax; + $values[] = $priorityMax; } $sql .= ')'; } @@ -490,7 +488,7 @@ SQL; * @param numeric-string $idMax fail safe article ID * @return int|false affected rows */ - public function markReadCat(int $id, string $idMax = '0', ?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true) { + public function markReadCat(int $id, string $idMax = '0', ?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true): int|false { FreshRSS_UserDAO::touch(); if ($idMax == '0') { $idMax = time() . '000000'; @@ -531,7 +529,7 @@ SQL; * @param numeric-string $idMax fail safe article ID * @return int|false affected rows */ - public function markReadFeed(int $id_feed, string $idMax = '0', ?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true) { + public function markReadFeed(int $id_feed, string $idMax = '0', ?FreshRSS_BooleanSearch $filters = null, int $state = 0, bool $is_read = true): int|false { FreshRSS_UserDAO::touch(); if ($idMax == '0') { $idMax = time() . '000000'; @@ -623,9 +621,8 @@ SQL; /** * Remember to call updateCachedValues($id_feed) or updateCachedValues() just after. * @param array<string,bool|int|string> $options - * @return int|false */ - public function cleanOldEntries(int $id_feed, array $options = []) { + public function cleanOldEntries(int $id_feed, array $options = []): int|false { $sql = 'DELETE FROM `_entry` WHERE id_feed = :id_feed1'; //No alias for MySQL / MariaDB $params = []; $params[':id_feed1'] = $id_feed; @@ -1121,12 +1118,11 @@ SQL; * @phpstan-param 'a'|'A'|'s'|'S'|'i'|'c'|'f'|'t'|'T'|'ST' $type * @param 'ASC'|'DESC' $order * @param int $id category/feed/tag ID - * @return PDOStatement|false * @throws FreshRSS_EntriesGetter_Exception */ private function listWhereRaw(string $type = 'a', int $id = 0, int $state = FreshRSS_Entry::STATE_ALL, string $order = 'DESC', int $limit = 1, int $offset = 0, string $firstId = '', ?FreshRSS_BooleanSearch $filters = null, - int $date_min = 0) { + int $date_min = 0): PDOStatement|false { [$values, $sql] = $this->sqlListWhere($type, $id, $state, $order, $limit, $offset, $firstId, $filters, $date_min); if ($order !== 'DESC' && $order !== 'ASC') { @@ -1244,7 +1240,7 @@ SQL; * @param array<string> $guids * @return array<string>|false */ - public function listHashForFeedGuids(int $id_feed, array $guids) { + public function listHashForFeedGuids(int $id_feed, array $guids): array|false { $result = []; if (count($guids) < 1) { return $result; @@ -1283,7 +1279,7 @@ SQL; * @param array<string> $guids * @return int|false The number of affected entries, or false if error */ - public function updateLastSeen(int $id_feed, array $guids, int $mtime = 0) { + public function updateLastSeen(int $id_feed, array $guids, int $mtime = 0): int|false { if (count($guids) < 1) { return 0; } elseif (count($guids) > FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER) { @@ -1321,7 +1317,7 @@ SQL; * To be performed just before {@see FreshRSS_FeedDAO::updateLastUpdate()} * @return int|false The number of affected entries, or false in case of error */ - public function updateLastSeenUnchanged(int $id_feed, int $mtime = 0) { + public function updateLastSeenUnchanged(int $id_feed, int $mtime = 0): int|false { $sql = <<<'SQL' UPDATE `_entry` SET `lastSeen` = :mtime WHERE id_feed = :id_feed1 AND `lastSeen` = ( |
