diff options
| author | 2023-04-28 14:01:11 +0200 | |
|---|---|---|
| committer | 2023-04-28 14:01:11 +0200 | |
| commit | c72914bba2363e436574204b3d6093a6f3cfce89 (patch) | |
| tree | 377008a7393e4d80e4c8659f27dd42c0ccbab382 /app/Controllers/statsController.php | |
| parent | 26e2a703125ffe1d0d2746b0e5ea3491b627832c (diff) | |
PHPStan Level 7 for more DAO PDO (#5328)
* PHPStan Level 7 for more DAO PDO
With new function to address common type and check problems
* A bit more
* PHPStan Level 7 for FreshRSS_Entry
Diffstat (limited to 'app/Controllers/statsController.php')
| -rw-r--r-- | app/Controllers/statsController.php | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 0fc6490f8..afbaccfc5 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -47,25 +47,34 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { $statsDAO = FreshRSS_Factory::createStatsDAO(); FreshRSS_View::appendScript(Minz_Url::display('/scripts/vendor/chart.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/vendor/chart.min.js'))); - $this->view->repartition = $statsDAO->calculateEntryRepartition(); + $this->view->repartitions = $statsDAO->calculateEntryRepartition(); $entryCount = $statsDAO->calculateEntryCount(); - $this->view->entryCount = $entryCount; - $this->view->average = round(array_sum(array_values($entryCount)) / count($entryCount), 2); + if (is_array($entryCount) && count($entryCount) > 0) { + $this->view->entryCount = $entryCount; + $this->view->average = round(array_sum(array_values($entryCount)) / count($entryCount), 2); + } else { + $this->view->entryCount = []; + $this->view->average = -1.0; + } - $feedByCategory_calculated = $statsDAO->calculateFeedByCategory(); $feedByCategory = []; - for ($i = 0; $i < count($feedByCategory_calculated); $i++) { - $feedByCategory['label'][$i] = $feedByCategory_calculated[$i]['label']; - $feedByCategory['data'][$i] = $feedByCategory_calculated[$i]['data']; + $feedByCategory_calculated = $statsDAO->calculateFeedByCategory(); + if (is_array($feedByCategory_calculated)) { + for ($i = 0; $i < count($feedByCategory_calculated); $i++) { + $feedByCategory['label'][$i] = $feedByCategory_calculated[$i]['label']; + $feedByCategory['data'][$i] = $feedByCategory_calculated[$i]['data']; + } } $this->view->feedByCategory = $feedByCategory; - $entryByCategory_calculated = $statsDAO->calculateEntryByCategory(); $entryByCategory = []; - for ($i = 0; $i < count($entryByCategory_calculated); $i++) { - $entryByCategory['label'][$i] = $entryByCategory_calculated[$i]['label']; - $entryByCategory['data'][$i] = $entryByCategory_calculated[$i]['data']; + $entryByCategory_calculated = $statsDAO->calculateEntryByCategory(); + if (is_array($entryByCategory_calculated)) { + for ($i = 0; $i < count($entryByCategory_calculated); $i++) { + $entryByCategory['label'][$i] = $entryByCategory_calculated[$i]['label']; + $entryByCategory['data'][$i] = $entryByCategory_calculated[$i]['data']; + } } $this->view->entryByCategory = $entryByCategory; @@ -114,7 +123,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController { FreshRSS_View::appendScript(Minz_Url::display('/scripts/feed.js?' . @filemtime(PUBLIC_PATH . '/scripts/feed.js'))); $feed_dao = FreshRSS_Factory::createFeedDao(); $statsDAO = FreshRSS_Factory::createStatsDAO(); - $feeds = $statsDAO->calculateFeedLastDate(); + $feeds = $statsDAO->calculateFeedLastDate() ?: []; $idleFeeds = array( 'last_5_year' => array(), 'last_3_year' => array(), |
