aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Category.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-02-06 14:31:36 +0100
committerGravatar GitHub <noreply@github.com> 2022-02-06 14:31:36 +0100
commit1c5cf718599f698836fef3f8f88748757a7e85b5 (patch)
tree2760e8a90bb653cb4000a4f236b1bfec4508e948 /app/Models/Category.php
parentfe880d1a98d8224682036e44520bb92b2ed417aa (diff)
Fix Fever 32 bit ID issue + more PHP type hints (#4201)
* Fix Fever 32 bit ID issue + more PHP type hints #fix https://github.com/FreshRSS/FreshRSS/issues/4200 Follow up and fix regression from https://github.com/FreshRSS/FreshRSS/pull/4110 * More PHP type hints with PHPStan * Fix pull problem * Avoid more nulls
Diffstat (limited to 'app/Models/Category.php')
-rw-r--r--app/Models/Category.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 499f95d97..d2968828a 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -1,6 +1,9 @@
<?php
class FreshRSS_Category extends Minz_Model {
+ /**
+ * @var int
+ */
private $id = 0;
private $name;
private $nbFeed = -1;
@@ -10,7 +13,7 @@ class FreshRSS_Category extends Minz_Model {
private $isDefault = false;
private $attributes = [];
- public function __construct($name = '', $feeds = null) {
+ public function __construct(string $name = '', $feeds = null) {
$this->_name($name);
if (isset($feeds)) {
$this->_feeds($feeds);
@@ -24,16 +27,16 @@ class FreshRSS_Category extends Minz_Model {
}
}
- public function id() {
+ public function id(): int {
return $this->id;
}
- public function name() {
+ public function name(): string {
return $this->name;
}
- public function isDefault() {
+ public function isDefault(): bool {
return $this->isDefault;
}
- public function nbFeed() {
+ public function nbFeed(): int {
if ($this->nbFeed < 0) {
$catDAO = FreshRSS_Factory::createCategoryDao();
$this->nbFeed = $catDAO->countFeed($this->id());
@@ -41,7 +44,7 @@ class FreshRSS_Category extends Minz_Model {
return $this->nbFeed;
}
- public function nbNotRead() {
+ public function nbNotRead(): int {
if ($this->nbNotRead < 0) {
$catDAO = FreshRSS_Factory::createCategoryDao();
$this->nbNotRead = $catDAO->countNotRead($this->id());
@@ -49,7 +52,7 @@ class FreshRSS_Category extends Minz_Model {
return $this->nbNotRead;
}
- public function feeds() {
+ public function feeds(): array {
if ($this->feeds === null) {
$feedDAO = FreshRSS_Factory::createFeedDao();
$this->feeds = $feedDAO->listByCategory($this->id());