diff options
| author | 2023-04-23 11:58:15 +0200 | |
|---|---|---|
| committer | 2023-04-23 11:58:15 +0200 | |
| commit | 115724622fa32e1b7981e378e87ccfb770450cb1 (patch) | |
| tree | 4d7072768076fd76f2f1877757f3e2e395ab2ded /app/Services | |
| parent | 8abe53d879ef188a5c1cc394894ce211fcfa9f92 (diff) | |
PHPStan Level 7 for ten more files (#5327)
* PHPStan Level 7 for nine more files
* Minor syntax
* One more
Diffstat (limited to 'app/Services')
| -rw-r--r-- | app/Services/ExportService.php | 11 | ||||
| -rw-r--r-- | app/Services/ImportService.php | 4 |
2 files changed, 9 insertions, 6 deletions
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<string,string> 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); diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index 3707e4c5e..e5d558233 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -56,7 +56,7 @@ class FreshRSS_Import_Service { // Get the categories by names so we can use this array to retrieve // existing categories later. - $categories = $this->catDAO->listCategories(false); + $categories = $this->catDAO->listCategories(false) ?: []; $categories_by_names = []; foreach ($categories as $category) { $categories_by_names[$category->name()] = $category; @@ -180,7 +180,7 @@ class FreshRSS_Import_Service { if (isset($feed_elt['frss:filtersActionRead'])) { $feed->_filtersAction( 'read', - preg_split('/[\n\r]+/', $feed_elt['frss:filtersActionRead']) + preg_split('/[\n\r]+/', $feed_elt['frss:filtersActionRead']) ?: [] ); } |
