aboutsummaryrefslogtreecommitdiff
path: root/app/Services/ImportService.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-06-09 20:32:12 +0200
committerGravatar GitHub <noreply@github.com> 2024-06-09 20:32:12 +0200
commit5b28a35003a015e29770094932157f13a3f7f5c0 (patch)
tree4cbe4100379ca0d148115ad31f5a1c0c95ff7c80 /app/Services/ImportService.php
parente98c57841b843ed881f06ce6ed1c9c89942c27b8 (diff)
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
Diffstat (limited to 'app/Services/ImportService.php')
-rw-r--r--app/Services/ImportService.php18
1 files changed, 9 insertions, 9 deletions
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<mixed> $outlines
+ * @param array<array<mixed>> $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<mixed>,1:array<mixed>}
+ * @return array{0:array<string,array<string,string>>,1:array<string,array<array<string,string>>>}
*/
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<string,mixed>,1:array<string,mixed>}
+ * @return array{0:array<string,array<string,string>>,1:array<array<string,array<string,string>>>}
*/
- 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;