aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-05-11 13:02:04 +0200
committerGravatar GitHub <noreply@github.com> 2023-05-11 13:02:04 +0200
commit6e2f2f1c1e98ecd86aa89c6547beb742d7385d18 (patch)
tree7ba9f5aebb01d12045b9067a86b5060ba13dca18 /app/Controllers
parentfe7d9bbcd68660a59b813346c236b61b25a51c80 (diff)
A few additional PHPStan rules (#5388)
A subset of https://github.com/phpstan/phpstan-strict-rules
Diffstat (limited to 'app/Controllers')
-rw-r--r--app/Controllers/feedController.php2
-rw-r--r--app/Controllers/indexController.php9
-rw-r--r--app/Controllers/javascriptController.php5
-rw-r--r--app/Controllers/statsController.php23
-rw-r--r--app/Controllers/tagController.php6
-rw-r--r--app/Controllers/userController.php16
6 files changed, 25 insertions, 36 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index fc03f7224..c007c3050 100644
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -348,7 +348,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
// Set maxFeeds to a minimum of 10
- if (!is_int($maxFeeds) || $maxFeeds < 10) {
+ if ($maxFeeds < 10) {
$maxFeeds = 10;
}
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index 3f5c419f1..0e680934a 100644
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -192,13 +192,8 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
$get = FreshRSS_Context::currentGet(true);
- if (is_array($get)) {
- $type = $get[0];
- $id = (int)$get[1];
- } else {
- $type = $get;
- $id = 0;
- }
+ $type = (string)$get[0];
+ $id = (int)$get[1];
$catDAO = FreshRSS_Factory::createCategoryDao();
$categories = $catDAO->listCategories(true, true);
diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php
index d3f73b2f9..eea8fc233 100644
--- a/app/Controllers/javascriptController.php
+++ b/app/Controllers/javascriptController.php
@@ -2,7 +2,10 @@
class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
- /** @var FreshRSS_ViewJavascript */
+ /**
+ * @var FreshRSS_ViewJavascript
+ * @phpstan-ignore-next-line
+ */
protected $view;
public function __construct() {
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
index d9c4fe5f4..3ce42dd2c 100644
--- a/app/Controllers/statsController.php
+++ b/app/Controllers/statsController.php
@@ -5,7 +5,10 @@
*/
class FreshRSS_stats_Controller extends FreshRSS_ActionController {
- /** @var FreshRSS_ViewStats */
+ /**
+ * @var FreshRSS_ViewStats
+ * @phpstan-ignore-next-line
+ */
protected $view;
public function __construct() {
@@ -57,7 +60,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
$this->view->repartitions = $statsDAO->calculateEntryRepartition();
$entryCount = $statsDAO->calculateEntryCount();
- if (is_array($entryCount) && count($entryCount) > 0) {
+ if (count($entryCount) > 0) {
$this->view->entryCount = $entryCount;
$this->view->average = round(array_sum(array_values($entryCount)) / count($entryCount), 2);
} else {
@@ -67,21 +70,17 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
$feedByCategory = [];
$feedByCategory_calculated = $statsDAO->calculateFeedByCategory();
- if (is_array($feedByCategory_calculated)) {
- for ($i = 0; $i < count($feedByCategory_calculated); $i++) {
- $feedByCategory['label'][$i] = $feedByCategory_calculated[$i]['label'];
- $feedByCategory['data'][$i] = $feedByCategory_calculated[$i]['data'];
- }
+ for ($i = 0; $i < count($feedByCategory_calculated); $i++) {
+ $feedByCategory['label'][$i] = $feedByCategory_calculated[$i]['label'];
+ $feedByCategory['data'][$i] = $feedByCategory_calculated[$i]['data'];
}
$this->view->feedByCategory = $feedByCategory;
$entryByCategory = [];
$entryByCategory_calculated = $statsDAO->calculateEntryByCategory();
- if (is_array($entryByCategory_calculated)) {
- for ($i = 0; $i < count($entryByCategory_calculated); $i++) {
- $entryByCategory['label'][$i] = $entryByCategory_calculated[$i]['label'];
- $entryByCategory['data'][$i] = $entryByCategory_calculated[$i]['data'];
- }
+ for ($i = 0; $i < count($entryByCategory_calculated); $i++) {
+ $entryByCategory['label'][$i] = $entryByCategory_calculated[$i]['label'];
+ $entryByCategory['data'][$i] = $entryByCategory_calculated[$i]['data'];
}
$this->view->entryByCategory = $entryByCategory;
diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.php
index c9dc7ce3e..eb259df12 100644
--- a/app/Controllers/tagController.php
+++ b/app/Controllers/tagController.php
@@ -96,12 +96,8 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
}
$name = Minz_Request::paramString('name');
- $lengthOfName = 0;
- if (is_string($name)) {
- $lengthOfName = strlen($name);
- }
$tagDAO = FreshRSS_Factory::createTagDao();
- if ($lengthOfName > 0 && null === $tagDAO->searchByName($name)) {
+ if (strlen($name) > 0 && null === $tagDAO->searchByName($name)) {
$tagDAO->addTag(['name' => $name]);
Minz_Request::good(_t('feedback.tag.created', $name), ['c' => 'tag', 'a' => 'index']);
}
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index ed8e6cc44..650f96fb2 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -41,11 +41,9 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
$userConfig->passwordHash = $passwordHash;
}
- if (is_array($userConfigUpdated)) {
- foreach ($userConfigUpdated as $configName => $configValue) {
- if ($configValue !== null) {
- $userConfig->_param($configName, $configValue);
- }
+ foreach ($userConfigUpdated as $configName => $configValue) {
+ if ($configValue !== null) {
+ $userConfig->_param($configName, $configValue);
}
}
@@ -224,9 +222,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
}
}
- if (is_array($userConfigOverride)) {
- $userConfig = array_merge($userConfig, $userConfigOverride);
- }
+ $userConfig = array_merge($userConfig, $userConfigOverride);
$ok = self::checkUsername($new_user_name);
$homeDir = join_path(DATA_PATH, 'users', $new_user_name);
@@ -234,11 +230,11 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
if ($ok) {
$languages = Minz_Translate::availableLanguages();
- if (empty($userConfig['language']) || !in_array($userConfig['language'], $languages)) {
+ if (empty($userConfig['language']) || !in_array($userConfig['language'], $languages, true)) {
$userConfig['language'] = 'en';
}
- $ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers())); //Not an existing user, case-insensitive
+ $ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers()), true); //Not an existing user, case-insensitive
$configPath = join_path($homeDir, 'config.php');
$ok &= !file_exists($configPath);