From 75a203fff233901b0276beccdf2f64c34ef53f40 Mon Sep 17 00:00:00 2001 From: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> Date: Fri, 20 Jan 2023 23:37:41 +0100 Subject: Type hinting statsController.php (#5024) --- app/Controllers/statsController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/Controllers/statsController.php') diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 1798ee3cf..0ab7df09b 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -10,7 +10,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { * the common boiler plate for every action. It is triggered by the * underlying framework. */ - public function firstAction() { + public function firstAction(): void { if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error(403); } @@ -32,7 +32,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { FreshRSS_View::prependTitle(_t('admin.stats.title') . ' · '); } - private function convertToSeries($data) { + private function convertToSeries($data): array { $series = array(); foreach ($data as $key => $value) { @@ -42,7 +42,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { return $series; } - private function convertToPieSeries($data) { + private function convertToPieSeries(array $data): array { $series = array(); foreach ($data as $value) { @@ -64,7 +64,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { * - number of article by category (entryByCategory) * - list of most prolific feed (topFeed) */ - public function indexAction() { + public function indexAction(): void { $statsDAO = FreshRSS_Factory::createStatsDAO(); FreshRSS_View::appendScript(Minz_Url::display('/scripts/vendor/chart.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/vendor/chart.min.js'))); @@ -106,7 +106,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { * to use the subscription controller to save it, * but shows the stats idle page */ - public function feedAction() { + public function feedAction(): void { $id = Minz_Request::param('id'); $ajax = Minz_Request::param('ajax'); if ($ajax) { @@ -131,7 +131,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { * - last month * - last week */ - public function idleAction() { + public function idleAction(): void { FreshRSS_View::appendScript(Minz_Url::display('/scripts/feed.js?' . @filemtime(PUBLIC_PATH . '/scripts/feed.js'))); $feed_dao = FreshRSS_Factory::createFeedDao(); $statsDAO = FreshRSS_Factory::createStatsDAO(); @@ -216,7 +216,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { * @todo verify that the metrics used here make some sense. Especially * for the average. */ - public function repartitionAction() { + public function repartitionAction(): void { $statsDAO = FreshRSS_Factory::createStatsDAO(); $categoryDAO = FreshRSS_Factory::createCategoryDao(); $feedDAO = FreshRSS_Factory::createFeedDao(); -- cgit v1.2.3 From 1c434971d4148e752e749835bb9acdf252e8d501 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 21 Jan 2023 23:20:44 +0100 Subject: statsController at phpStan level 9 (#5028) Follow up of https://github.com/FreshRSS/FreshRSS/pull/5024 ``` vendor/bin/phpstan analyse --level 9 app/Controllers/statsController.php ``` Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112 --- app/Controllers/statsController.php | 27 +++------------------------ app/views/index/logs.phtml | 10 +++++----- 2 files changed, 8 insertions(+), 29 deletions(-) (limited to 'app/Controllers/statsController.php') diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 0ab7df09b..16b09d702 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -32,27 +32,6 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { FreshRSS_View::prependTitle(_t('admin.stats.title') . ' · '); } - private function convertToSeries($data): array { - $series = array(); - - foreach ($data as $key => $value) { - $series[] = array($key, $value); - } - - return $series; - } - - private function convertToPieSeries(array $data): array { - $series = array(); - - foreach ($data as $value) { - $value['data'] = array(array(0, (int) $value['data'])); - $series[] = $value; - } - - return $series; - } - /** * This action handles the statistic main page. * @@ -94,7 +73,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { $last30DaysLabels = []; for ($i = 0; $i < 30; $i++) { - $last30DaysLabels[$i] = date('d.m.Y', strtotime((-30 + $i) . ' days')); + $last30DaysLabels[$i] = date('d.m.Y', strtotime((-30 + $i) . ' days') ?: null); } $this->view->last30DaysLabels = $last30DaysLabels; @@ -107,8 +86,8 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { * but shows the stats idle page */ public function feedAction(): void { - $id = Minz_Request::param('id'); - $ajax = Minz_Request::param('ajax'); + $id = '' . Minz_Request::param('id', ''); + $ajax = '' . Minz_Request::param('ajax', ''); if ($ajax) { $url_redirect = array('c' => 'subscription', 'a' => 'feed', 'params' => array('id' => $id, 'from' => 'stats', 'ajax' => $ajax)); } else { diff --git a/app/views/index/logs.phtml b/app/views/index/logs.phtml index f6a76b922..896a19765 100644 --- a/app/views/index/logs.phtml +++ b/app/views/index/logs.phtml @@ -6,7 +6,7 @@

- + $items */ @@ -29,8 +29,8 @@ level()) ?> -