aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Feed.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-09-06 09:06:46 +0200
committerGravatar GitHub <noreply@github.com> 2024-09-06 09:06:46 +0200
commita81656c3ed5b8fe0f31794a4fbe0d1a907fca8e8 (patch)
tree8bf49bd876aaebc985a9fb1214863190a799cbee /app/Models/Feed.php
parent8f7c3473a76809efc88814253722c76f0cc8eb04 (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/Feed.php')
-rw-r--r--app/Models/Feed.php23
1 files changed, 8 insertions, 15 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 36cc58cfd..6e468e33f 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -116,10 +116,7 @@ class FreshRSS_Feed extends Minz_Model {
}
public function categoryId(): int {
- if ($this->category !== null) {
- return $this->category->id() ?: $this->categoryId;
- }
- return $this->categoryId;
+ return $this->category?->id() ?: $this->categoryId;
}
/**
@@ -155,7 +152,7 @@ class FreshRSS_Feed extends Minz_Model {
* @phpstan-return ($raw is true ? string : array{'username':string,'password':string})
* @return array{'username':string,'password':string}|string
*/
- public function httpAuth(bool $raw = true) {
+ public function httpAuth(bool $raw = true): array|string {
if ($raw) {
return $this->httpAuth;
} else {
@@ -816,7 +813,7 @@ class FreshRSS_Feed extends Minz_Model {
/**
* @return int|null The max number of unread articles to keep, or null if disabled.
*/
- public function keepMaxUnread() {
+ public function keepMaxUnread(): ?int {
$keepMaxUnread = $this->attributeInt('keep_max_n_unread');
if ($keepMaxUnread === null) {
$keepMaxUnread = FreshRSS_Context::userConf()->mark_when['max_n_unread'];
@@ -827,7 +824,7 @@ class FreshRSS_Feed extends Minz_Model {
/**
* @return int|false The number of articles marked as read, of false if error
*/
- public function markAsReadMaxUnread() {
+ public function markAsReadMaxUnread(): int|false {
$keepMaxUnread = $this->keepMaxUnread();
if ($keepMaxUnread === null) {
return false;
@@ -842,7 +839,7 @@ class FreshRSS_Feed extends Minz_Model {
* Remember to call `updateCachedValues($id_feed)` or `updateCachedValues()` just after.
* @return int|false the number of lines affected, or false if not applicable
*/
- public function markAsReadUponGone(bool $upstreamIsEmpty, int $minLastSeen = 0) {
+ public function markAsReadUponGone(bool $upstreamIsEmpty, int $minLastSeen = 0): int|false {
$readUponGone = $this->attributeBoolean('read_upon_gone');
if ($readUponGone === null) {
$readUponGone = FreshRSS_Context::userConf()->mark_when['gone'];
@@ -868,9 +865,8 @@ class FreshRSS_Feed extends Minz_Model {
/**
* Remember to call `updateCachedValues($id_feed)` or `updateCachedValues()` just after
- * @return int|false
*/
- public function cleanOldEntries() {
+ public function cleanOldEntries(): int|false {
/** @var array<string,bool|int|string>|null $archiving */
$archiving = $this->attributeArray('archiving');
if ($archiving === null) {
@@ -926,7 +922,7 @@ class FreshRSS_Feed extends Minz_Model {
}
/** @return int|false */
- public function cacheModifiedTime() {
+ public function cacheModifiedTime(): int|false {
$filename = $this->cacheFilename();
clearstatcache(true, $filename);
return @filemtime($filename);
@@ -977,10 +973,7 @@ class FreshRSS_Feed extends Minz_Model {
return false;
}
- /**
- * @return string|false
- */
- public function pubSubHubbubPrepare() {
+ public function pubSubHubbubPrepare(): string|false {
$key = '';
if (Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) &&
$this->hubUrl && $this->selfUrl && @is_dir(PSHB_PATH)) {