A free, self-hostable news aggregator…
Chore/processing of depreciations and updating code to php72 minimum (#5504)
Luc SANCHEZf8f163d05411
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.phpindex 0839656a5..8feebe9a3 100644--- a/app/Controllers/authController.php+++ b/app/Controllers/authController.php@@ -61,23 +61,27 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {** It forwards to the correct login page (form) or main page if* the user is already connected.+ * @throws Minz_ConfigurationParamException*/public function loginAction(): void {if (FreshRSS_Auth::hasAccess() && Minz_Request::paramString('u') === '') {- Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true);+ Minz_Request::forward(['c' => 'index', 'a' => 'index'], true);}$auth_type = FreshRSS_Context::$system_conf->auth_type;FreshRSS_Context::initUser(Minz_User::INTERNAL_USER, false);switch ($auth_type) {case 'form':- Minz_Request::forward(array('c' => 'auth', 'a' => 'formLogin'));+ Minz_Request::forward(['c' => 'auth', 'a' => 'formLogin']);break;case 'http_auth':- Minz_Error::error(403, array('error' => array(_t('feedback.access.denied'),+ Minz_Error::error(403, [+ 'error' => [+ _t('feedback.access.denied'),' [HTTP Remote-User=' . htmlspecialchars(httpAuthUser(false), ENT_NOQUOTES, 'UTF-8') .' ; Remote IP address=' . ($_SERVER['REMOTE_ADDR'] ?? '') . ']'- )), false);+ ]+ ], false);break;case 'none':// It should not happen!@@ -200,12 +204,12 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {Minz_Translate::init(FreshRSS_Context::$user_conf->language);- Minz_Request::good(_t('feedback.auth.login.success'), [ 'c' => 'index', 'a' => 'index' ]);+ Minz_Request::good(_t('feedback.auth.login.success'), ['c' => 'index', 'a' => 'index']);} else {Minz_Log::warning('Unsafe password mismatch for user ' . $username);Minz_Request::bad(_t('feedback.auth.login.invalid'),- array('c' => 'auth', 'a' => 'login')+ ['c' => 'auth', 'a' => 'login']);}}@@ -229,7 +233,7 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {*/public function registerAction(): void {if (FreshRSS_Auth::hasAccess()) {- Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true);+ Minz_Request::forward(['c' => 'index', 'a' => 'index'], true);}if (max_registrations_reached()) {diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.phpindex 60685c566..630399bf4 100644--- a/app/Controllers/categoryController.php+++ b/app/Controllers/categoryController.php@@ -30,7 +30,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {$catDAO = FreshRSS_Factory::createCategoryDao();$tagDAO = FreshRSS_Factory::createTagDao();- $url_redirect = array('c' => 'subscription', 'a' => 'add');+ $url_redirect = ['c' => 'subscription', 'a' => 'add'];$limits = FreshRSS_Context::$system_conf->limits;$this->view->categories = $catDAO->listCategories(false) ?: [];@@ -88,7 +88,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {*/public function updateAction(): void {$catDAO = FreshRSS_Factory::createCategoryDao();- $url_redirect = array('c' => 'subscription', 'a' => 'index');+ $url_redirect = ['c' => 'subscription', 'a' => 'index'];if (Minz_Request::isPost()) {invalidateHttpCache();@@ -131,7 +131,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {public function deleteAction(): void {$feedDAO = FreshRSS_Factory::createFeedDao();$catDAO = FreshRSS_Factory::createCategoryDao();- $url_redirect = array('c' => 'subscription', 'a' => 'index');+ $url_redirect = ['c' => 'subscription', 'a' => 'index'];if (Minz_Request::isPost()) {invalidateHttpCache();@@ -174,7 +174,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {*/public function emptyAction(): void {$feedDAO = FreshRSS_Factory::createFeedDao();- $url_redirect = array('c' => 'subscription', 'a' => 'index');+ $url_redirect = ['c' => 'subscription', 'a' => 'index'];if (Minz_Request::isPost()) {invalidateHttpCache();@@ -214,7 +214,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController {*/public function refreshOpmlAction(): void {$catDAO = FreshRSS_Factory::createCategoryDao();- $url_redirect = array('c' => 'subscription', 'a' => 'index');+ $url_redirect = ['c' => 'subscription', 'a' => 'index'];if (Minz_Request::isPost()) {invalidateHttpCache();diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.phpindex 592e8c896..7981c00bb 100644--- a/app/Controllers/configureController.php+++ b/app/Controllers/configureController.php@@ -127,16 +127,16 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {FreshRSS_Context::$user_conf->auto_remove_article = Minz_Request::paramBoolean('auto_remove_article');FreshRSS_Context::$user_conf->mark_updated_article_unread = Minz_Request::paramBoolean('mark_updated_article_unread');FreshRSS_Context::$user_conf->sort_order = Minz_Request::paramString('sort_order') ?: 'DESC';- FreshRSS_Context::$user_conf->mark_when = array(+ FreshRSS_Context::$user_conf->mark_when = ['article' => Minz_Request::paramBoolean('mark_open_article'),'gone' => Minz_Request::paramBoolean('read_upon_gone'),'max_n_unread' => Minz_Request::paramBoolean('enable_keep_max_n_unread') ? Minz_Request::paramInt('keep_max_n_unread') : false,'reception' => Minz_Request::paramBoolean('mark_upon_reception'),- 'same_title_in_feed' => Minz_Request::paramBoolean('enable_read_when_same_title_in_feed') ?- Minz_Request::paramBoolean('read_when_same_title_in_feed') : false,+ 'same_title_in_feed' =>+ Minz_Request::paramBoolean('enable_read_when_same_title_in_feed') && Minz_Request::paramBoolean('read_when_same_title_in_feed'),'scroll' => Minz_Request::paramBoolean('mark_scroll'),'site' => Minz_Request::paramBoolean('mark_open_site'),- );+ ];FreshRSS_Context::$user_conf->save();invalidateHttpCache();@@ -197,7 +197,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {FreshRSS_Context::$user_conf->save();invalidateHttpCache();- Minz_Request::good(_t('feedback.conf.shortcuts_updated'), array('c' => 'configure', 'a' => 'shortcut'));+ Minz_Request::good(_t('feedback.conf.shortcuts_updated'), ['c' => 'configure', 'a' => 'shortcut']);}FreshRSS_View::prependTitle(_t('conf.shortcut.title') . ' · ');@@ -313,7 +313,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'queries' ]);} else {- $this->view->queries = array();+ $this->view->queries = [];foreach (FreshRSS_Context::$user_conf->queries as $key => $query) {$this->view->queries[intval($key)] = new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao);}@@ -419,13 +419,13 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {$category_dao = FreshRSS_Factory::createCategoryDao();$feed_dao = FreshRSS_Factory::createFeedDao();$tag_dao = FreshRSS_Factory::createTagDao();- $queries = array();+ $queries = [];foreach (FreshRSS_Context::$user_conf->queries as $key => $query) {$queries[$key] = (new FreshRSS_UserQuery($query, $feed_dao, $category_dao, $tag_dao))->toArray();}$params = $_GET;unset($params['rid']);- $params['url'] = Minz_Url::display(array('params' => $params));+ $params['url'] = Minz_Url::display(['params' => $params]);$params['name'] = _t('conf.query.number', count($queries) + 1);$queries[] = (new FreshRSS_UserQuery($params, $feed_dao, $category_dao, $tag_dao))->toArray();diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.phpindex ff995b12f..f334ce0a6 100644--- a/app/Controllers/entryController.php+++ b/app/Controllers/entryController.php@@ -66,7 +66,7 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {if ($id == false) {// id is false? It MUST be a POST request!if (!Minz_Request::isPost()) {- Minz_Request::bad(_t('feedback.access.not_found'), array('c' => 'index', 'a' => 'index'));+ Minz_Request::bad(_t('feedback.access.not_found'), ['c' => 'index', 'a' => 'index']);return;}@@ -104,11 +104,11 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {}}} else {- $ids = is_array($id) ? $id : array($id);+ $ids = is_array($id) ? $id : [$id];$entryDAO->markRead($ids, $is_read);$tagDAO = FreshRSS_Factory::createTagDao();$tagsForEntries = $tagDAO->getTagsForEntries($ids) ?: [];- $tags = array();+ $tags = [];foreach ($tagsForEntries as $line) {$tags['t_' . $line['id_tag']][] = $line['id_entry'];}@@ -116,12 +116,14 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {}if (!$this->ajax) {- Minz_Request::good($is_read ? _t('feedback.sub.articles.marked_read') : _t('feedback.sub.articles.marked_unread'),- array(- 'c' => 'index',- 'a' => 'index',- 'params' => $params,- ));+ Minz_Request::good(+ $is_read ? _t('feedback.sub.articles.marked_read') : _t('feedback.sub.articles.marked_unread'),+ [+ 'c' => 'index',+ 'a' => 'index',+ 'params' => $params,+ ]+ );}}@@ -142,10 +144,10 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {}if (!$this->ajax) {- Minz_Request::forward(array(+ Minz_Request::forward(['c' => 'index','a' => 'index',- ), true);+ ], true);}}@@ -158,10 +160,10 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {* @todo call this action through web-cron when available*/public function optimizeAction(): void {- $url_redirect = array(+ $url_redirect = ['c' => 'configure','a' => 'archiving',- );+ ];if (!Minz_Request::isPost()) {Minz_Request::forward($url_redirect, true);@@ -207,9 +209,9 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {$databaseDAO->minorDbMaintenance();invalidateHttpCache();- Minz_Request::good(_t('feedback.sub.purge_completed', $nb_total), array(+ Minz_Request::good(_t('feedback.sub.purge_completed', $nb_total), ['c' => 'configure',- 'a' => 'archiving'- ));+ 'a' => 'archiving',+ ]);}}diff --git a/app/Controllers/errorController.php b/app/Controllers/errorController.phpindex c5b727c05..fe56b13eb 100644--- a/app/Controllers/errorController.php+++ b/app/Controllers/errorController.php@@ -15,7 +15,7 @@ class FreshRSS_error_Controller extends FreshRSS_ActionController {*/public function indexAction(): void {$code_int = Minz_Session::param('error_code', 404);- $error_logs = Minz_Session::param('error_logs', array());+ $error_logs = Minz_Session::param('error_logs', []);Minz_Session::_params(['error_code' => false,'error_logs' => false,diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.phpindex 2543edac1..e93ec778f 100644--- a/app/Controllers/extensionController.php+++ b/app/Controllers/extensionController.php@@ -20,12 +20,12 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {*/public function indexAction(): void {FreshRSS_View::prependTitle(_t('admin.extensions.title') . ' · ');- $this->view->extension_list = array(- 'system' => array(),- 'user' => array(),- );+ $this->view->extension_list = [+ 'system' => [],+ 'user' => [],+ ];- $this->view->extensions_installed = array();+ $this->view->extensions_installed = [];$extensions = Minz_ExtensionManager::listExtensions();foreach ($extensions as $ext) {@@ -47,21 +47,21 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {// we ran into problems, simply ignore themif ($json === false) {Minz_Log::error('Could not fetch available extension from GitHub');- return array();+ return [];}// fetch the list as an array- /** @var array<string,mixed> */+ /** @var array<string,mixed> $list*/$list = json_decode($json, true);if (empty($list)) {Minz_Log::warning('Failed to convert extension file list');- return array();+ return [];}// By now, all the needed data is kept in the main extension file.// In the future we could fetch detail information from the extensions metadata.json, but I tend to stick with// the current implementation for now, unless it becomes too much effort maintain the extension list manually- /** @var array<string,array{'name':string,'author':string,'description':string,'version':string,'entrypoint':string,'type':'system'|'user','url':string,'method':string,'directory':string}> */+ /** @var array<string,array{'name':string,'author':string,'description':string,'version':string,'entrypoint':string,'type':'system'|'user','url':string,'method':string,'directory':string}> $extensions*/$extensions = $list['extensions'];return $extensions;@@ -112,7 +112,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {* - e: the extension name (urlencoded).*/public function enableAction(): void {- $url_redirect = array('c' => 'extension', 'a' => 'index');+ $url_redirect = ['c' => 'extension', 'a' => 'index'];if (Minz_Request::isPost()) {$ext_name = urldecode(Minz_Request::paramString('e'));@@ -174,7 +174,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {* - e: the extension name (urlencoded).*/public function disableAction(): void {- $url_redirect = array('c' => 'extension', 'a' => 'index');+ $url_redirect = ['c' => 'extension', 'a' => 'index'];if (Minz_Request::isPost()) {$ext_name = urldecode(Minz_Request::paramString('e'));@@ -240,7 +240,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {Minz_Error::error(403);}- $url_redirect = array('c' => 'extension', 'a' => 'index');+ $url_redirect = ['c' => 'extension', 'a' => 'index'];if (Minz_Request::isPost()) {$ext_name = urldecode(Minz_Request::paramString('e'));diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex 8c95a5c9c..e5685dddf 100644--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -54,7 +54,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {$cat = $catDAO->searchById($cat_id);}if ($cat === null && $new_cat_name != '') {- $new_cat_id = $catDAO->addCategory(array('name' => $new_cat_name));+ $new_cat_id = $catDAO->addCategory(['name' => $new_cat_name]);$cat_id = $new_cat_id > 0 ? $new_cat_id : $cat_id;$cat = $catDAO->searchById($cat_id);}@@ -132,18 +132,18 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {if ($url === '') {// No url, do nothing- Minz_Request::forward(array(+ Minz_Request::forward(['c' => 'subscription',- 'a' => 'index'- ), true);+ 'a' => 'index',+ ], true);}$feedDAO = FreshRSS_Factory::createFeedDao();- $url_redirect = array(+ $url_redirect = ['c' => 'subscription','a' => 'add',- 'params' => array(),- );+ 'params' => [],+ ];$limits = FreshRSS_Context::$system_conf->limits;$this->view->feeds = $feedDAO->listFeeds();@@ -302,11 +302,11 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {*/public function truncateAction(): void {$id = Minz_Request::paramInt('id');- $url_redirect = array(+ $url_redirect = ['c' => 'subscription','a' => 'index',- 'params' => array('id' => $id)- );+ 'params' => ['id' => $id],+ ];if (!Minz_Request::isPost()) {Minz_Request::forward($url_redirect, true);@@ -337,7 +337,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {// Create a list of feeds to actualize.// If feed_id is set and valid, corresponding feed is added to the list but// alone in order to automatize further process.- $feeds = array();+ $feeds = [];if ($feed_id > 0 || $feed_url) {$feed = $feed_id > 0 ? $feedDAO->searchById($feed_id) : $feedDAO->searchByUrl($feed_url);if ($feed) {@@ -455,9 +455,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {$titlesAsRead = array_flip($feedDAO->listTitles($feed->id(), (int)$readWhenSameTitleInFeed));}- $mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') !== null ? (- $feed->attributes('mark_updated_article_unread')- ) : FreshRSS_Context::$user_conf->mark_updated_article_unread;+ $mark_updated_article_unread = $feed->attributes('mark_updated_article_unread') ?? FreshRSS_Context::$user_conf->mark_updated_article_unread;// For this feed, check existing GUIDs already in database.$existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids) ?: [];@@ -555,7 +553,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {}unset($entries);- if (mt_rand(0, 30) === 1) { // Remove old entries once in 30.+ if (rand(0, 30) === 1) { // Remove old entries once in 30.if (!$entryDAO->inTransaction()) {$entryDAO->beginTransaction();}@@ -590,7 +588,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {}$feed->_url($selfUrl, false);Minz_Log::notice('Feed ' . $url . ' canonical address moved to ' . $feed->url(false));- $feedDAO->updateFeed($feed->id(), array('url' => $feed->url()));+ $feedDAO->updateFeed($feed->id(), ['url' => $feed->url()]);}}} elseif ($feed->url() !== $url) { // HTTP 301 Moved Permanently@@ -602,7 +600,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {if ($simplePie != null) {if ($feed->name(true) === '') {//HTML to HTML-PRE //ENT_COMPAT except '&'- $name = strtr(html_only_entity_decode($simplePie->get_title()), array('<' => '<', '>' => '>', '"' => '"'));+ $name = strtr(html_only_entity_decode($simplePie->get_title()), ['<' => '<', '>' => '>', '"' => '"']);$feed->_name($name);$feedProperties['name'] = $feed->name(false);}@@ -661,7 +659,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {$databaseDAO = FreshRSS_Factory::createDatabaseDAO();$databaseDAO->minorDbMaintenance();}- return array($updated_feeds, reset($feeds), $nb_new_articles);+ return [$updated_feeds, reset($feeds), $nb_new_articles];}/**@@ -722,13 +720,18 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {return $updated_feeds;}+ /**+ * @throws Minz_ConfigurationNamespaceException+ * @throws JsonException+ * @throws Minz_PDOConnectionException+ */public static function renameFeed(int $feed_id, string $feed_name): bool {if ($feed_id <= 0 || $feed_name === '') {return false;}FreshRSS_UserDAO::touch();$feedDAO = FreshRSS_Factory::createFeedDao();- return $feedDAO->updateFeed($feed_id, array('name' => $feed_name)) === 1;+ return $feedDAO->updateFeed($feed_id, ['name' => $feed_name]) === 1;}public static function moveFeed(int $feed_id, int $cat_id, string $new_cat_name = ''): bool {@@ -743,7 +746,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {$cat_id = $cat === null ? 0 : $cat->id();}if ($cat_id <= 1 && $new_cat_name != '') {- $cat_id = $catDAO->addCategory(array('name' => $new_cat_name));+ $cat_id = $catDAO->addCategory(['name' => $new_cat_name]);}if ($cat_id <= 1) {$catDAO->checkDefault();@@ -751,7 +754,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {}$feedDAO = FreshRSS_Factory::createFeedDao();- return $feedDAO->updateFeed($feed_id, array('category' => $cat_id)) === 1;+ return $feedDAO->updateFeed($feed_id, ['category' => $cat_id]) === 1;}/**@@ -768,7 +771,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {*/public function moveAction(): void {if (!Minz_Request::isPost()) {- Minz_Request::forward(array('c' => 'subscription'), true);+ Minz_Request::forward(['c' => 'subscription'], true);}$feed_id = Minz_Request::paramInt('f_id');@@ -815,14 +818,14 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {switch ($from) {case 'stats':- $redirect_url = array('c' => 'stats', 'a' => 'idle');+ $redirect_url = ['c' => 'stats', 'a' => 'idle'];break;case 'normal':$get = Minz_Request::paramString('get');if ($get) {- $redirect_url = array('c' => 'index', 'a' => 'normal', 'params' => array('get' => $get));+ $redirect_url = ['c' => 'index', 'a' => 'normal', 'params' => ['get' => $get]];} else {- $redirect_url = array('c' => 'index', 'a' => 'normal');+ $redirect_url = ['c' => 'index', 'a' => 'normal'];}break;default:@@ -853,15 +856,15 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {$feedDAO = FreshRSS_Factory::createFeedDao();$feed = $feedDAO->searchById($id);if ($feed === null) {- Minz_Request::bad(_t('feedback.sub.feed.not_found'), array());+ Minz_Request::bad(_t('feedback.sub.feed.not_found'), []);return;}$feed->clearCache();- Minz_Request::good(_t('feedback.sub.feed.cache_cleared', $feed->name()), array(- 'params' => array('get' => 'f_' . $feed->id())- ));+ Minz_Request::good(_t('feedback.sub.feed.cache_cleared', $feed->name()), [+ 'params' => ['get' => 'f_' . $feed->id()],+ ]);}/**@@ -884,7 +887,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {$feed = $feedDAO->searchById($feed_id);if ($feed === null) {- Minz_Request::bad(_t('feedback.sub.feed.not_found'), array());+ Minz_Request::bad(_t('feedback.sub.feed.not_found'), []);return;}@@ -915,9 +918,9 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {Minz_ModelPdo::$usesSharedPdo = true;//Give feedback to user.- Minz_Request::good(_t('feedback.sub.feed.reloaded', $feed->name()), array(- 'params' => array('get' => 'f_' . $feed->id())- ));+ Minz_Request::good(_t('feedback.sub.feed.reloaded', $feed->name()), [+ 'params' => ['get' => 'f_' . $feed->id()]+ ]);}/**diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.phpindex b6f7a4441..9c18b608f 100644--- a/app/Controllers/importExportController.php+++ b/app/Controllers/importExportController.php@@ -70,15 +70,15 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {$type_file = self::guessFileType($name);- $list_files = array(- 'opml' => array(),- 'json_starred' => array(),- 'json_feed' => array(),- 'ttrss_starred' => array(),- );+ $list_files = [+ 'opml' => [],+ 'json_starred' => [],+ 'json_feed' => [],+ 'ttrss_starred' => [],+ ];// We try to list all files according to their type- $list = array();+ $list = [];if ('zip' === $type_file && extension_loaded('zip')) {$zip = new ZipArchive();$result = $zip->open($path);@@ -171,7 +171,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {*/public function importAction(): void {if (!Minz_Request::isPost()) {- Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true);+ Minz_Request::forward(['c' => 'importExport', 'a' => 'index'], true);}$file = $_FILES['file'];@@ -188,12 +188,16 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {try {$error = !$this->importFile($file['name'], $file['tmp_name']);} catch (FreshRSS_ZipMissing_Exception $zme) {- Minz_Request::bad(_t('feedback.import_export.no_zip_extension'),- array('c' => 'importExport', 'a' => 'index'));+ Minz_Request::bad(+ _t('feedback.import_export.no_zip_extension'),+ ['c' => 'importExport', 'a' => 'index']+ );} catch (FreshRSS_Zip_Exception $ze) {Minz_Log::warning('ZIP archive cannot be imported. Error code: ' . $ze->zipErrorCode());- Minz_Request::bad(_t('feedback.import_export.zip_error'),- array('c' => 'importExport', 'a' => 'index'));+ Minz_Request::bad(+ _t('feedback.import_export.zip_error'),+ ['c' => 'importExport', 'a' => 'index']+ );}// And finally, we get import status and redirect to the home page@@ -245,7 +249,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {$item['updated'] = isset($item['updated']) ? strtotime($item['updated']) : '';$item['published'] = $item['updated'];$item['content'] = ['content' => $item['content'] ?? ''];- $item['categories'] = isset($item['tag_cache']) ? array($item['tag_cache']) : array();+ $item['categories'] = isset($item['tag_cache']) ? [$item['tag_cache']] : [];if (!empty($item['marked'])) {$item['categories'][] = 'user/-/state/com.google/starred';}@@ -298,10 +302,10 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {$mark_as_read = FreshRSS_Context::$user_conf->mark_when['reception'] ? 1 : 0;$error = false;- $article_to_feed = array();+ $article_to_feed = [];$nb_feeds = count($this->feedDAO->listFeeds());- $newFeedGuids = array();+ $newFeedGuids = [];$limits = FreshRSS_Context::$system_conf->limits;// First, we check feeds of articles are in DB (and add them if needed).@@ -353,7 +357,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {if ($feed != null) {$article_to_feed[$item['guid']] = $feed->id();if (!isset($newFeedGuids['f_' . $feed->id()])) {- $newFeedGuids['f_' . $feed->id()] = array();+ $newFeedGuids['f_' . $feed->id()] = [];}$newFeedGuids['f_' . $feed->id()][] = safe_ascii($item['guid']);}@@ -361,22 +365,22 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {$tagDAO = FreshRSS_Factory::createTagDao();$labels = $tagDAO->listTags() ?: [];- $knownLabels = array();+ $knownLabels = [];foreach ($labels as $label) {$knownLabels[$label->name()]['id'] = $label->id();- $knownLabels[$label->name()]['articles'] = array();+ $knownLabels[$label->name()]['articles'] = [];}unset($labels);// For each feed, check existing GUIDs already in database.- $existingHashForGuids = array();+ $existingHashForGuids = [];foreach ($newFeedGuids as $feedId => $newGuids) {$existingHashForGuids[$feedId] = $this->entryDAO->listHashForFeedGuids((int)substr($feedId, 2), $newGuids);}unset($newFeedGuids);// Then, articles are imported.- $newGuids = array();+ $newGuids = [];$this->entryDAO->beginTransaction();foreach ($items as $item) {if (empty($item['guid']) || empty($article_to_feed[$item['guid']])) {@@ -388,8 +392,8 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {$author = $item['author'] ?? '';$is_starred = null; // null is used to preserve the current state if that item exists and is already starred$is_read = null;- $tags = empty($item['categories']) ? array() : $item['categories'];- $labels = array();+ $tags = empty($item['categories']) ? [] : $item['categories'];+ $labels = [];for ($i = count($tags) - 1; $i >= 0; $i--) {$tag = trim($tags[$i]);if (strpos($tag, 'user/-/') !== false) {@@ -480,15 +484,15 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {foreach ($labels as $labelName) {if (empty($knownLabels[$labelName]['id'])) {- $labelId = $tagDAO->addTag(array('name' => $labelName));+ $labelId = $tagDAO->addTag(['name' => $labelName]);$knownLabels[$labelName]['id'] = $labelId;- $knownLabels[$labelName]['articles'] = array();+ $knownLabels[$labelName]['articles'] = [];}- $knownLabels[$labelName]['articles'][] = array(- //'id' => $entry->id(), //ID changes after commitNewEntries()- 'id_feed' => $entry->feedId(),- 'guid' => $entry->guid(),- );+ $knownLabels[$labelName]['articles'][] = [+ //'id' => $entry->id(), //ID changes after commitNewEntries()+ 'id_feed' => $entry->feedId(),+ 'guid' => $entry->guid(),+ ];}$error |= ($ok === false);diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.phpindex 0e680934a..cad2e9f85 100644--- a/app/Controllers/indexController.php+++ b/app/Controllers/indexController.php@@ -10,10 +10,10 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {*/public function indexAction(): void {$preferred_output = FreshRSS_Context::$user_conf->view_mode;- Minz_Request::forward(array(+ Minz_Request::forward(['c' => 'index',- 'a' => $preferred_output- ));+ 'a' => $preferred_output,+ ]);}/**@@ -22,14 +22,14 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {public function normalAction(): void {$allow_anonymous = FreshRSS_Context::$system_conf->allow_anonymous;if (!FreshRSS_Auth::hasAccess() && !$allow_anonymous) {- Minz_Request::forward(array('c' => 'auth', 'a' => 'login'));+ Minz_Request::forward(['c' => 'auth', 'a' => 'login']);return;}$id = Minz_Request::paramInt('id');if ($id !== 0) {$view = Minz_Request::paramString('a');- $url_redirect = array('c' => 'subscription', 'a' => 'feed', 'params' => array('id' => (string)$id, 'from' => $view));+ $url_redirect = ['c' => 'subscription', 'a' => 'feed', 'params' => ['id' => (string)$id, 'from' => $view]];Minz_Request::forward($url_redirect, true);return;}@@ -58,7 +58,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {FreshRSS_Context::$id_max = time() . '000000';- $this->view->callbackBeforeFeeds = function (FreshRSS_View $view) {+ $this->view->callbackBeforeFeeds = static function (FreshRSS_View $view) {try {$tagDAO = FreshRSS_Factory::createTagDao();$view->tags = $tagDAO->listTags(true) ?: [];@@ -71,7 +71,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {}};- $this->view->callbackBeforeEntries = function (FreshRSS_View $view) {+ $this->view->callbackBeforeEntries = static 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 (?FreshRSS_View $view, int $nbEntries, FreshRSS_Entry $lastEntry) {+ $this->view->callbackBeforePagination = static 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' pageob_clean();@@ -108,7 +108,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {public function globalAction(): void {$allow_anonymous = FreshRSS_Context::$system_conf->allow_anonymous;if (!FreshRSS_Auth::hasAccess() && !$allow_anonymous) {- Minz_Request::forward(array('c' => 'auth', 'a' => 'login'));+ Minz_Request::forward(['c' => 'auth', 'a' => 'login']);return;}diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.phpindex 3ce42dd2c..9890db04b 100644--- a/app/Controllers/statsController.php+++ b/app/Controllers/statsController.php@@ -104,9 +104,9 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {$id = Minz_Request::paramInt('id');$ajax = Minz_Request::paramBoolean('ajax');if ($ajax) {- $url_redirect = array('c' => 'subscription', 'a' => 'feed', 'params' => array('id' => (string)$id, 'from' => 'stats', 'ajax' => (string)$ajax));+ $url_redirect = ['c' => 'subscription', 'a' => 'feed', 'params' => ['id' => (string)$id, 'from' => 'stats', 'ajax' => (string)$ajax]];} else {- $url_redirect = array('c' => 'subscription', 'a' => 'feed', 'params' => array('id' => (string)$id, 'from' => 'stats'));+ $url_redirect = ['c' => 'subscription', 'a' => 'feed', 'params' => ['id' => (string)$id, 'from' => 'stats']];}Minz_Request::forward($url_redirect, true);}@@ -130,16 +130,16 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {$feed_dao = FreshRSS_Factory::createFeedDao();$statsDAO = FreshRSS_Factory::createStatsDAO();$feeds = $statsDAO->calculateFeedLastDate() ?: [];- $idleFeeds = array(- 'last_5_year' => array(),- 'last_3_year' => array(),- 'last_2_year' => array(),- 'last_year' => array(),- 'last_6_month' => array(),- 'last_3_month' => array(),- 'last_month' => array(),- 'last_week' => array(),- );+ $idleFeeds = [+ 'last_5_year' => [],+ 'last_3_year' => [],+ 'last_2_year' => [],+ 'last_year' => [],+ 'last_6_month' => [],+ 'last_3_month' => [],+ 'last_month' => [],+ 'last_week' => [],+ ];$now = new \DateTime();$feedDate = clone $now;$lastWeek = clone $now;diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.phpindex 3383dc66a..733a9252c 100644--- a/app/Controllers/subscriptionController.php+++ b/app/Controllers/subscriptionController.php@@ -231,7 +231,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {$feed->_attributes('path_entries_filter', Minz_Request::paramString('path_entries_filter', true));- $values = array(+ $values = ['name' => Minz_Request::paramString('name'),'kind' => $feed->kind(),'description' => sanitizeHTML(Minz_Request::paramString('description', true)),@@ -243,26 +243,26 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {'httpAuth' => $httpAuth,'ttl' => $feed->ttl(true),'attributes' => $feed->attributes(),- );+ ];invalidateHttpCache();$from = Minz_Request::paramString('from');switch ($from) {case 'stats':- $url_redirect = array('c' => 'stats', 'a' => 'idle', 'params' => array('id' => $id, 'from' => 'stats'));+ $url_redirect = ['c' => 'stats', 'a' => 'idle', 'params' => ['id' => $id, 'from' => 'stats']];break;case 'normal':case 'reader':$get = Minz_Request::paramString('get');if ($get) {- $url_redirect = array('c' => 'index', 'a' => $from, 'params' => array('get' => $get));+ $url_redirect = ['c' => 'index', 'a' => $from, 'params' => ['get' => $get]];} else {- $url_redirect = array('c' => 'index', 'a' => $from);+ $url_redirect = ['c' => 'index', 'a' => $from];}break;default:- $url_redirect = array('c' => 'subscription', 'params' => array('id' => $id));+ $url_redirect = ['c' => 'subscription', 'params' => ['id' => $id]];}if ($values['url'] != '' && $feedDAO->updateFeed($id, $values) !== false) {@@ -346,7 +346,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {invalidateHttpCache();- $url_redirect = array('c' => 'subscription', 'params' => array('id' => $id, 'type' => 'category'));+ $url_redirect = ['c' => 'subscription', 'params' => ['id' => $id, 'type' => 'category']];if (false !== $categoryDAO->updateCategory($id, $values)) {Minz_Request::good(_t('feedback.sub.category.updated'), $url_redirect);} else {diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.phpindex eb259df12..68ef36111 100644--- a/app/Controllers/tagController.php+++ b/app/Controllers/tagController.php@@ -45,7 +45,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {$tagDAO->tagEntry($existing_tag->id(), $id_entry, $checked);} else {//Create new tag- $id_tag = $tagDAO->addTag(array('name' => $name_tag));+ $id_tag = $tagDAO->addTag(['name' => $name_tag]);}}if ($id_tag != false) {@@ -56,10 +56,10 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {Minz_Error::error(405);}if (!$this->ajax) {- Minz_Request::forward(array(+ Minz_Request::forward(['c' => 'index','a' => 'index',- ), true);+ ], true);}}@@ -74,10 +74,10 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {Minz_Error::error(405);}if (!$this->ajax) {- Minz_Request::forward(array(+ Minz_Request::forward(['c' => 'tag','a' => 'index',- ), true);+ ], true);}}@@ -107,7 +107,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {/*** @throws Minz_ConfigurationNamespaceException- * @throws Minz_PDOConnectionException+ * @throws Minz_PDOConnectionException|JsonException*/public function renameAction(): void {if (!Minz_Request::isPost()) {diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.phpindex 241184090..6d9249771 100644--- a/app/Controllers/updateController.php+++ b/app/Controllers/updateController.php@@ -142,17 +142,17 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {}if (touch(FRESHRSS_PATH . '/index.html')) {$this->view->update_to_apply = true;- $this->view->message = array(+ $this->view->message = ['status' => 'good','title' => _t('gen.short.ok'),'body' => _t('feedback.update.can_apply', $version),- );+ ];} else {- $this->view->message = array(+ $this->view->message = ['status' => 'bad','title' => _t('gen.short.damn'),'body' => _t('feedback.update.file_is_nok', $version, FRESHRSS_PATH),- );+ ];}}}@@ -174,7 +174,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {// There is already an update file to apply: we don’t need to check// the webserver!// Or if already check during the last hour, do nothing.- Minz_Request::forward(array('c' => 'update'), true);+ Minz_Request::forward(['c' => 'update'], true);return;}@@ -185,10 +185,10 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {if (self::hasGitUpdate()) {$version = self::getCurrentGitBranch();} else {- $this->view->message = array(+ $this->view->message = ['status' => 'latest',- 'body' => _t('feedback.update.none')- );+ 'body' => _t('feedback.update.none'),+ ];@touch(join_path(DATA_PATH, self::LASTUPDATEFILE));return;}@@ -219,20 +219,20 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {'Error during update (HTTP code ' . $curlGetinfo . '): ' . $curlError);- $this->view->message = array(+ $this->view->message = ['status' => 'bad',- 'body' => _t('feedback.update.server_not_found', $auto_update_url)- );+ 'body' => _t('feedback.update.server_not_found', $auto_update_url),+ ];return;}$res_array = explode("\n", (string)$result, 2);$status = $res_array[0];if (strpos($status, 'UPDATE') !== 0) {- $this->view->message = array(+ $this->view->message = ['status' => 'latest',- 'body' => _t('feedback.update.none')- );+ 'body' => _t('feedback.update.none'),+ ];@touch(join_path(DATA_PATH, self::LASTUPDATEFILE));return;}@@ -246,18 +246,18 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {if (file_put_contents(UPDATE_FILENAME, $script) !== false) {@file_put_contents(join_path(DATA_PATH, self::LASTUPDATEFILE), $version);- Minz_Request::forward(array('c' => 'update'), true);+ Minz_Request::forward(['c' => 'update'], true);} else {- $this->view->message = array(+ $this->view->message = ['status' => 'bad',- 'body' => _t('feedback.update.error', 'Cannot save the update script')- );+ 'body' => _t('feedback.update.error', 'Cannot save the update script'),+ ];}}public function applyAction(): void {if (FreshRSS_Context::$system_conf->disable_update || !file_exists(UPDATE_FILENAME) || !touch(FRESHRSS_PATH . '/index.html')) {- Minz_Request::forward(array('c' => 'update'), true);+ Minz_Request::forward(['c' => 'update'], true);}if (Minz_Request::paramBoolean('post_conf')) {@@ -305,11 +305,11 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {}if ($res === true) {- Minz_Request::forward(array(+ Minz_Request::forward(['c' => 'update','a' => 'apply',- 'params' => array('post_conf' => '1')- ), true);+ 'params' => ['post_conf' => '1'],+ ], true);} else {Minz_Log::error(_t('feedback.update.error', $res));Minz_Request::bad(_t('feedback.update.error', $res), [ 'c' => 'update', 'a' => 'index' ]);diff --git a/app/Controllers/userController.php b/app/Controllers/userController.phpindex 90eb44800..aa5682e26 100644--- a/app/Controllers/userController.php+++ b/app/Controllers/userController.php@@ -8,7 +8,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {* The username is also used as folder name, file name, and part of SQL table name.* '_' is a reserved internal username.*/- const USERNAME_PATTERN = '([0-9a-zA-Z_][0-9a-zA-Z_.@-]{1,38}|[0-9a-zA-Z])';+ public const USERNAME_PATTERN = '([0-9a-zA-Z_][0-9a-zA-Z_.@-]{1,38}|[0-9a-zA-Z])';public static function checkUsername(string $username): bool {return preg_match('/^' . self::USERNAME_PATTERN . '$/', $username) === 1;@@ -69,12 +69,12 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {if ($ok) {$isSelfUpdate = Minz_User::name() === $username;if ($passwordPlain == '' || !$isSelfUpdate) {- Minz_Request::good(_t('feedback.user.updated', $username), array('c' => 'user', 'a' => 'manage'));+ Minz_Request::good(_t('feedback.user.updated', $username), ['c' => 'user', 'a' => 'manage']);} else {- Minz_Request::good(_t('feedback.profile.updated'), array('c' => 'index', 'a' => 'index'));+ Minz_Request::good(_t('feedback.profile.updated'), ['c' => 'index', 'a' => 'index']);}} else {- Minz_Request::bad(_t('feedback.user.updated.error', $username), [ 'c' => 'user', 'a' => 'manage' ]);+ Minz_Request::bad(_t('feedback.user.updated.error', $username), ['c' => 'user', 'a' => 'manage']);}}}@@ -111,14 +111,14 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {if ($system_conf->force_email_validation && empty($email)) {Minz_Request::bad(_t('user.email.feedback.required'),- array('c' => 'user', 'a' => 'profile')+ ['c' => 'user', 'a' => 'profile']);}if (!empty($email) && !validateEmailAddress($email)) {Minz_Request::bad(_t('user.email.feedback.invalid'),- array('c' => 'user', 'a' => 'profile')+ ['c' => 'user', 'a' => 'profile']);}@@ -135,14 +135,14 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {if ($ok) {if ($system_conf->force_email_validation && $email !== $old_email) {- Minz_Request::good(_t('feedback.profile.updated'), array('c' => 'user', 'a' => 'validateEmail'));+ Minz_Request::good(_t('feedback.profile.updated'), ['c' => 'user', 'a' => 'validateEmail']);} elseif ($passwordPlain == '') {- Minz_Request::good(_t('feedback.profile.updated'), array('c' => 'user', 'a' => 'profile'));+ Minz_Request::good(_t('feedback.profile.updated'), ['c' => 'user', 'a' => 'profile']);} else {- Minz_Request::good(_t('feedback.profile.updated'), array('c' => 'index', 'a' => 'index'));+ Minz_Request::good(_t('feedback.profile.updated'), ['c' => 'index', 'a' => 'index']);}} else {- Minz_Request::bad(_t('feedback.profile.error'), [ 'c' => 'user', 'a' => 'profile' ]);+ Minz_Request::bad(_t('feedback.profile.error'), ['c' => 'user', 'a' => 'profile']);}}}@@ -441,7 +441,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {if ($user_config->email_validation_token === '') {Minz_Request::good(_t('user.email.validation.feedback.unnecessary'),- array('c' => 'index', 'a' => 'index')+ ['c' => 'index', 'a' => 'index']);}@@ -449,7 +449,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {if ($user_config->email_validation_token !== $token) {Minz_Request::bad(_t('user.email.validation.feedback.wrong_token'),- array('c' => 'user', 'a' => 'validateEmail')+ ['c' => 'user', 'a' => 'validateEmail']);}@@ -457,12 +457,12 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {if ($user_config->save()) {Minz_Request::good(_t('user.email.validation.feedback.ok'),- array('c' => 'index', 'a' => 'index')+ ['c' => 'index', 'a' => 'index']);} else {Minz_Request::bad(_t('user.email.validation.feedback.error'),- array('c' => 'user', 'a' => 'validateEmail')+ ['c' => 'user', 'a' => 'validateEmail']);}}@@ -491,16 +491,16 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {$user_config = FreshRSS_Context::$user_conf;if ($user_config->email_validation_token === '') {- Minz_Request::forward(array(+ Minz_Request::forward(['c' => 'index','a' => 'index',- ), true);+ ], true);}$mailer = new FreshRSS_User_Mailer();$ok = $mailer->send_email_need_validation($username, $user_config);- $redirect_url = array('c' => 'user', 'a' => 'validateEmail');+ $redirect_url = ['c' => 'user', 'a' => 'validateEmail'];if ($ok) {Minz_Request::good(_t('user.email.validation.feedback.email_sent'),@@ -549,7 +549,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {}if ($ok && $self_deletion) {FreshRSS_Auth::removeAccess();- $redirect_url = array('c' => 'index', 'a' => 'index');+ $redirect_url = ['c' => 'index', 'a' => 'index'];}invalidateHttpCache();@@ -603,10 +603,12 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {FreshRSS_UserDAO::touch($username);if ($ok) {- Minz_Request::good(_t('feedback.user.updated', $username), array('c' => 'user', 'a' => 'manage'));+ Minz_Request::good(_t('feedback.user.updated', $username), ['c' => 'user', 'a' => 'manage']);} else {- Minz_Request::bad(_t('feedback.user.updated.error', $username),- array('c' => 'user', 'a' => 'manage'));+ Minz_Request::bad(+ _t('feedback.user.updated.error', $username),+ ['c' => 'user', 'a' => 'manage']+ );}}diff --git a/app/FreshRSS.php b/app/FreshRSS.phpindex 6e39fe97e..c4f06f63f 100644--- a/app/FreshRSS.php+++ b/app/FreshRSS.php@@ -177,10 +177,10 @@ class FreshRSS extends Minz_FrontController {Minz_Request::is('javascript', 'nonce'));if ($email_not_verified && !$action_is_allowed) {- Minz_Request::forward(array(+ Minz_Request::forward(['c' => 'user','a' => 'validateEmail',- ), true);+ ], true);}}}diff --git a/app/Mailers/UserMailer.php b/app/Mailers/UserMailer.phpindex 6b10ccc74..ad634290d 100644--- a/app/Mailers/UserMailer.php+++ b/app/Mailers/UserMailer.php@@ -19,14 +19,14 @@ class FreshRSS_User_Mailer extends Minz_Mailer {$this->view->username = $username;$this->view->site_title = FreshRSS_Context::$system_conf->title;$this->view->validation_url = Minz_Url::display(- array(+ ['c' => 'user','a' => 'validateEmail',- 'params' => array(+ 'params' => ['username' => $username,- 'token' => $user_config->email_validation_token- )- ),+ 'token' => $user_config->email_validation_token,+ ],+ ],'txt',true);diff --git a/app/Models/Auth.php b/app/Models/Auth.phpindex d048460f6..f3c8b52f9 100644--- a/app/Models/Auth.php+++ b/app/Models/Auth.php@@ -7,7 +7,7 @@ class FreshRSS_Auth {/*** Determines if user is connected.*/- const DEFAULT_COOKIE_DURATION = 7776000;+ public const DEFAULT_COOKIE_DURATION = 7776000;/** @var bool */private static $login_ok = false;@@ -216,7 +216,7 @@ class FreshRSS_Auth {$csrf = Minz_Session::param('csrf');if ($csrf == '') {$salt = FreshRSS_Context::$system_conf->salt;- $csrf = sha1($salt . uniqid('' . mt_rand(), true));+ $csrf = sha1($salt . uniqid('' . random_int(0, mt_getrandmax()), true));Minz_Session::_param('csrf', $csrf);}return $csrf;diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.phpindex d4d8a42ab..5cfcd9342 100644--- a/app/Models/BooleanSearch.php+++ b/app/Models/BooleanSearch.php@@ -8,7 +8,7 @@ class FreshRSS_BooleanSearch {/** @var string */private $raw_input = '';/** @var array<FreshRSS_BooleanSearch|FreshRSS_Search> */- private $searches = array();+ private $searches = [];/*** @phpstan-var 'AND'|'OR'|'AND NOT'@@ -62,6 +62,9 @@ class FreshRSS_BooleanSearch {$fromS = [];$toS = [];foreach ($all_matches as $matches) {+ if (empty($matches['search'])) {+ continue;+ }for ($i = count($matches['search']) - 1; $i >= 0; $i--) {$name = trim($matches['search'][$i]);if (!empty($queries[$name])) {@@ -97,9 +100,12 @@ class FreshRSS_BooleanSearch {$fromS = [];$toS = [];foreach ($all_matches as $matches) {+ if (empty($matches['search'])) {+ continue;+ }for ($i = count($matches['search']) - 1; $i >= 0; $i--) {// Index starting from 1- $id = intval(trim($matches['search'][$i])) - 1;+ $id = (int)(trim($matches['search'][$i])) - 1;if (!empty($queries[$id])) {$fromS[] = $matches[0][$i];$toS[] = '(' . trim($queries[$id]->getSearch()) . ')';diff --git a/app/Models/Category.php b/app/Models/Category.phpindex c9c919e4a..1adf81f92 100644--- a/app/Models/Category.php+++ b/app/Models/Category.php@@ -156,7 +156,7 @@ class FreshRSS_Category extends Minz_Model {/** @param array<FreshRSS_Feed>|FreshRSS_Feed $values */public function _feeds($values): void {if (!is_array($values)) {- $values = array($values);+ $values = [$values];}$this->feeds = $values;diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.phpindex ccfd5c08a..d617fd672 100644--- a/app/Models/CategoryDAO.php+++ b/app/Models/CategoryDAO.php@@ -2,7 +2,7 @@class FreshRSS_CategoryDAO extends Minz_ModelPdo {- const DEFAULTCATEGORYID = 1;+ public const DEFAULTCATEGORYID = 1;public function resetDefaultCategoryName(): bool {//FreshRSS 1.15.1@@ -51,7 +51,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {$attributes = [];}if ($keepHistory > 0) {- $attributes['archiving']['keep_min'] = intval($keepHistory);+ $attributes['archiving']['keep_min'] = (int)$keepHistory;} elseif ($keepHistory == -1) { //Infinite$attributes['archiving']['keep_period'] = false;$attributes['archiving']['keep_max'] = false;@@ -100,6 +100,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo {/*** @param array{'name':string,'id'?:int,'kind'?:int,'lastUpdate'?:int,'error'?:int|bool,'attributes'?:string|array<string,mixed>} $valuesTmp* @return int|false+ * @throws JsonException*/public function addCategory(array $valuesTmp) {// TRIM() to provide a type hint as text@@ -115,12 +116,12 @@ SQL;if (!isset($valuesTmp['attributes'])) {$valuesTmp['attributes'] = [];}- $values = array(+ $values = [$valuesTmp['kind'] ?? FreshRSS_Category::KIND_NORMAL,$valuesTmp['name'],is_string($valuesTmp['attributes']) ? $valuesTmp['attributes'] : json_encode($valuesTmp['attributes'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),$valuesTmp['name'],- );+ ];if ($stm !== false && $stm->execute($values) && $stm->rowCount() > 0) {$catId = $this->pdo->lastInsertId('`_category_id_seq`');@@ -153,6 +154,7 @@ SQL;/*** @param array{'name':string,'kind':int,'attributes'?:string|array<string,mixed>} $valuesTmp* @return int|false+ * @throws JsonException*/public function updateCategory(int $id, array $valuesTmp) {// No tag of the same name@@ -166,13 +168,13 @@ SQL;if (empty($valuesTmp['attributes'])) {$valuesTmp['attributes'] = [];}- $values = array(+ $values = [$valuesTmp['name'],$valuesTmp['kind'] ?? FreshRSS_Category::KIND_NORMAL,is_string($valuesTmp['attributes']) ? $valuesTmp['attributes'] : json_encode($valuesTmp['attributes'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),$id,$valuesTmp['name'],- );+ ];if ($stm !== false && $stm->execute($values)) {return $stm->rowCount();@@ -358,10 +360,10 @@ SQL;}$stm = $this->pdo->prepare($sql);- $values = array(+ $values = [$cat->id(),$cat->name(),- );+ ];if ($stm !== false && $stm->execute($values)) {$catId = $this->pdo->lastInsertId('`_category_id_seq`');@@ -482,7 +484,7 @@ SQL;$cat->_kind($dao['kind']);$cat->_lastUpdate($dao['lastUpdate'] ?? 0);$cat->_error($dao['error'] ?? 0);- $cat->_attributes('', isset($dao['attributes']) ? $dao['attributes'] : '');+ $cat->_attributes('', $dao['attributes'] ?? '');$list[] = $cat;}diff --git a/app/Models/Context.php b/app/Models/Context.phpindex c10119d7d..2dc49e844 100644--- a/app/Models/Context.php+++ b/app/Models/Context.php@@ -18,11 +18,11 @@ final class FreshRSS_Context {/*** @var array<int,FreshRSS_Category>*/- public static $categories = array();+ public static $categories = [];/*** @var array<int,FreshRSS_Tag>*/- public static $tags = array();+ public static $tags = [];/*** @var string*/@@ -261,19 +261,19 @@ final class FreshRSS_Context {return $asArray ? ['s', true] : 's';} elseif (self::$current_get['feed']) {if ($asArray) {- return array('f', self::$current_get['feed']);+ return ['f', self::$current_get['feed']];} else {return 'f_' . self::$current_get['feed'];}} elseif (self::$current_get['category']) {if ($asArray) {- return array('c', self::$current_get['category']);+ return ['c', self::$current_get['category']];} else {return 'c_' . self::$current_get['category'];}} elseif (self::$current_get['tag']) {if ($asArray) {- return array('t', self::$current_get['tag']);+ return ['t', self::$current_get['tag']];} else {return 't_' . self::$current_get['tag'];}diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.phpindex edbfd72cc..ea12bab8e 100644--- a/app/Models/DatabaseDAO.php+++ b/app/Models/DatabaseDAO.php@@ -6,18 +6,18 @@class FreshRSS_DatabaseDAO extends Minz_ModelPdo {//MySQL error codes- const ER_BAD_FIELD_ERROR = '42S22';- const ER_BAD_TABLE_ERROR = '42S02';- const ER_DATA_TOO_LONG = '1406';+ public const ER_BAD_FIELD_ERROR = '42S22';+ public const ER_BAD_TABLE_ERROR = '42S02';+ public const ER_DATA_TOO_LONG = '1406';/*** Based on SQLite SQLITE_MAX_VARIABLE_NUMBER*/- const MAX_VARIABLE_NUMBER = 998;+ public const MAX_VARIABLE_NUMBER = 998;//MySQL InnoDB maximum index length for UTF8MB4//https://dev.mysql.com/doc/refman/8.0/en/innodb-restrictions.html- const LENGTH_INDEX_UNICODE = 191;+ public const LENGTH_INDEX_UNICODE = 191;public function create(): string {require(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php');@@ -53,14 +53,14 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {return false;}- $tables = array(+ $tables = [$this->pdo->prefix() . 'category' => false,$this->pdo->prefix() . 'feed' => false,$this->pdo->prefix() . 'entry' => false,$this->pdo->prefix() . 'entrytmp' => false,$this->pdo->prefix() . 'tag' => false,$this->pdo->prefix() . 'entrytag' => false,- );+ ];foreach ($res as $value) {$tables[array_pop($value)] = true;}@@ -90,43 +90,59 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {}public function categoryIsCorrect(): bool {- return $this->checkTable('category', array(- 'id', 'name',- ));+ return $this->checkTable('category', ['id', 'name']);}public function feedIsCorrect(): bool {- return $this->checkTable('feed', array(- 'id', 'url', 'category', 'name', 'website', 'description', 'lastUpdate',- 'priority', 'pathEntries', 'httpAuth', 'error', 'ttl', 'attributes',- 'cache_nbEntries', 'cache_nbUnreads',- ));+ return $this->checkTable('feed', [+ 'id',+ 'url',+ 'category',+ 'name',+ 'website',+ 'description',+ 'lastUpdate',+ 'priority',+ 'pathEntries',+ 'httpAuth',+ 'error',+ 'ttl',+ 'attributes',+ 'cache_nbEntries',+ 'cache_nbUnreads',+ ]);}public function entryIsCorrect(): bool {- return $this->checkTable('entry', array(- 'id', 'guid', 'title', 'author', 'content_bin', 'link', 'date', 'lastSeen', 'hash', 'is_read',- 'is_favorite', 'id_feed', 'tags',- ));+ return $this->checkTable('entry', [+ 'id',+ 'guid',+ 'title',+ 'author',+ 'content_bin',+ 'link',+ 'date',+ 'lastSeen',+ 'hash',+ 'is_read',+ 'is_favorite',+ 'id_feed',+ 'tags',+ ]);}public function entrytmpIsCorrect(): bool {- return $this->checkTable('entrytmp', array(- 'id', 'guid', 'title', 'author', 'content_bin', 'link', 'date', 'lastSeen', 'hash', 'is_read',- 'is_favorite', 'id_feed', 'tags',- ));+ return $this->checkTable('entrytmp', [+ 'id', 'guid', 'title', 'author', 'content_bin', 'link', 'date', 'lastSeen', 'hash', 'is_read', 'is_favorite', 'id_feed', 'tags'+ ]);}public function tagIsCorrect(): bool {- return $this->checkTable('tag', array(- 'id', 'name', 'attributes',- ));+ return $this->checkTable('tag', ['id', 'name', 'attributes']);}public function entrytagIsCorrect(): bool {- return $this->checkTable('entrytag', array(- 'id_tag', 'id_entry',- ));+ return $this->checkTable('entrytag', ['id_tag', 'id_entry']);}/**@@ -147,7 +163,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {* @return array<array<string,string|int|bool|null>>*/public function listDaoToSchema(array $listDAO): array {- $list = array();+ $list = [];foreach ($listDAO as $dao) {$list[] = $this->daoToSchema($dao);@@ -174,7 +190,7 @@ SQL;public function optimize(): bool {$ok = true;- $tables = array('category', 'feed', 'entry', 'entrytmp', 'tag', 'entrytag');+ $tables = ['category', 'feed', 'entry', 'entrytmp', 'tag', 'entrytag'];foreach ($tables as $table) {$sql = 'OPTIMIZE TABLE `_' . $table . '`'; //MySQL@@ -219,8 +235,8 @@ SQL;return false;}- const SQLITE_EXPORT = 1;- const SQLITE_IMPORT = 2;+ public const SQLITE_EXPORT = 1;+ public const SQLITE_IMPORT = 2;public function dbCopy(string $filename, int $mode, bool $clearFirst = false): bool {if (!extension_loaded('pdo_sqlite')) {diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.phpindex 29b16e3dc..7976d5e14 100644--- a/app/Models/DatabaseDAOPGSQL.php+++ b/app/Models/DatabaseDAOPGSQL.php@@ -6,8 +6,8 @@class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAOSQLite {//PostgreSQL error codes- const UNDEFINED_COLUMN = '42703';- const UNDEFINED_TABLE = '42P01';+ public const UNDEFINED_COLUMN = '42703';+ public const UNDEFINED_TABLE = '42P01';public function tablesAreCorrect(): bool {$db = FreshRSS_Context::$system_conf->db;@@ -71,13 +71,13 @@ pg_total_relation_size('`{$this->pdo->prefix()}entrytag`')SQL;$res = $this->fetchColumn($sql, 0);}- return intval($res[0] ?? -1);+ return (int)($res[0] ?? -1);}public function optimize(): bool {$ok = true;- $tables = array('category', 'feed', 'entry', 'entrytmp', 'tag', 'entrytag');+ $tables = ['category', 'feed', 'entry', 'entrytmp', 'tag', 'entrytag'];foreach ($tables as $table) {$sql = 'VACUUM `_' . $table . '`';diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.phpindex 5168f5e19..261932867 100644--- a/app/Models/DatabaseDAOSQLite.php+++ b/app/Models/DatabaseDAOSQLite.php@@ -13,14 +13,14 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {return false;}- $tables = array(+ $tables = [$this->pdo->prefix() . 'category' => false,$this->pdo->prefix() . 'feed' => false,$this->pdo->prefix() . 'entry' => false,$this->pdo->prefix() . 'entrytmp' => false,$this->pdo->prefix() . 'tag' => false,$this->pdo->prefix() . 'entrytag' => false,- );+ ];foreach ($res as $value) {$tables[$value['name']] = true;}@@ -36,17 +36,15 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {}public function entryIsCorrect(): bool {- return $this->checkTable('entry', array(- 'id', 'guid', 'title', 'author', 'content', 'link', 'date', 'lastSeen', 'hash', 'is_read',- 'is_favorite', 'id_feed', 'tags',- ));+ return $this->checkTable('entry', [+ 'id', 'guid', 'title', 'author', 'content', 'link', 'date', 'lastSeen', 'hash', 'is_read', 'is_favorite', 'id_feed', 'tags',+ ]);}public function entrytmpIsCorrect(): bool {- return $this->checkTable('entrytmp', array(- 'id', 'guid', 'title', 'author', 'content', 'link', 'date', 'lastSeen', 'hash', 'is_read',- 'is_favorite', 'id_feed', 'tags',- ));+ return $this->checkTable('entrytmp', [+ 'id', 'guid', 'title', 'author', 'content', 'link', 'date', 'lastSeen', 'hash', 'is_read', 'is_favorite', 'id_feed', 'tags'+ ]);}/**diff --git a/app/Models/Entry.php b/app/Models/Entry.phpindex 86b3899d8..7e10367fa 100644--- a/app/Models/Entry.php+++ b/app/Models/Entry.php@@ -1,11 +1,11 @@<?phpclass FreshRSS_Entry extends Minz_Model {- const STATE_READ = 1;- const STATE_NOT_READ = 2;- const STATE_ALL = 3;- const STATE_FAVORITE = 4;- const STATE_NOT_FAVORITE = 8;+ public const STATE_READ = 1;+ public const STATE_NOT_READ = 2;+ public const STATE_ALL = 3;+ public const STATE_FAVORITE = 4;+ public const STATE_NOT_FAVORITE = 8;/** @var string */private $id = '0';@@ -143,7 +143,7 @@ class FreshRSS_Entry extends Minz_Model {$medium = $enclosure['medium'] ?? '';$mime = $enclosure['type'] ?? '';- return $elink != '' && $medium === 'image' || strpos($mime, 'image') === 0 ||+ return ($elink != '' && $medium === 'image') || strpos($mime, 'image') === 0 ||($mime == '' && $length == 0 && preg_match('/[.](avif|gif|jpe?g|png|svg|webp)$/i', $elink));}@@ -800,7 +800,7 @@ HTML;* 'hash':string,'is_read':?bool,'is_favorite':?bool,'id_feed':int,'tags':string,'attributes':array<string,mixed>}*/public function toArray(): array {- return array(+ return ['id' => $this->id(),'guid' => $this->guid(),'title' => $this->title(),@@ -815,7 +815,7 @@ HTML;'id_feed' => $this->feedId(),'tags' => $this->tags(true),'attributes' => $this->attributes(),- );+ ];}/**@@ -833,7 +833,7 @@ HTML;* Some clients (tested with News+) would fail if sending too long item content* @var int*/- const API_MAX_COMPAT_CONTENT_LENGTH = 500000;+ public const API_MAX_COMPAT_CONTENT_LENGTH = 500000;/*** N.B.: To avoid expensive lookups, ensure to set `$entry->_feed($feed)` before calling this function.diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.phpindex f9bdd7be2..e8a531ec0 100644--- a/app/Models/EntryDAO.php+++ b/app/Models/EntryDAO.php@@ -313,7 +313,7 @@ SQL;*/public function markFavorite($ids, bool $is_favorite = true) {if (!is_array($ids)) {- $ids = array($ids);+ $ids = [$ids];}if (count($ids) < 1) {return 0;@@ -331,7 +331,7 @@ SQL;$sql = 'UPDATE `_entry` '. 'SET is_favorite=? '. 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)';- $values = array($is_favorite ? 1 : 0);+ $values = [$is_favorite ? 1 : 0];$values = array_merge($values, $ids);$stm = $this->pdo->prepare($sql);if ($stm !== false && $stm->execute($values)) {@@ -361,7 +361,7 @@ UPDATE `_feed` f LEFT OUTER JOIN (SET f.`cache_nbUnreads` = COALESCE(x.nbUnreads, 0)SQL;$hasWhere = false;- $values = array();+ $values = [];if ($feedId != null) {$sql .= ' WHERE';$hasWhere = true;@@ -419,7 +419,7 @@ SQL;$sql = 'UPDATE `_entry` '. 'SET is_read=? '. 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)';- $values = array($is_read ? 1 : 0);+ $values = [$is_read ? 1 : 0];$values = array_merge($values, $ids);$stm = $this->pdo->prepare($sql);if (!($stm && $stm->execute($values))) {@@ -437,7 +437,7 @@ SQL;. 'SET e.is_read=?,'. 'f.`cache_nbUnreads`=f.`cache_nbUnreads`' . ($is_read ? '-' : '+') . '1 '. 'WHERE e.id=? AND e.is_read=?';- $values = array($is_read ? 1 : 0, $ids, $is_read ? 0 : 1);+ $values = [$is_read ? 1 : 0, $ids, $is_read ? 0 : 1];$stm = $this->pdo->prepare($sql);if ($stm !== false && $stm->execute($values)) {return $stm->rowCount();@@ -484,9 +484,9 @@ SQL;} elseif ($priorityMin >= 0) {$sql .= ' AND f.priority > ' . intval($priorityMin);}- $values = array($is_read ? 1 : 0, $is_read ? 1 : 0, $idMax);+ $values = [$is_read ? 1 : 0, $is_read ? 1 : 0, $idMax];- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state);+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);$stm = $this->pdo->prepare($sql . $search);if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {@@ -522,9 +522,9 @@ SQL;$sql = 'UPDATE `_entry` e INNER JOIN `_feed` f ON e.id_feed=f.id '. 'SET e.is_read=? '. 'WHERE f.category=? AND e.is_read <> ? AND e.id <= ?';- $values = array($is_read ? 1 : 0, $id, $is_read ? 1 : 0, $idMax);+ $values = [$is_read ? 1 : 0, $id, $is_read ? 1 : 0, $idMax];- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state);+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);$stm = $this->pdo->prepare($sql . $search);if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {@@ -564,9 +564,9 @@ SQL;$sql = 'UPDATE `_entry` '. 'SET is_read=? '. 'WHERE id_feed=? AND is_read <> ? AND id <= ?';- $values = array($is_read ? 1 : 0, $id_feed, $is_read ? 1 : 0, $idMax);+ $values = [$is_read ? 1 : 0, $id_feed, $is_read ? 1 : 0, $idMax];- list($searchValues, $search) = $this->sqlListEntriesWhere('', $filters, $state);+ [$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);$stm = $this->pdo->prepare($sql . $search);if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {@@ -617,14 +617,14 @@ SQL;. 'WHERE '. ($id == 0 ? '' : 'et.id_tag = ? AND '). 'e.is_read <> ? AND e.id <= ?';- $values = array($is_read ? 1 : 0);+ $values = [$is_read ? 1 : 0];if ($id != 0) {$values[] = $id;}$values[] = $is_read ? 1 : 0;$values[] = $idMax;- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state);+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);$stm = $this->pdo->prepare($sql . $search);if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {@@ -769,7 +769,7 @@ SQL;}if ($filter instanceof FreshRSS_BooleanSearch) {// BooleanSearches are combined by AND (default) or OR (special case) operator and are recursive- list($filterValues, $filterSearch) = self::sqlBooleanSearch($alias, $filter, $level + 1);+ [$filterValues, $filterSearch] = self::sqlBooleanSearch($alias, $filter, $level + 1);$filterSearch = trim($filterSearch);if ($filterSearch !== '') {@@ -1016,7 +1016,7 @@ SQL;int $state = FreshRSS_Entry::STATE_ALL,string $order = 'DESC', string $firstId = '', int $date_min = 0) {$search = ' ';- $values = array();+ $values = [];if ($state & FreshRSS_Entry::STATE_NOT_READ) {if (!($state & FreshRSS_Entry::STATE_READ)) {$search .= 'AND ' . $alias . 'is_read=0 ';@@ -1048,14 +1048,14 @@ SQL;$values[] = $date_min . '000000';}if ($filters && count($filters->searches()) > 0) {- list($filterValues, $filterSearch) = self::sqlBooleanSearch($alias, $filters);+ [$filterValues, $filterSearch] = self::sqlBooleanSearch($alias, $filters);$filterSearch = trim($filterSearch);if ($filterSearch !== '') {$search .= 'AND (' . $filterSearch . ') ';$values = array_merge($values, $filterValues);}}- return array($values, $search);+ return [$values, $search];}/**@@ -1071,7 +1071,7 @@ SQL;$state = FreshRSS_Entry::STATE_ALL;}$where = '';- $values = array();+ $values = [];switch ($type) {case 'a': //All PRIORITY_MAIN_STREAM$where .= 'f.priority > ' . FreshRSS_Feed::PRIORITY_NORMAL . ' ';@@ -1109,10 +1109,9 @@ SQL;throw new FreshRSS_EntriesGetter_Exception('Bad type in Entry->listByType: [' . $type . ']!');}- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state, $order, $firstId, $date_min);+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state, $order, $firstId, $date_min);- return array(array_merge($values, $searchValues),- 'SELECT '+ return [array_merge($values, $searchValues), 'SELECT '. ($type === 'T' ? 'DISTINCT ' : ''). 'e.id FROM `_entry` e '. 'INNER JOIN `_feed` f ON e.id_feed = f.id '@@ -1120,7 +1119,7 @@ SQL;. 'WHERE ' . $where. $search. 'ORDER BY e.id ' . $order- . ($limit > 0 ? ' LIMIT ' . intval($limit) : '')); //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/+ . ($limit > 0 ? ' LIMIT ' . intval($limit) : '')]; //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/}/**@@ -1257,7 +1256,7 @@ SQL;$sql = 'SELECT guid, ' . static::sqlHexEncode('hash') .' AS hex_hash FROM `_entry` WHERE id_feed=? AND guid IN (' . str_repeat('?,', count($guids) - 1). '?)';$stm = $this->pdo->prepare($sql);- $values = array($id_feed);+ $values = [$id_feed];$values = array_merge($values, $guids);if ($stm !== false && $stm->execute($values)) {$rows = $stm->fetchAll(PDO::FETCH_ASSOC);@@ -1297,7 +1296,7 @@ SQL;if ($mtime <= 0) {$mtime = time();}- $values = array($mtime, $id_feed);+ $values = [$mtime, $id_feed];$values = array_merge($values, $guids);if ($stm !== false && $stm->execute($values)) {return $stm->rowCount();diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.phpindex 58a61828b..6abf31a5b 100644--- a/app/Models/EntryDAOSQLite.php+++ b/app/Models/EntryDAOSQLite.php@@ -86,7 +86,7 @@ SET `cache_nbUnreads`=(WHERE e.id_feed=`_feed`.id AND e.is_read=0)SQL;$hasWhere = false;- $values = array();+ $values = [];if ($feedId != null) {$sql .= ' WHERE';$hasWhere = true;@@ -135,7 +135,7 @@ SQL;} else {$this->pdo->beginTransaction();$sql = 'UPDATE `_entry` SET is_read=? WHERE id=? AND is_read=?';- $values = array($is_read ? 1 : 0, $ids, $is_read ? 0 : 1);+ $values = [$is_read ? 1 : 0, $ids, $is_read ? 0 : 1];$stm = $this->pdo->prepare($sql);if (!($stm && $stm->execute($values))) {$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();@@ -147,7 +147,7 @@ SQL;if ($affected > 0) {$sql = 'UPDATE `_feed` SET `cache_nbUnreads`=`cache_nbUnreads`' . ($is_read ? '-' : '+') . '1 '. 'WHERE id=(SELECT e.id_feed FROM `_entry` e WHERE e.id=?)';- $values = array($ids);+ $values = [$ids];$stm = $this->pdo->prepare($sql);if (!($stm && $stm->execute($values))) {$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();@@ -196,9 +196,9 @@ SQL;} elseif ($priorityMin >= 0) {$sql .= ' AND id_feed IN (SELECT f.id FROM `_feed` f WHERE f.priority > ' . intval($priorityMin) . ')';}- $values = array($is_read ? 1 : 0, $is_read ? 1 : 0, $idMax);+ $values = [$is_read ? 1 : 0, $is_read ? 1 : 0, $idMax];- list($searchValues, $search) = $this->sqlListEntriesWhere('', $filters, $state);+ [$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);$stm = $this->pdo->prepare($sql . $search);if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {@@ -235,9 +235,9 @@ SQL;. 'SET is_read = ? '. 'WHERE is_read <> ? AND id <= ? AND '. 'id_feed IN (SELECT f.id FROM `_feed` f WHERE f.category=?)';- $values = array($is_read ? 1 : 0, $is_read ? 1 : 0, $idMax, $id);+ $values = [$is_read ? 1 : 0, $is_read ? 1 : 0, $idMax, $id];- list($searchValues, $search) = $this->sqlListEntriesWhere('', $filters, $state);+ [$searchValues, $search] = $this->sqlListEntriesWhere('', $filters, $state);$stm = $this->pdo->prepare($sql . $search);if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {@@ -271,12 +271,12 @@ SQL;. 'id IN (SELECT et.id_entry FROM `_entrytag` et '. ($id == 0 ? '' : 'WHERE et.id_tag = ?'). ')';- $values = array($is_read ? 1 : 0, $is_read ? 1 : 0, $idMax);+ $values = [$is_read ? 1 : 0, $is_read ? 1 : 0, $idMax];if ($id != 0) {$values[] = $id;}- list($searchValues, $search) = $this->sqlListEntriesWhere('e.', $filters, $state);+ [$searchValues, $search] = $this->sqlListEntriesWhere('e.', $filters, $state);$stm = $this->pdo->prepare($sql . $search);if (!($stm && $stm->execute(array_merge($values, $searchValues)))) {diff --git a/app/Models/Feed.php b/app/Models/Feed.phpindex 9b9910bff..2baee9e0d 100644--- a/app/Models/Feed.php+++ b/app/Models/Feed.php@@ -6,36 +6,36 @@ class FreshRSS_Feed extends Minz_Model {* Normal RSS or Atom feed* @var int*/- const KIND_RSS = 0;+ public const KIND_RSS = 0;/*** Invalid RSS or Atom feed* @var int*/- const KIND_RSS_FORCED = 2;+ public const KIND_RSS_FORCED = 2;/*** Normal HTML with XPath scraping* @var int*/- const KIND_HTML_XPATH = 10;+ public const KIND_HTML_XPATH = 10;/*** Normal XML with XPath scraping* @var int*/- const KIND_XML_XPATH = 15;+ public const KIND_XML_XPATH = 15;/*** Normal JSON with XPath scraping* @var int*/- const KIND_JSON_XPATH = 20;+ public const KIND_JSON_XPATH = 20;- const PRIORITY_MAIN_STREAM = 10;- const PRIORITY_NORMAL = 0;- const PRIORITY_ARCHIVED = -10;+ public const PRIORITY_MAIN_STREAM = 10;+ public const PRIORITY_NORMAL = 0;+ public const PRIORITY_ARCHIVED = -10;- const TTL_DEFAULT = 0;+ public const TTL_DEFAULT = 0;- const ARCHIVING_RETENTION_COUNT_LIMIT = 10000;- const ARCHIVING_RETENTION_PERIOD = 'P3M';+ public const ARCHIVING_RETENTION_COUNT_LIMIT = 10000;+ public const ARCHIVING_RETENTION_PERIOD = 'P3M';/** @var int */private $id = 0;@@ -183,10 +183,10 @@ class FreshRSS_Feed extends Minz_Model {$pass = '';}- return array(+ return ['username' => $user,- 'password' => $pass- );+ 'password' => $pass,+ ];}}public function inError(): bool {@@ -422,7 +422,7 @@ class FreshRSS_Feed extends Minz_Model {$subscribe_url = $simplePie->subscribe_url(false);//HTML to HTML-PRE //ENT_COMPAT except '&'- $title = strtr(html_only_entity_decode($simplePie->get_title()), array('<' => '<', '>' => '>', '"' => '"'));+ $title = strtr(html_only_entity_decode($simplePie->get_title()), ['<' => '<', '>' => '>', '"' => '"']);$this->_name($title == '' ? $this->url : $title);$this->_website(html_only_entity_decode($simplePie->get_link()));@@ -546,14 +546,30 @@ class FreshRSS_Feed extends Minz_Model {$attributeEnclosure = ['url' => $elink,];- if ($etitle != '') $attributeEnclosure['title'] = $etitle;- if ($credit != null) $attributeEnclosure['credit'] = $credit->get_name();- if ($description != '') $attributeEnclosure['description'] = $description;- if ($mime != '') $attributeEnclosure['type'] = $mime;- if ($medium != '') $attributeEnclosure['medium'] = $medium;- if ($length != '') $attributeEnclosure['length'] = intval($length);- if ($height != '') $attributeEnclosure['height'] = intval($height);- if ($width != '') $attributeEnclosure['width'] = intval($width);+ if ($etitle != '') {+ $attributeEnclosure['title'] = $etitle;+ }+ if ($credit != null) {+ $attributeEnclosure['credit'] = $credit->get_name();+ }+ if ($description != '') {+ $attributeEnclosure['description'] = $description;+ }+ if ($mime != '') {+ $attributeEnclosure['type'] = $mime;+ }+ if ($medium != '') {+ $attributeEnclosure['medium'] = $medium;+ }+ if ($length != '') {+ $attributeEnclosure['length'] = intval($length);+ }+ if ($height != '') {+ $attributeEnclosure['height'] = intval($height);+ }+ if ($width != '') {+ $attributeEnclosure['width'] = intval($width);+ }if (!empty($enclosure->get_thumbnails())) {foreach ($enclosure->get_thumbnails() as $thumbnail) {@@ -589,7 +605,7 @@ class FreshRSS_Feed extends Minz_Model {$authorNames,$content == '' ? '' : $content,$link == '' ? '' : $link,- $date ? $date : time()+ $date ?: time());$entry->_tags($tags);$entry->_feed($this);@@ -604,6 +620,9 @@ class FreshRSS_Feed extends Minz_Model {}}+ /**+ * @throws FreshRSS_Context_Exception+ */public function loadHtmlXpath(): ?SimplePie {if ($this->url == '') {return null;@@ -615,7 +634,7 @@ class FreshRSS_Feed extends Minz_Model {// Same naming conventions than https://rss-bridge.github.io/rss-bridge/Bridge_API/XPathAbstract.html// https://rss-bridge.github.io/rss-bridge/Bridge_API/BridgeAbstract.html#collectdata- /** @var array<string,string> */+ /** @var array<string,string> $xPathSettings */$xPathSettings = $this->attributes('xpath');$xPathFeedTitle = $xPathSettings['feedTitle'] ?? '';$xPathItem = $xPathSettings['item'] ?? '';@@ -689,7 +708,7 @@ class FreshRSS_Feed extends Minz_Model {$item['content'] = $content;} else {// Typed expression, save as-is- $item['content'] = strval($result);+ $item['content'] = (string)$result;}}@@ -753,6 +772,7 @@ class FreshRSS_Feed extends Minz_Model {/*** Remember to call updateCachedValue($id_feed) or updateCachedValues() just after.* @return int|false the number of lines affected, or false if not applicable+ * @throws JsonException*/public function keepMaxUnread() {$keepMaxUnread = $this->attributes('keep_max_n_unread');@@ -761,8 +781,7 @@ class FreshRSS_Feed extends Minz_Model {}$keepMaxUnread = (int)$keepMaxUnread;if ($keepMaxUnread > 0 && $this->nbNotRead(false) + $this->nbPendingNotRead > $keepMaxUnread) {- $feedDAO = FreshRSS_Factory::createFeedDao();- return $feedDAO->keepMaxUnread($this->id(), max(0, $keepMaxUnread - $this->nbPendingNotRead));+ return FreshRSS_Factory::createFeedDao()->keepMaxUnread($this->id(), max(0, $keepMaxUnread - $this->nbPendingNotRead));}return false;}@@ -865,7 +884,7 @@ class FreshRSS_Feed extends Minz_Model {*/public function filterActions(): array {if (empty($this->filterActions)) {- $this->filterActions = array();+ $this->filterActions = [];$filters = $this->attributes('filters');if (is_array($filters)) {foreach ($filters as $filter) {@@ -897,9 +916,9 @@ class FreshRSS_Feed extends Minz_Model {public function filtersAction(string $action): array {$action = trim($action);if ($action == '') {- return array();+ return [];}- $filters = array();+ $filters = [];$filterActions = $this->filterActions();for ($i = count($filterActions) - 1; $i >= 0; $i--) {$filterAction = $filterActions[$i];@@ -957,10 +976,10 @@ class FreshRSS_Feed extends Minz_Model {for ($k = count($filters) - 1; $k >= 0; $k --) {$filter = $filters[$k];if ($filter != '') {- $filterAction = FreshRSS_FilterAction::fromJSON(array(- 'search' => $filter,- 'actions' => array($action),- ));+ $filterAction = FreshRSS_FilterAction::fromJSON([+ 'search' => $filter,+ 'actions' => [$action],+ ]);if ($filterAction != null) {$filterActions[] = $filterAction;}@@ -976,7 +995,7 @@ class FreshRSS_Feed extends Minz_Model {//<WebSub>public function pubSubHubbubEnabled(): bool {- $url = $this->selfUrl ? $this->selfUrl : $this->url;+ $url = $this->selfUrl ?: $this->url;$hubFilename = PSHB_PATH . '/feeds/' . sha1($url) . '/!hub.json';if ($hubFile = @file_get_contents($hubFilename)) {$hubJson = json_decode($hubFile, true);@@ -989,10 +1008,10 @@ class FreshRSS_Feed extends Minz_Model {}public function pubSubHubbubError(bool $error = true): bool {- $url = $this->selfUrl ? $this->selfUrl : $this->url;+ $url = $this->selfUrl ?: $this->url;$hubFilename = PSHB_PATH . '/feeds/' . sha1($url) . '/!hub.json';$hubFile = @file_get_contents($hubFilename);- $hubJson = $hubFile ? json_decode($hubFile, true) : array();+ $hubJson = $hubFile ? json_decode($hubFile, true) : [];if (!isset($hubJson['error']) || $hubJson['error'] !== $error) {$hubJson['error'] = $error;file_put_contents($hubFilename, json_encode($hubJson));@@ -1032,10 +1051,10 @@ class FreshRSS_Feed extends Minz_Model {} else {@mkdir($path, 0770, true);$key = sha1($path . FreshRSS_Context::$system_conf->salt);- $hubJson = array(+ $hubJson = ['hub' => $this->hubUrl,'key' => $key,- );+ ];file_put_contents($hubFilename, json_encode($hubJson));@mkdir(PSHB_PATH . '/keys/', 0770, true);file_put_contents(PSHB_PATH . '/keys/' . $key . '.txt', $this->selfUrl);@@ -1054,7 +1073,7 @@ class FreshRSS_Feed extends Minz_Model {//Parameter true to subscribe, false to unsubscribe.public function pubSubHubbubSubscribe(bool $state): bool {if ($state) {- $url = $this->selfUrl ? $this->selfUrl : $this->url;+ $url = $this->selfUrl ?: $this->url;} else {$url = $this->url; //Always use current URL during unsubscribe}@@ -1081,19 +1100,18 @@ class FreshRSS_Feed extends Minz_Model {}$ch = curl_init();curl_setopt_array($ch, [- CURLOPT_URL => $hubJson['hub'],- CURLOPT_RETURNTRANSFER => true,- CURLOPT_POSTFIELDS => http_build_query(array(- 'hub.verify' => 'sync',- 'hub.mode' => $state ? 'subscribe' : 'unsubscribe',- 'hub.topic' => $url,- 'hub.callback' => $callbackUrl,- )),- CURLOPT_USERAGENT => FRESHRSS_USERAGENT,- CURLOPT_MAXREDIRS => 10,- CURLOPT_FOLLOWLOCATION => true,- CURLOPT_ENCODING => '', //Enable all encodings- ]);+ CURLOPT_URL => $hubJson['hub'],+ CURLOPT_RETURNTRANSFER => true,+ CURLOPT_POSTFIELDS => http_build_query([+ 'hub.verify' => 'sync',+ 'hub.mode' => $state ? 'subscribe' : 'unsubscribe',+ 'hub.topic' => $url, 'hub.callback' => $callbackUrl,+ ]),+ CURLOPT_USERAGENT => FRESHRSS_USERAGENT,+ CURLOPT_MAXREDIRS => 10,+ CURLOPT_FOLLOWLOCATION => true,+ CURLOPT_ENCODING => '', //Enable all encodings+ ]);$response = curl_exec($ch);$info = curl_getinfo($ch);diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.phpindex b9295abe0..dc3a33165 100644--- a/app/Models/FeedDAO.php+++ b/app/Models/FeedDAO.php@@ -38,6 +38,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {* @param array{'url':string,'kind':int,'category':int,'name':string,'website':string,'description':string,'lastUpdate':int,'priority'?:int,* 'pathEntries'?:string,'httpAuth':string,'error':int|bool,'ttl'?:int,'attributes'?:string|array<string|mixed>} $valuesTmp* @return int|false+ * @throws JsonException*/public function addFeed(array $valuesTmp) {$sql = 'INSERT INTO `_feed` (url, kind, category, name, website, description, `lastUpdate`, priority, `pathEntries`, `httpAuth`, error, ttl, attributes)@@ -53,7 +54,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {$valuesTmp['attributes'] = [];}- $values = array(+ $values = [$valuesTmp['url'],$valuesTmp['kind'] ?? FreshRSS_Feed::KIND_RSS,$valuesTmp['category'],@@ -61,13 +62,13 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {$valuesTmp['website'],sanitizeHTML($valuesTmp['description'], '', 1023),$valuesTmp['lastUpdate'],- isset($valuesTmp['priority']) ? intval($valuesTmp['priority']) : FreshRSS_Feed::PRIORITY_MAIN_STREAM,+ isset($valuesTmp['priority']) ? (int)$valuesTmp['priority'] : FreshRSS_Feed::PRIORITY_MAIN_STREAM,mb_strcut($valuesTmp['pathEntries'], 0, 511, 'UTF-8'),base64_encode($valuesTmp['httpAuth']),- isset($valuesTmp['error']) ? intval($valuesTmp['error']) : 0,- isset($valuesTmp['ttl']) ? intval($valuesTmp['ttl']) : FreshRSS_Feed::TTL_DEFAULT,+ isset($valuesTmp['error']) ? (int)$valuesTmp['error'] : 0,+ isset($valuesTmp['ttl']) ? (int)$valuesTmp['ttl'] : FreshRSS_Feed::TTL_DEFAULT,is_string($valuesTmp['attributes']) ? $valuesTmp['attributes'] : json_encode($valuesTmp['attributes'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),- );+ ];if ($stm !== false && $stm->execute($values)) {$feedId = $this->pdo->lastInsertId('`_feed_id_seq`');@@ -87,7 +88,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {// Add feed only if we don’t find it in DB$feed_search = $this->searchByUrl($feed->url());if (!$feed_search) {- $values = array(+ $values = ['id' => $feed->id(),'url' => $feed->url(),'kind' => $feed->kind(),@@ -101,7 +102,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {'httpAuth' => $feed->httpAuth(),'ttl' => $feed->ttl(true),'attributes' => $feed->attributes(),- );+ ];$id = $this->addFeed($values);if ($id) {@@ -145,6 +146,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {* @return int|false*/public function updateFeed(int $id, array $valuesTmp) {+ $values = [];$originalValues = $valuesTmp;if (isset($valuesTmp['name'])) {$valuesTmp['name'] = mb_strcut(trim($valuesTmp['name']), 0, FreshRSS_DatabaseDAO::LENGTH_INDEX_UNICODE, 'UTF-8');@@ -195,9 +197,9 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {public function updateFeedAttribute(FreshRSS_Feed $feed, string $key, $value) {$feed->_attributes($key, $value);return $this->updateFeed(- $feed->id(),- array('attributes' => $feed->attributes())- );+ $feed->id(),+ ['attributes' => $feed->attributes()]+ );}/**@@ -206,11 +208,11 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {*/public function updateLastUpdate(int $id, bool $inError = false, int $mtime = 0) {$sql = 'UPDATE `_feed` SET `lastUpdate`=?, error=? WHERE id=?';- $values = array(+ $values = [$mtime <= 0 ? time() : $mtime,$inError ? 1 : 0,$id,- );+ ];$stm = $this->pdo->prepare($sql);if ($stm !== false && $stm->execute($values)) {@@ -239,10 +241,10 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {$sql = 'UPDATE `_feed` SET category=? WHERE category=?';$stm = $this->pdo->prepare($sql);- $values = array(+ $values = [$newCat->id(),- $idOldCat- );+ $idOldCat,+ ];if ($stm !== false && $stm->execute($values)) {return $stm->rowCount();@@ -258,7 +260,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {$sql = 'DELETE FROM `_feed` WHERE id=?';$stm = $this->pdo->prepare($sql);- $values = array($id);+ $values = [$id];if ($stm !== false && $stm->execute($values)) {return $stm->rowCount();@@ -280,7 +282,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {}$stm = $this->pdo->prepare($sql);- $values = array($id);+ $values = [$id];if ($stm !== false && $stm->execute($values)) {return $stm->rowCount();@@ -376,8 +378,8 @@ SQL;$sql = 'SELECT id, url, kind, name, website, `lastUpdate`, `pathEntries`, `httpAuth`, ttl, attributes '. 'FROM `_feed` '. ($defaultCacheDuration < 0 ? '' : 'WHERE ttl >= ' . FreshRSS_Feed::TTL_DEFAULT- . ' AND `lastUpdate` < (' . (time() + 60)- . '-(CASE WHEN ttl=' . FreshRSS_Feed::TTL_DEFAULT . ' THEN ' . intval($defaultCacheDuration) . ' ELSE ttl END)) ')+ . ' AND `lastUpdate` < (' . (time() + 60)+ . '-(CASE WHEN ttl=' . FreshRSS_Feed::TTL_DEFAULT . ' THEN ' . intval($defaultCacheDuration) . ' ELSE ttl END)) '). 'ORDER BY `lastUpdate` '. ($limit < 1 ? '' : 'LIMIT ' . intval($limit));$stm = $this->pdo->query($sql);@@ -389,7 +391,7 @@ SQL;return $this->listFeedsOrderUpdate($defaultCacheDuration, $limit);}Minz_Log::error('SQL error ' . __METHOD__ . json_encode($info));- return array();+ return [];}}@@ -416,8 +418,10 @@ SQL;return [];}- /** @var array<int,array{'url':string,'kind':int,'category':int,'name':string,'website':string,'lastUpdate':int,- * 'priority'?:int,'pathEntries'?:string,'httpAuth':string,'error':int,'ttl'?:int,'attributes'?:string}> $res */+ /**+ * @var array<int,array{'url':string,'kind':int,'category':int,'name':string,'website':string,'lastUpdate':int,+ * 'priority'?:int,'pathEntries'?:string,'httpAuth':string,'error':int,'ttl'?:int,'attributes'?:string}> $res+ */$feeds = self::daoToFeed($res);usort($feeds, static function (FreshRSS_Feed $a, FreshRSS_Feed $b) {@@ -579,7 +583,7 @@ SQL;* @return array<int,FreshRSS_Feed>*/public static function daoToFeed(array $listDAO, ?int $catID = null): array {- $list = array();+ $list = [];foreach ($listDAO as $key => $dao) {if (!isset($dao['name'])) {@@ -621,7 +625,7 @@ SQL;public function updateTTL(): void {$sql = 'UPDATE `_feed` SET ttl=:new_value WHERE ttl=:old_value';$stm = $this->pdo->prepare($sql);- if (!($stm && $stm->execute(array(':new_value' => FreshRSS_Feed::TTL_DEFAULT, ':old_value' => -2)))) {+ if (!($stm && $stm->execute([':new_value' => FreshRSS_Feed::TTL_DEFAULT, ':old_value' => -2]))) {$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();Minz_Log::error('SQL error ' . __METHOD__ . ' A ' . json_encode($info));@@ -632,7 +636,7 @@ SQL;Minz_Log::error('SQL error ' . __METHOD__ . ' B ' . json_encode($info));}} else {- $stm->execute(array(':new_value' => -3600, ':old_value' => -1));+ $stm->execute([':new_value' => -3600, ':old_value' => -1]);}}@@ -643,6 +647,6 @@ SQL;return -1;}$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);- return isset($res[0]) ? $res[0] : 0;+ return $res[0] ?? 0;}}diff --git a/app/Models/FilterAction.php b/app/Models/FilterAction.phpindex 44ff5674a..e94456086 100644--- a/app/Models/FilterAction.php+++ b/app/Models/FilterAction.php@@ -34,10 +34,10 @@ class FreshRSS_FilterAction {/** @return array{'search'?:string,'actions'?:array<string>} */public function toJSON(): array {if (is_array($this->actions) && $this->booleanSearch != null) {- return array(- 'search' => $this->booleanSearch->getRawInput(),- 'actions' => $this->actions,- );+ return [+ 'search' => $this->booleanSearch->getRawInput(),+ 'actions' => $this->actions,+ ];}return [];}diff --git a/app/Models/FormAuth.php b/app/Models/FormAuth.phpindex 52c75d73d..c19856c37 100644--- a/app/Models/FormAuth.php+++ b/app/Models/FormAuth.php@@ -17,7 +17,7 @@ class FreshRSS_FormAuth {public static function getCredentialsFromCookie(): array {$token = Minz_Session::getLongTermCookie('FreshRSS_login');if (!ctype_alnum($token)) {- return array();+ return [];}$token_file = DATA_PATH . '/tokens/' . $token . '.txt';@@ -27,7 +27,7 @@ class FreshRSS_FormAuth {if ($mtime + $cookie_duration < time()) {// Token has expired (> cookie_duration) or does not exist.@unlink($token_file);- return array();+ return [];}$credentials = @file_get_contents($token_file);diff --git a/app/Models/ReadingMode.php b/app/Models/ReadingMode.phpindex 30ab13aad..c0fa95b31 100644--- a/app/Models/ReadingMode.php+++ b/app/Models/ReadingMode.php@@ -87,26 +87,26 @@ class FreshRSS_ReadingMode {$isDefaultCtrl = Minz_Request::controllerName() === $defaultCtrl;$urlOutput = Minz_Request::currentRequest();- $readingModes = array(+ $readingModes = [new FreshRSS_ReadingMode("view-normal",_t('index.menu.normal_view'),- array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'normal')),+ array_merge($urlOutput, ['c' => $defaultCtrl, 'a' => 'normal']),($isDefaultCtrl && $actualView === 'normal')),new FreshRSS_ReadingMode("view-global",_t('index.menu.global_view'),- array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'global')),+ array_merge($urlOutput, ['c' => $defaultCtrl, 'a' => 'global']),($isDefaultCtrl && $actualView === 'global')),new FreshRSS_ReadingMode("view-reader",_t('index.menu.reader_view'),- array_merge($urlOutput, array('c' => $defaultCtrl, 'a' => 'reader')),+ array_merge($urlOutput, ['c' => $defaultCtrl, 'a' => 'reader']),($isDefaultCtrl && $actualView === 'reader')- ),- );+ )+ ];return $readingModes;}diff --git a/app/Models/Search.php b/app/Models/Search.phpindex 9622e18ab..52b000344 100644--- a/app/Models/Search.php+++ b/app/Models/Search.php@@ -645,7 +645,7 @@ class FreshRSS_Search {return '';}if (preg_match_all('/(?<=\s|^)[!-](?P<search>[^\s]+)/', $input, $matches)) {- $this->not_search = array_merge(is_array($this->not_search) ? $this->not_search : array(), $matches['search']);+ $this->not_search = array_merge(is_array($this->not_search) ? $this->not_search : [], $matches['search']);$input = str_replace($matches[0], '', $input);}$this->not_search = self::removeEmptyValues($this->not_search);diff --git a/app/Models/Share.php b/app/Models/Share.phpindex 4af9c8217..5bacfc381 100644--- a/app/Models/Share.php+++ b/app/Models/Share.php@@ -254,18 +254,18 @@ class FreshRSS_Share {* Return the current url by merging url_transform and base_url.*/public function url(): string {- $matches = array(+ $matches = ['~ID~','~URL~','~TITLE~','~LINK~',- );- $replaces = array(+ ];+ $replaces = [$this->id(),$this->base_url,$this->title(),$this->link(),- );+ ];return str_replace($matches, $replaces, $this->url_transform);}diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.phpindex 53219843e..122ca14a8 100644--- a/app/Models/StatsDAO.php+++ b/app/Models/StatsDAO.php@@ -2,7 +2,7 @@class FreshRSS_StatsDAO extends Minz_ModelPdo {- const ENTRY_COUNT_PERIOD = 30;+ public const ENTRY_COUNT_PERIOD = 30;protected function sqlFloor(string $s): string {return "FLOOR($s)";@@ -14,10 +14,10 @@ class FreshRSS_StatsDAO extends Minz_ModelPdo {* @return array{'main_stream':array{'total':int,'count_unreads':int,'count_reads':int,'count_favorites':int}|false,'all_feeds':array{'total':int,'count_unreads':int,'count_reads':int,'count_favorites':int}|false}*/public function calculateEntryRepartition(): array {- return array(+ return ['main_stream' => $this->calculateEntryRepartitionPerFeed(null, true),'all_feeds' => $this->calculateEntryRepartitionPerFeed(null, false),- );+ ];}/**@@ -313,7 +313,7 @@ SQL;* @return array<string>*/public function getDays(): array {- return $this->convertToTranslatedJson(array(+ return $this->convertToTranslatedJson(['sun','mon','tue',@@ -321,7 +321,7 @@ SQL;'thu','fri','sat',- ));+ ]);}/**@@ -329,7 +329,7 @@ SQL;* @return array<string>*/public function getMonths(): array {- return $this->convertToTranslatedJson(array(+ return $this->convertToTranslatedJson(['jan','feb','mar',@@ -342,7 +342,7 @@ SQL;'oct','nov','dec',- ));+ ]);}/**@@ -350,7 +350,7 @@ SQL;* @param array<string> $data* @return array<string>*/- private function convertToTranslatedJson(array $data = array()): array {+ private function convertToTranslatedJson(array $data = []): array {$translated = array_map(static function (string $a) {return _t('gen.date.' . $a);}, $data);diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.phpindex 7888caca8..0704fd9f7 100644--- a/app/Models/TagDAO.php+++ b/app/Models/TagDAO.php@@ -60,11 +60,11 @@ SQL;if (!isset($valuesTmp['attributes'])) {$valuesTmp['attributes'] = [];}- $values = array(+ $values = [$valuesTmp['name'],is_string($valuesTmp['attributes']) ? $valuesTmp['attributes'] : json_encode($valuesTmp['attributes'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),$valuesTmp['name'],- );+ ];if ($stm !== false && $stm->execute($values) && $stm->rowCount() > 0) {$tagId = $this->pdo->lastInsertId('`_tag_id_seq`');@@ -80,10 +80,10 @@ SQL;public function addTagObject(FreshRSS_Tag $tag) {$tag0 = $this->searchByName($tag->name());if (!$tag0) {- $values = array(+ $values = ['name' => $tag->name(),'attributes' => $tag->attributes(),- );+ ];return $this->addTag($values);}return $tag->id();@@ -148,7 +148,7 @@ SQL;$sql = 'DELETE FROM `_tag` WHERE id=?';$stm = $this->pdo->prepare($sql);- $values = array($id);+ $values = [$id];if ($stm !== false && $stm->execute($values)) {return $stm->rowCount();@@ -326,7 +326,7 @@ SQL;$sql = 'DELETE FROM `_entrytag` WHERE id_tag=? AND id_entry=?';}$stm = $this->pdo->prepare($sql);- $values = array($id_tag, $id_entry);+ $values = [$id_tag, $id_entry];if ($stm !== false && $stm->execute($values)) {return true;@@ -348,12 +348,12 @@ ORDER BY t.nameSQL;$stm = $this->pdo->prepare($sql);- $values = array($id_entry);+ $values = [$id_entry];if ($stm !== false && $stm->execute($values)) {$lines = $stm->fetchAll(PDO::FETCH_ASSOC);for ($i = count($lines) - 1; $i >= 0; $i--) {- $lines[$i]['id'] = intval($lines[$i]['id']);+ $lines[$i]['id'] = (int)($lines[$i]['id']);$lines[$i]['checked'] = !empty($lines[$i]['checked']);}return $lines;@@ -377,7 +377,7 @@ FROM `_tag` tINNER JOIN `_entrytag` et ON et.id_tag = t.idSQL;- $values = array();+ $values = [];if (count($entries) > 0) {if (count($entries) > FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER) {// Split a query with too many variables parameters@@ -424,12 +424,12 @@ SQL;* @return array<string,array<string>>*/public function getEntryIdsTagNames(array $entries): array {- $result = array();+ $result = [];foreach ($this->getTagsForEntries($entries) ?: [] as $line) {$entryId = 'e_' . $line['id_entry'];$tagName = $line['name'];if (empty($result[$entryId])) {- $result[$entryId] = array();+ $result[$entryId] = [];}$result[$entryId][] = $tagName;}diff --git a/app/Models/Themes.php b/app/Models/Themes.phpindex 20d825e4b..24539855b 100644--- a/app/Models/Themes.php+++ b/app/Models/Themes.php@@ -12,14 +12,14 @@ class FreshRSS_Themes extends Minz_Model {public static function getList(): array {return array_values(array_diff(scandir(PUBLIC_PATH . self::$themesUrl) ?: [],- array('..', '.')+ ['..', '.']));}/** @return array<string,array{'id':string,'name':string,'author':string,'description':string,'version':float|string,'files':array<string>,'theme-color'?:string|array{'dark'?:string,'light'?:string,'default'?:string}}> */public static function get(): array {$themes_list = self::getList();- $list = array();+ $list = [];foreach ($themes_list as $theme_dir) {$theme = self::get_infos($theme_dir);if ($theme) {@@ -76,8 +76,8 @@ class FreshRSS_Themes extends Minz_Model {self::$themeIconsUrl = self::$themesUrl . $theme_id . '/icons/';self::$themeIcons = is_dir(PUBLIC_PATH . self::$themeIconsUrl) ? array_fill_keys(array_diff(scandir(PUBLIC_PATH . self::$themeIconsUrl) ?: [],- array('..', '.')- ), 1) : array();+ ['..', '.']+ ), 1) : [];return $infos;}@@ -89,7 +89,7 @@ class FreshRSS_Themes extends Minz_Model {}public static function alt(string $name): string {- static $alts = array(+ static $alts = ['add' => '➕', //✚'all' => '☰','bookmark-add' => '➕', //✚@@ -131,15 +131,15 @@ class FreshRSS_Themes extends Minz_Model {'view-global' => '📖', //☷'view-reader' => '📜','warning' => '⚠️', //△- );+ ];return $alts[$name] ?? '';}// TODO: Change for enum in PHP 8.1+- const ICON_DEFAULT = 0;- const ICON_IMG = 1;- const ICON_URL = 2;- const ICON_EMOJI = 3;+ public const ICON_DEFAULT = 0;+ public const ICON_IMG = 1;+ public const ICON_URL = 2;+ public const ICON_EMOJI = 3;public static function icon(string $name, int $type = self::ICON_DEFAULT): string {$alt = self::alt($name);diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.phpindex a4cb469fe..f5e45f6d2 100644--- a/app/Models/UserQuery.php+++ b/app/Models/UserQuery.php@@ -73,14 +73,14 @@ class FreshRSS_UserQuery {* @return array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string}*/public function toArray(): array {- return array_filter(array(+ return array_filter(['get' => $this->get,'name' => $this->name,'order' => $this->order,'search' => $this->search->__toString(),'state' => $this->state,'url' => $this->url,- ));+ ]);}/**diff --git a/app/Services/ImportService.php b/app/Services/ImportService.phpindex 8565be41c..e92351c0f 100644--- a/app/Services/ImportService.php+++ b/app/Services/ImportService.php@@ -36,7 +36,7 @@ class FreshRSS_Import_Service {public function importOpml(string $opml_file, ?FreshRSS_Category $forced_category = null, bool $dry_run = false): void {@set_time_limit(300);$this->lastStatus = true;- $opml_array = array();+ $opml_array = [];try {$libopml = new \marienfressinaud\LibOpml\LibOpml(false);$opml_array = $libopml->parseString($opml_file);@@ -70,10 +70,7 @@ class FreshRSS_Import_Service {// Process the OPML outlines to get a list of categories and a list of// feeds elements indexed by their categories names.- list (- $categories_elements,- $categories_to_feeds,- ) = $this->loadFromOutlines($opml_array['body'], '');+ [$categories_elements, $categories_to_feeds] = $this->loadFromOutlines($opml_array['body'], '');foreach ($categories_to_feeds as $category_name => $feeds_elements) {$category_element = $categories_elements[$category_name] ?? null;@@ -302,10 +299,7 @@ class FreshRSS_Import_Service {foreach ($outlines as $outline) {// Get the categories and feeds from the child outline (it may// return several categories and feeds if the outline is a category).- list (- $outline_categories,- $outline_categories_to_feeds,- ) = $this->loadFromOutline($outline, $parent_category_name);+ [$outline_categories, $outline_categories_to_feeds] = $this->loadFromOutline($outline, $parent_category_name);// Then, we merge the initial arrays with the arrays returned by// the outline.@@ -367,10 +361,7 @@ class FreshRSS_Import_Service {$category_name = $parent_category_name;}- list (- $categories_elements,- $categories_to_feeds,- ) = $this->loadFromOutlines($outline['@outlines'], $category_name);+ [$categories_elements, $categories_to_feeds] = $this->loadFromOutlines($outline['@outlines'], $category_name);unset($outline['@outlines']);$categories_elements[$category_name] = $outline;diff --git a/app/Utils/passwordUtil.php b/app/Utils/passwordUtil.phpindex 0edead213..4e3040f4a 100644--- a/app/Utils/passwordUtil.php+++ b/app/Utils/passwordUtil.php@@ -12,7 +12,7 @@ class FreshRSS_password_Util {$passwordHash = password_hash($passwordPlain,PASSWORD_BCRYPT,- array('cost' => self::BCRYPT_COST)+ ['cost' => self::BCRYPT_COST]);// Compatibility with bcrypt.jsdiff --git a/app/install.php b/app/install.phpindex 4023e249e..873689054 100644--- a/app/install.php+++ b/app/install.php@@ -268,11 +268,11 @@ function checkStep0(): array {$language = Minz_Session::param('language') != '' && in_array(Minz_Session::param('language'), $languages, true);$sessionWorking = Minz_Session::param('sessionWorking') === 'ok';- return array(+ return ['language' => $language ? 'ok' : 'ko','sessionWorking' => $sessionWorking ? 'ok' : 'ko',- 'all' => $language && $sessionWorking ? 'ok' : 'ko'- );+ 'all' => $language && $sessionWorking ? 'ok' : 'ko',+ ];}function freshrss_already_installed(): bool {@@ -376,7 +376,7 @@ function printStep0(): void {<?= FRESHRSS_VERSION ?></div></div>-+<form action="index.php?step=0" method="post"><legend><?= _t('install.language.choose') ?></legend><div class="form-group">@@ -544,7 +544,7 @@ function printStep2(): void {<label class="group-name" for="host"><?= _t('install.bdd.host') ?></label><div class="group-controls"><input type="text" id="host" name="host" pattern="[0-9A-Z/a-z_.-]{1,64}(:[0-9]{2,5})?" value="<?=- isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : ($system_default_config->db['host'] ?? '') ?>" tabindex="2" />+ $_SESSION['bd_host'] ?? $system_default_config->db['host'] ?? '' ?>" tabindex="2" /></div></div>@@ -552,7 +552,7 @@ function printStep2(): void {<label class="group-name" for="user"><?= _t('install.bdd.username') ?></label><div class="group-controls"><input type="text" id="user" name="user" maxlength="64" pattern="[0-9A-Za-z@_.-]{1,64}" value="<?=- isset($_SESSION['bd_user']) ? $_SESSION['bd_user'] : '' ?>" tabindex="3" />+ $_SESSION['bd_user'] ?? '' ?>" tabindex="3" /></div></div>@@ -561,7 +561,7 @@ function printStep2(): void {<div class="group-controls"><div class="stick"><input type="password" id="pass" name="pass" value="<?=- isset($_SESSION['bd_password']) ? $_SESSION['bd_password'] : '' ?>" tabindex="4" autocomplete="off" />+ $_SESSION['bd_password'] ?? '' ?>" tabindex="4" autocomplete="off" /><a class="btn toggle-password" data-toggle="pass" tabindex="5"><?= FreshRSS_Themes::icon('key') ?></a></div></div>@@ -571,7 +571,7 @@ function printStep2(): void {<label class="group-name" for="base"><?= _t('install.bdd') ?></label><div class="group-controls"><input type="text" id="base" name="base" maxlength="64" pattern="[0-9A-Za-z_-]{1,64}" value="<?=- isset($_SESSION['bd_base']) ? $_SESSION['bd_base'] : '' ?>" tabindex="6" />+ $_SESSION['bd_base'] ?? '' ?>" tabindex="6" /></div></div>@@ -579,7 +579,7 @@ function printStep2(): void {<label class="group-name" for="prefix"><?= _t('install.bdd.prefix') ?></label><div class="group-controls"><input type="text" id="prefix" name="prefix" maxlength="16" pattern="[0-9A-Za-z_]{1,16}" value="<?=- isset($_SESSION['bd_prefix']) ? $_SESSION['bd_prefix'] : ($system_default_config->db['prefix'] ?? '') ?>" tabindex="7" />+ $_SESSION['bd_prefix'] ?? $system_default_config->db['prefix'] ?? '' ?>" tabindex="7" /></div></div></div>@@ -603,7 +603,7 @@ function no_auth(string $auth_type): bool {/* Create default user */function printStep3(): void {- $auth_type = isset($_SESSION['auth_type']) ? $_SESSION['auth_type'] : '';+ $auth_type = $_SESSION['auth_type'] ?? '';$s3 = checkStep3();if ($s3['all'] == 'ok') { ?><p class="alert alert-success"><span class="alert-head"><?= _t('gen.short.ok') ?></span> <?= _t('install.conf.ok') ?></p>@@ -618,7 +618,7 @@ function printStep3(): void {<label class="group-name" for="default_user"><?= _t('install.default_user') ?></label><div class="group-controls"><input type="text" id="default_user" name="default_user" autocomplete="username" required="required" size="16"- pattern="<?= FreshRSS_user_Controller::USERNAME_PATTERN ?>" value="<?= isset($_SESSION['default_user']) ? $_SESSION['default_user'] : '' ?>"+ pattern="<?= FreshRSS_user_Controller::USERNAME_PATTERN ?>" value="<?= $_SESSION['default_user'] ?? '' ?>"placeholder="<?= httpAuthUser(false) == '' ? 'alice' : httpAuthUser(false) ?>" tabindex="1" /><p class="help"><?= _i('help') ?> <?= _t('install.default_user.max_char') ?></p></div>