From 5b28a35003a015e29770094932157f13a3f7f5c0 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 9 Jun 2024 20:32:12 +0200 Subject: Pass PHPStan level 9 (#6544) * More PHPStan * More, passing * 4 more files * Update to PHPStan 1.11.4 Needed for fixed bug: Consider numeric-string types after string concat https://github.com/phpstan/phpstan/releases/tag/1.11.4 * Pass PHPStan level 9 Start tracking booleansInConditions * Fix mark as read * Fix doctype * ctype_digit --- app/Services/ImportService.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'app/Services') diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index 2c23e5d4f..11da49217 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -78,13 +78,13 @@ class FreshRSS_Import_Service { $category_element = $categories_elements[$category_name] ?? null; $category = null; - if ($forced_category) { + if ($forced_category !== null) { // If the category is forced, ignore the actual category name $category = $forced_category; } elseif (isset($categories_by_names[$category_name])) { // If the category already exists, get it from $categories_by_names $category = $categories_by_names[$category_name]; - } elseif ($category_element) { + } elseif (is_array($category_element)) { // Otherwise, create the category (if possible) $limit_reached = $nb_categories >= $limits['max_categories']; $can_create_category = FreshRSS_Context::$isCli || !$limit_reached; @@ -362,11 +362,11 @@ class FreshRSS_Import_Service { * This method is applied to a list of outlines. It merges the different * list of feeds from several outlines into one array. * - * @param array $outlines + * @param array> $outlines * The outlines from which to extract the outlines. * @param string $parent_category_name * The name of the parent category of the current outlines. - * @return array{0:array,1:array} + * @return array{0:array>,1:array>>} */ private function loadFromOutlines(array $outlines, string $parent_category_name): array { $categories_elements = []; @@ -410,13 +410,13 @@ class FreshRSS_Import_Service { * @param string $parent_category_name * The name of the parent category of the current outline. * - * @return array{0:array,1:array} + * @return array{0:array>,1:array>>} */ - private function loadFromOutline($outline, $parent_category_name): array { + private function loadFromOutline(array $outline, string $parent_category_name): array { $categories_elements = []; $categories_to_feeds = []; - if ($parent_category_name === '' && isset($outline['category'])) { + if ($parent_category_name === '' && isset($outline['category']) && is_array($outline['category'])) { // The outline has no parent category, but its OPML category // attribute is set, so we use it as the category name. // lib_opml parses this attribute as an array of strings, so we @@ -429,9 +429,9 @@ class FreshRSS_Import_Service { if (isset($outline['@outlines'])) { // The outline has children, it’s probably a category - if (!empty($outline['text'])) { + if (!empty($outline['text']) && is_string($outline['text'])) { $category_name = $outline['text']; - } elseif (!empty($outline['title'])) { + } elseif (!empty($outline['title']) && is_string($outline['title'])) { $category_name = $outline['title']; } else { $category_name = $parent_category_name; -- cgit v1.2.3