aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-04-17 08:30:21 +0200
committerGravatar GitHub <noreply@github.com> 2023-04-17 08:30:21 +0200
commitf3760f138dcbaf7a2190336a0378cf1b2190c9f5 (patch)
tree6fac8fbf9efd7aa74a8e3970ab70ccf85287b2cd /app/Controllers
parent41fa4e746df8c2e2399ed753b4994ca85cb21358 (diff)
Complete PHPStan Level 6 (#5305)
* Complete PHPStan Level 6 Fix https://github.com/FreshRSS/FreshRSS/issues/4112 And initiate PHPStan Level 7 * PHPStan Level 6 for tests * Use phpstan/phpstan-phpunit * Update to PHPStan version 1.10 * Fix mixed bug * Fix mixed return bug * Fix paginator bug * Fix FreshRSS_UserConfiguration * A couple more Minz_Configuration bug fixes * A few trivial PHPStan Level 7 fixes * A few more simple PHPStan Level 7 * More files passing PHPStan Level 7 Add interface to replace removed class from https://github.com/FreshRSS/FreshRSS/pull/5251 * A few more PHPStan Level 7 preparations * A few last details
Diffstat (limited to 'app/Controllers')
-rw-r--r--app/Controllers/categoryController.php4
-rw-r--r--app/Controllers/configureController.php4
-rw-r--r--app/Controllers/entryController.php4
-rw-r--r--app/Controllers/extensionController.php6
-rw-r--r--app/Controllers/feedController.php9
-rw-r--r--app/Controllers/importExportController.php10
-rw-r--r--app/Controllers/indexController.php12
-rw-r--r--app/Controllers/javascriptController.php6
-rw-r--r--app/Controllers/statsController.php4
-rw-r--r--app/Controllers/subscriptionController.php12
-rw-r--r--app/Controllers/tagController.php15
11 files changed, 42 insertions, 44 deletions
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php
index 91cd92787..0ca1bbbcd 100644
--- a/app/Controllers/categoryController.php
+++ b/app/Controllers/categoryController.php
@@ -33,7 +33,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {
$url_redirect = array('c' => 'subscription', 'a' => 'add');
$limits = FreshRSS_Context::$system_conf->limits;
- $this->view->categories = $catDAO->listCategories(false);
+ $this->view->categories = $catDAO->listCategories(false) ?: [];
if (count($this->view->categories) >= $limits['max_categories']) {
Minz_Request::bad(_t('feedback.sub.category.over_max', $limits['max_categories']), $url_redirect);
@@ -231,7 +231,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {
if (Minz_Request::paramBoolean('ajax')) {
Minz_Request::setGoodNotification(_t('feedback.sub.category.updated'));
- $this->view->_layout(false);
+ $this->view->_layout(null);
} else {
if ($ok) {
Minz_Request::good(_t('feedback.sub.category.updated'), $url_redirect);
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 667c2da74..87d9e4426 100644
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -264,7 +264,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
FreshRSS_Context::$user_conf->volatile = $volatile;
$entryDAO = FreshRSS_Factory::createEntryDao();
- $this->view->nb_total = $entryDAO->count();
+ $this->view->nb_total = $entryDAO->count() ?: 0;
$databaseDAO = FreshRSS_Factory::createDatabaseDAO();
$this->view->size_user = $databaseDAO->size();
@@ -338,7 +338,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
* applied to the selected query.
*/
public function queryAction(): void {
- $this->view->_layout(false);
+ $this->view->_layout(null);
$id = Minz_Request::paramInt('id');
if ($id !== 0 || !isset(FreshRSS_Context::$user_conf->queries[$id])) {
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php
index 7a30f94de..ff995b12f 100644
--- a/app/Controllers/entryController.php
+++ b/app/Controllers/entryController.php
@@ -24,7 +24,7 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {
// If ajax request, we do not print layout
$this->ajax = Minz_Request::paramBoolean('ajax');
if ($this->ajax) {
- $this->view->_layout(false);
+ $this->view->_layout(null);
Minz_Request::_param('ajax');
}
}
@@ -107,7 +107,7 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {
$ids = is_array($id) ? $id : array($id);
$entryDAO->markRead($ids, $is_read);
$tagDAO = FreshRSS_Factory::createTagDao();
- $tagsForEntries = $tagDAO->getTagsForEntries($ids);
+ $tagsForEntries = $tagDAO->getTagsForEntries($ids) ?: [];
$tags = array();
foreach ($tagsForEntries as $line) {
$tags['t_' . $line['id_tag']][] = $line['id_entry'];
diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php
index b482b1a35..4b440327d 100644
--- a/app/Controllers/extensionController.php
+++ b/app/Controllers/extensionController.php
@@ -79,7 +79,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {
*/
public function configureAction(): void {
if (Minz_Request::paramBoolean('ajax')) {
- $this->view->_layout(false);
+ $this->view->_layout(null);
} else {
$this->indexAction();
$this->view->_path('extension/index.phtml');
@@ -143,7 +143,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {
if ($conf !== null && $res === true) {
$ext_list = $conf->extensions_enabled;
- $ext_list = array_filter($ext_list, function($key) use($type) {
+ $ext_list = array_filter($ext_list, static function(string $key) use($type) {
// Remove from list the extensions that have disappeared or changed type
$extension = Minz_ExtensionManager::findExtension($key);
return $extension !== null && $extension->getType() === $type;
@@ -205,7 +205,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {
if ($conf !== null && $res === true) {
$ext_list = $conf->extensions_enabled;
- $ext_list = array_filter($ext_list, function($key) use($type) {
+ $ext_list = array_filter($ext_list, static function(string $key) use($type) {
// Remove from list the extensions that have disappeared or changed type
$extension = Minz_ExtensionManager::findExtension($key);
return $extension !== null && $extension->getType() === $type;
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 39a1c7289..15bf0128b 100644
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -262,7 +262,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
FreshRSS_View::prependTitle(_t('sub.feed.title_add') . ' · ');
$catDAO = FreshRSS_Factory::createCategoryDao();
- $this->view->categories = $catDAO->listCategories(false);
+ $this->view->categories = $catDAO->listCategories(false) ?: [];
$this->view->feed = new FreshRSS_Feed($url);
try {
// We try to get more information about the feed.
@@ -316,7 +316,8 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
/**
* @return array{0:int,1:FreshRSS_Feed|false,2:int}
*/
- public static function actualizeFeed(int $feed_id, string $feed_url, bool $force, ?SimplePie $simplePiePush = null, bool $noCommit = false, int $maxFeeds = 10) {
+ public static function actualizeFeed(int $feed_id, string $feed_url, bool $force, ?SimplePie $simplePiePush = null,
+ bool $noCommit = false, int $maxFeeds = 10): array {
@set_time_limit(300);
$feedDAO = FreshRSS_Factory::createFeedDao();
@@ -666,7 +667,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
// are several updated feeds.
Minz_Request::setGoodNotification(_t('feedback.sub.feed.actualizeds'));
// No layout in ajax request.
- $this->view->_layout(false);
+ $this->view->_layout(null);
} else {
// Redirect to the main page with correct notification.
if ($updated_feeds === 1) {
@@ -903,7 +904,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
$this->view->selectorSuccess = false;
$this->view->htmlContent = '';
- $this->view->_layout(false);
+ $this->view->_layout(null);
$this->_csp([
'default-src' => "'self'",
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 2df185398..4939a0748 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -226,7 +226,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
unset($table['article']);
for ($i = count($table['items']) - 1; $i >= 0; $i--) {
$item = (array)($table['items'][$i]);
- $item = array_filter($item, function ($v) {
+ $item = array_filter($item, static function ($v) {
// Filter out empty properties, potentially reported as empty objects
return (is_string($v) && trim($v) !== '') || !empty($v);
});
@@ -267,7 +267,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
*
* $article_file the JSON file content.
* true if articles from the file must be starred.
- * @return boolean false if an error occurred, true otherwise.
+ * @return bool false if an error occurred, true otherwise.
*/
private function importJson(string $article_file, bool $starred = false): bool {
$article_object = json_decode($article_file, true);
@@ -575,10 +575,8 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
* - export_starred (default: false)
* - export_labelled (default: false)
* - export_feeds (default: array()) a list of feed ids
- *
- * @return void|null
*/
- public function exportAction() {
+ public function exportAction(): void {
if (!Minz_Request::isPost()) {
Minz_Request::forward(['c' => 'importExport', 'a' => 'index'], true);
return;
@@ -654,7 +652,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
header('Content-Type: ' . $content_type);
header('Content-disposition: attachment; filename="' . $filename . '"');
- $this->view->_layout(false);
+ $this->view->_layout(null);
$this->view->content = $content;
}
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index 17aee3585..64371c530 100644
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -58,10 +58,10 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
FreshRSS_Context::$id_max = time() . '000000';
- $this->view->callbackBeforeFeeds = function ($view) {
+ $this->view->callbackBeforeFeeds = function (FreshRSS_View $view) {
try {
$tagDAO = FreshRSS_Factory::createTagDao();
- $view->tags = $tagDAO->listTags(true);
+ $view->tags = $tagDAO->listTags(true) ?: [];
$view->nbUnreadTags = 0;
foreach ($view->tags as $tag) {
$view->nbUnreadTags += $tag->nbUnread();
@@ -71,7 +71,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
};
- $this->view->callbackBeforeEntries = function ($view) {
+ $this->view->callbackBeforeEntries = function (FreshRSS_View $view) {
try {
FreshRSS_Context::$number++; //+1 for articles' page
$view->entries = FreshRSS_index_Controller::listEntriesByContext();
@@ -83,7 +83,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
};
- $this->view->callbackBeforePagination = function ($view, $nbEntries, $lastEntry) {
+ $this->view->callbackBeforePagination = function (?FreshRSS_View $view, int $nbEntries, FreshRSS_Entry $lastEntry) {
if ($nbEntries >= FreshRSS_Context::$number) {
//We have enough entries: we discard the last one to use it for the next articles' page
ob_clean();
@@ -170,7 +170,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
// No layout for RSS output.
$this->view->rss_url = PUBLIC_TO_INDEX_PATH . '/' . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']);
$this->view->rss_title = FreshRSS_Context::$name . ' | ' . FreshRSS_View::title();
- $this->view->_layout(false);
+ $this->view->_layout(null);
header('Content-Type: application/rss+xml; charset=utf-8');
}
@@ -238,7 +238,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
// No layout for OPML output.
- $this->view->_layout(false);
+ $this->view->_layout(null);
header('Content-Type: application/xml; charset=utf-8');
}
diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php
index d7c600113..ce25d03c9 100644
--- a/app/Controllers/javascriptController.php
+++ b/app/Controllers/javascriptController.php
@@ -3,7 +3,7 @@
class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
public function firstAction(): void {
- $this->view->_layout(false);
+ $this->view->_layout(null);
}
public function actualizeAction(): void {
@@ -20,9 +20,9 @@ class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
public function nbUnreadsPerFeedAction(): void {
header('Content-Type: application/json; charset=UTF-8');
$catDAO = FreshRSS_Factory::createCategoryDao();
- $this->view->categories = $catDAO->listCategories(true, false);
+ $this->view->categories = $catDAO->listCategories(true, false) ?: [];
$tagDAO = FreshRSS_Factory::createTagDao();
- $this->view->tags = $tagDAO->listTags(true);
+ $this->view->tags = $tagDAO->listTags(true) ?: [];
}
//For Web-form login
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
index cd9a247c4..0fc6490f8 100644
--- a/app/Controllers/statsController.php
+++ b/app/Controllers/statsController.php
@@ -26,7 +26,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
$catDAO->checkDefault();
$feedDAO->updateTTL();
- $this->view->categories = $catDAO->listSortedCategories(false);
+ $this->view->categories = $catDAO->listSortedCategories(false) ?: [];
$this->view->default_category = $catDAO->getDefault();
FreshRSS_View::prependTitle(_t('admin.stats.title') . ' · ');
@@ -207,7 +207,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
$id = null;
}
- $this->view->categories = $categoryDAO->listCategories();
+ $this->view->categories = $categoryDAO->listCategories() ?: [];
$this->view->feed = $id === null ? null : $feedDAO->searchById($id);
$this->view->days = $statsDAO->getDays();
$this->view->months = $statsDAO->getMonths();
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index e0a8d4ff4..d96cb02e1 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -19,7 +19,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
$catDAO->checkDefault();
$feedDAO->updateTTL();
- $this->view->categories = $catDAO->listSortedCategories(false, true);
+ $this->view->categories = $catDAO->listSortedCategories(false, true) ?: [];
$this->view->default_category = $catDAO->getDefault();
$signalError = false;
@@ -90,7 +90,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
*/
public function feedAction(): void {
if (Minz_Request::paramBoolean('ajax')) {
- $this->view->_layout(false);
+ $this->view->_layout(null);
} else {
FreshRSS_View::appendScript(Minz_Url::display('/scripts/feed.js?' . @filemtime(PUBLIC_PATH . '/scripts/feed.js')));
}
@@ -200,7 +200,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
]);
}
- $feed->_filtersAction('read', preg_split('/[\n\r]+/', Minz_Request::paramString('filteractions_read')));
+ $feed->_filtersAction('read', preg_split('/[\n\r]+/', Minz_Request::paramString('filteractions_read')) ?: []);
$feed->_kind(Minz_Request::paramInt('feed_kind') ?: FreshRSS_Feed::KIND_RSS);
if ($feed->kind() === FreshRSS_Feed::KIND_HTML_XPATH || $feed->kind() === FreshRSS_Feed::KIND_XML_XPATH) {
@@ -235,8 +235,8 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
'name' => Minz_Request::paramString('name'),
'kind' => $feed->kind(),
'description' => sanitizeHTML(Minz_Request::paramString('description', true)),
- 'website' => checkUrl(Minz_Request::paramString('website')),
- 'url' => checkUrl(Minz_Request::paramString('url')),
+ 'website' => checkUrl(Minz_Request::paramString('website')) ?: '',
+ 'url' => checkUrl(Minz_Request::paramString('url')) ?: '',
'category' => Minz_Request::paramInt('category'),
'pathEntries' => Minz_Request::paramString('path_entries'),
'priority' => Minz_Request::paramTernary('priority') === null ? FreshRSS_Feed::PRIORITY_MAIN_STREAM : Minz_Request::paramInt('priority'),
@@ -283,7 +283,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
}
public function categoryAction(): void {
- $this->view->_layout(false);
+ $this->view->_layout(null);
$categoryDAO = FreshRSS_Factory::createCategoryDao();
diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.php
index e4048238c..7a89b2b84 100644
--- a/app/Controllers/tagController.php
+++ b/app/Controllers/tagController.php
@@ -23,7 +23,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
// If ajax request, we do not print layout
$this->ajax = Minz_Request::paramBoolean('ajax');
if ($this->ajax) {
- $this->view->_layout(false);
+ $this->view->_layout(null);
Minz_Request::_param('ajax');
}
}
@@ -39,7 +39,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
$checked = Minz_Request::paramTernary('checked');
if ($id_entry != '') {
$tagDAO = FreshRSS_Factory::createTagDao();
- if ($id_tag === 0 && $name_tag !== '' && $checked) {
+ if ($id_tag == 0 && $name_tag !== '' && $checked) {
if ($existing_tag = $tagDAO->searchByName($name_tag)) {
// Use existing tag
$tagDAO->tagEntry($existing_tag->id(), $id_entry, $checked);
@@ -48,7 +48,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
$id_tag = $tagDAO->addTag(array('name' => $name_tag));
}
}
- if ($id_tag !== 0) {
+ if ($id_tag != false) {
$tagDAO->tagEntry($id_tag, $id_entry, $checked);
}
}
@@ -82,12 +82,12 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
}
public function getTagsForEntryAction(): void {
- $this->view->_layout(false);
+ $this->view->_layout(null);
header('Content-Type: application/json; charset=UTF-8');
header('Cache-Control: private, no-cache, no-store, must-revalidate');
$id_entry = Minz_Request::paramString('id_entry');
$tagDAO = FreshRSS_Factory::createTagDao();
- $this->view->tagsForEntry = $tagDAO->getTagsForEntry($id_entry);
+ $this->view->tagsForEntry = $tagDAO->getTagsForEntry($id_entry) ?: [];
}
public function addAction(): void {
@@ -110,11 +110,10 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
}
/**
- * @return void|null
* @throws Minz_ConfigurationNamespaceException
* @throws Minz_PDOConnectionException
*/
- public function renameAction() {
+ public function renameAction(): void {
if (!Minz_Request::isPost()) {
Minz_Error::error(405);
}
@@ -145,6 +144,6 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
public function indexAction(): void {
$tagDAO = FreshRSS_Factory::createTagDao();
- $this->view->tags = $tagDAO->listTags();
+ $this->view->tags = $tagDAO->listTags() ?: [];
}
}