diff options
| author | 2023-12-18 17:59:16 +0100 | |
|---|---|---|
| committer | 2023-12-18 17:59:16 +0100 | |
| commit | a80a5f48a16e7d232168a7aaa68e9a1804235ce1 (patch) | |
| tree | a515b88592629dea7e83b96e26e2452d3f98a98e /app/Controllers/categoryController.php | |
| parent | 6bb45a87268157aab961a6a4a728d9a9bbe043b0 (diff) | |
Pass PHPStan level 8 (#5946)
* Pass PHPStan level 8
And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels
* Revert wrong replace in comment
* Fix PHPStan level 8
* Update PHPStan and other dev dependencies
* Remove obsolete comment
* noVariableVariables and towards bleedingEdge
https://github.com/phpstan/phpstan-strict-rules
https://phpstan.org/blog/what-is-bleeding-edge
* More bleedingEdge
* A bit more PHPStan level 9
* More PHPStan level 9
* Prepare for booleansInConditions
Ignore int and null
* Revert wrong line
* More fixes
* Fix keep_max_n_unread
* Stricter attribute functions
* Stricter callHooks and more PHPStan level 9
* More typing
* A tiny more
Diffstat (limited to 'app/Controllers/categoryController.php')
| -rw-r--r-- | app/Controllers/categoryController.php | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index daee1666a..780f03f02 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -33,7 +33,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { $url_redirect = ['c' => 'subscription', 'a' => 'add']; - $limits = FreshRSS_Context::$system_conf->limits; + $limits = FreshRSS_Context::systemConf()->limits; $this->view->categories = $catDAO->listCategories(false) ?: []; if (count($this->view->categories) >= $limits['max_categories']) { @@ -61,10 +61,10 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { $opml_url = checkUrl(Minz_Request::paramString('opml_url')); if ($opml_url != '') { $cat->_kind(FreshRSS_Category::KIND_DYNAMIC_OPML); - $cat->_attributes('opml_url', $opml_url); + $cat->_attribute('opml_url', $opml_url); } else { $cat->_kind(FreshRSS_Category::KIND_NORMAL); - $cat->_attributes('opml_url', null); + $cat->_attribute('opml_url', null); } if ($catDAO->addCategoryObject($cat)) { @@ -102,7 +102,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { $category->_filtersAction('read', Minz_Request::paramTextToArray('filteractions_read')); if (Minz_Request::paramBoolean('use_default_purge_options')) { - $category->_attributes('archiving', null); + $category->_attribute('archiving', null); } else { if (!Minz_Request::paramBoolean('enable_keep_max')) { $keepMax = false; @@ -117,7 +117,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { } else { $keepPeriod = false; } - $category->_attributes('archiving', [ + $category->_attribute('archiving', [ 'keep_period' => $keepPeriod, 'keep_max' => $keepMax, 'keep_min' => Minz_Request::paramInt('keep_min'), @@ -128,15 +128,15 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { } $position = Minz_Request::paramInt('position') ?: null; - $category->_attributes('position', $position); + $category->_attribute('position', $position); $opml_url = checkUrl(Minz_Request::paramString('opml_url')); if ($opml_url != '') { $category->_kind(FreshRSS_Category::KIND_DYNAMIC_OPML); - $category->_attributes('opml_url', $opml_url); + $category->_attribute('opml_url', $opml_url); } else { $category->_kind(FreshRSS_Category::KIND_NORMAL); - $category->_attributes('opml_url', null); + $category->_attribute('opml_url', null); } $values = [ @@ -190,9 +190,10 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { } // Remove related queries. - FreshRSS_Context::$user_conf->queries = remove_query_by_get( - 'c_' . $id, FreshRSS_Context::$user_conf->queries); - FreshRSS_Context::$user_conf->save(); + /** @var array<array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string}> $queries */ + $queries = remove_query_by_get('c_' . $id, FreshRSS_Context::userConf()->queries); + FreshRSS_Context::userConf()->queries = $queries; + FreshRSS_Context::userConf()->save(); Minz_Request::good(_t('feedback.sub.category.deleted'), $url_redirect); } @@ -230,10 +231,11 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { // Remove related queries foreach ($feeds as $feed) { - FreshRSS_Context::$user_conf->queries = remove_query_by_get( - 'f_' . $feed->id(), FreshRSS_Context::$user_conf->queries); + /** @var array<array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string}> */ + $queries = remove_query_by_get('f_' . $feed->id(), FreshRSS_Context::userConf()->queries); + FreshRSS_Context::userConf()->queries = $queries; } - FreshRSS_Context::$user_conf->save(); + FreshRSS_Context::userConf()->save(); Minz_Request::good(_t('feedback.sub.category.emptied'), $url_redirect); } else { @@ -258,11 +260,13 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { $id = Minz_Request::paramInt('id'); if ($id === 0) { Minz_Request::bad(_t('feedback.sub.category.no_id'), $url_redirect); + return; } $category = $catDAO->searchById($id); if ($category === null) { Minz_Request::bad(_t('feedback.sub.category.not_exist'), $url_redirect); + return; } invalidateHttpCache(); @@ -288,7 +292,7 @@ class FreshRSS_category_Controller extends FreshRSS_ActionController { $successes = 0; $errors = 0; $catDAO = FreshRSS_Factory::createCategoryDao(); - $categories = $catDAO->listCategoriesOrderUpdate(FreshRSS_Context::$user_conf->dynamic_opml_ttl_default ?? 86400); + $categories = $catDAO->listCategoriesOrderUpdate(FreshRSS_Context::userConf()->dynamic_opml_ttl_default ?? 86400); foreach ($categories as $category) { if ($category->refreshDynamicOpml()) { $successes++; |
