aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Models/Category.php13
-rw-r--r--tests/phpstan-next.txt1
2 files changed, 10 insertions, 4 deletions
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 4e28b1741..c9c919e4a 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -36,7 +36,7 @@ class FreshRSS_Category extends Minz_Model {
/**
* @param array<FreshRSS_Feed>|null $feeds
*/
- public function __construct(string $name = '', array $feeds = null) {
+ public function __construct(string $name = '', ?array $feeds = null) {
$this->_name($name);
if ($feeds !== null) {
$this->_feeds($feeds);
@@ -99,7 +99,11 @@ class FreshRSS_Category extends Minz_Model {
return $this->nbNotRead;
}
- /** @return array<FreshRSS_Feed> */
+ /**
+ * @return array<FreshRSS_Feed>
+ * @throws Minz_ConfigurationNamespaceException
+ * @throws Minz_PDOConnectionException
+ */
public function feeds(): array {
if ($this->feeds === null) {
$feedDAO = FreshRSS_Factory::createFeedDao();
@@ -115,7 +119,7 @@ class FreshRSS_Category extends Minz_Model {
$this->sortFeeds();
}
- return $this->feeds;
+ return $this->feeds ?? [];
}
public function hasFeedsWithError(): bool {
@@ -266,6 +270,9 @@ class FreshRSS_Category extends Minz_Model {
}
private function sortFeeds(): void {
+ if ($this->feeds === null) {
+ return;
+ }
usort($this->feeds, static function (FreshRSS_Feed $a, FreshRSS_Feed $b) {
return strnatcasecmp($a->name(), $b->name());
});
diff --git a/tests/phpstan-next.txt b/tests/phpstan-next.txt
index ba06802de..b241caa2f 100644
--- a/tests/phpstan-next.txt
+++ b/tests/phpstan-next.txt
@@ -24,7 +24,6 @@
./app/Mailers/UserMailer.php
./app/Models/Auth.php
./app/Models/BooleanSearch.php
-./app/Models/Category.php
./app/Models/Context.php
./app/Models/DatabaseDAO.php
./app/Models/DatabaseDAOPGSQL.php