aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-05-02 14:38:32 +0200
committerGravatar GitHub <noreply@github.com> 2023-05-02 14:38:32 +0200
commitbd9fa803f1f0c23face77fa1bc550d1198ce5ad6 (patch)
treeedba662e84e70a6b0f23c8379d4ef174f714e999 /app/Controllers
parent4de1d5efea128e6cc70c71bad9be28d01e851f81 (diff)
PHPStan Level 7 complete DAOs (#5354)
* PHPStan Level 7 complete DAOs * Finalise PHPStan Level 7 for CategoryDAO * PHPStan Level 7 for Context and Search * Apply suggestions from code review Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>
Diffstat (limited to 'app/Controllers')
-rw-r--r--app/Controllers/feedController.php6
-rw-r--r--app/Controllers/indexController.php7
-rw-r--r--app/Controllers/statsController.php5
3 files changed, 10 insertions, 8 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 76cd3ad83..1974751d0 100644
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -823,8 +823,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$feedDAO = FreshRSS_Factory::createFeedDao();
$feed = $feedDAO->searchById($id);
-
- if (!$feed) {
+ if ($feed === null) {
Minz_Request::bad(_t('feedback.sub.feed.not_found'), array());
return;
}
@@ -854,8 +853,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$entryDAO = FreshRSS_Factory::createEntryDao();
$feed = $feedDAO->searchById($feed_id);
-
- if (!$feed) {
+ if ($feed === null) {
Minz_Request::bad(_t('feedback.sub.feed.not_found'), array());
return;
}
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index 21a94d53d..3f5c419f1 100644
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -194,7 +194,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
$get = FreshRSS_Context::currentGet(true);
if (is_array($get)) {
$type = $get[0];
- $id = $get[1];
+ $id = (int)$get[1];
} else {
$type = $get;
$id = 0;
@@ -219,7 +219,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
case 'f':
// We most likely already have the feed object in cache
$feed = FreshRSS_CategoryDAO::findFeed($categories, $id);
- if ($feed == null) {
+ if ($feed === null) {
$feedDAO = FreshRSS_Factory::createFeedDao();
$feed = $feedDAO->searchById($id);
if ($feed == null) {
@@ -290,8 +290,9 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
*/
public function tosAction(): void {
$terms_of_service = file_get_contents(TOS_FILENAME);
- if (!$terms_of_service) {
+ if ($terms_of_service === false) {
Minz_Error::error(404);
+ return;
}
$this->view->terms_of_service = $terms_of_service;
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
index afbaccfc5..79facbbf6 100644
--- a/app/Controllers/statsController.php
+++ b/app/Controllers/statsController.php
@@ -155,7 +155,10 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
foreach ($feeds as $feed) {
$feedDAO = FreshRSS_Factory::createFeedDao();
- $feed['favicon'] = $feedDAO->searchById($feed['id'])->favicon();
+ $feedObject = $feedDAO->searchById($feed['id']);
+ if ($feedObject !== null) {
+ $feed['favicon'] = $feedObject->favicon();
+ }
$feedDate->setTimestamp($feed['last_date']);
if ($feedDate >= $lastWeek) {