From 115724622fa32e1b7981e378e87ccfb770450cb1 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 23 Apr 2023 11:58:15 +0200 Subject: PHPStan Level 7 for ten more files (#5327) * PHPStan Level 7 for nine more files * Minor syntax * One more --- app/Services/ExportService.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'app/Services/ExportService.php') diff --git a/app/Services/ExportService.php b/app/Services/ExportService.php index 10d5ca2cc..c19c505af 100644 --- a/app/Services/ExportService.php +++ b/app/Services/ExportService.php @@ -43,7 +43,7 @@ class FreshRSS_Export_Service { public function generateOpml(): array { $view = new FreshRSS_View(); $day = date('Y-m-d'); - $view->categories = $this->category_dao->listCategories(true, true); + $view->categories = $this->category_dao->listCategories(true, true) ?: []; $view->excludeMutedFeeds = false; return [ @@ -67,7 +67,7 @@ class FreshRSS_Export_Service { */ public function generateStarredEntries(string $type): array { $view = new FreshRSS_View(); - $view->categories = $this->category_dao->listCategories(true); + $view->categories = $this->category_dao->listCategories(true) ?: []; $day = date('Y-m-d'); $view->list_title = _t('sub.import_export.starred_list'); @@ -99,7 +99,7 @@ class FreshRSS_Export_Service { } $view = new FreshRSS_View(); - $view->categories = $this->category_dao->listCategories(true); + $view->categories = $this->category_dao->listCategories(true) ?: []; $view->feed = $feed; $day = date('Y-m-d'); $filename = "feed_{$day}_" . $feed->categoryId() . '_' . $feed->id() . '.json'; @@ -127,7 +127,7 @@ class FreshRSS_Export_Service { * @return array Keys are filenames and values are contents. */ public function generateAllFeedEntries(int $max_number_entries): array { - $feed_ids = $this->feed_dao->listFeedsIds(); + $feed_ids = $this->feed_dao->listFeedsIds() ?: []; $exported_files = []; foreach ($feed_ids as $feed_id) { @@ -154,6 +154,9 @@ class FreshRSS_Export_Service { // From https://stackoverflow.com/questions/1061710/php-zip-files-on-the-fly $zip_file = tempnam('/tmp', 'zip'); + if ($zip_file == false) { + return [$zip_filename, false]; + } $zip_archive = new ZipArchive(); $zip_archive->open($zip_file, ZipArchive::OVERWRITE); -- cgit v1.2.3