aboutsummaryrefslogtreecommitdiff
path: root/app/Services
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-06-04 14:00:33 +0200
committerGravatar GitHub <noreply@github.com> 2025-06-04 14:00:33 +0200
commit4de7d0b81310c788365fd3d2ab28dfbbccb5b171 (patch)
tree9e1217892a1f6a3ee33611ff739aa46cfb6bd825 /app/Services
parent2b94cffeab0dfd66fcef15b6295efba24319b555 (diff)
PHPStan: pass checkImplicitMixed (#7642)
* PHPStan: pass checkImplicitMixed * Complete
Diffstat (limited to 'app/Services')
-rw-r--r--app/Services/ImportService.php23
1 files changed, 15 insertions, 8 deletions
diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php
index d32b62517..a2920dc74 100644
--- a/app/Services/ImportService.php
+++ b/app/Services/ImportService.php
@@ -41,6 +41,7 @@ class FreshRSS_Import_Service {
$opml_array = [];
try {
$libopml = new \marienfressinaud\LibOpml\LibOpml(false);
+ /** @var array{body:array<array<mixed>>} $opml_array */
$opml_array = $libopml->parseString($opml_file);
} catch (\marienfressinaud\LibOpml\Exception $e) {
self::log($e->getMessage());
@@ -382,13 +383,16 @@ class FreshRSS_Import_Service {
*
* @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<string,array<string,string>>,1:array<string,array<array<string,string>>>}
+ * @return array{0:array<string,array<string,string>>,1:array<string,list<array<string,string>>>}
*/
private function loadFromOutlines(array $outlines, string $parent_category_name): array {
$categories_elements = [];
$categories_to_feeds = [];
foreach ($outlines as $outline) {
+ if (!is_array($outline)) {
+ continue;
+ }
// Get the categories and feeds from the child outline (it may
// return several categories and feeds if the outline is a category).
[$outline_categories, $outline_categories_to_feeds] = $this->loadFromOutline($outline, $parent_category_name);
@@ -398,10 +402,12 @@ class FreshRSS_Import_Service {
$categories_elements = array_merge($categories_elements, $outline_categories);
foreach ($outline_categories_to_feeds as $category_name => $feeds) {
+ if (!is_string($category_name) || !is_array($feeds)) {
+ continue;
+ }
if (!isset($categories_to_feeds[$category_name])) {
$categories_to_feeds[$category_name] = [];
}
-
$categories_to_feeds[$category_name] = array_merge(
$categories_to_feeds[$category_name],
$feeds
@@ -424,7 +430,7 @@ class FreshRSS_Import_Service {
* @param array<mixed> $outline The outline from which to extract the categories and feeds outlines.
* @param string $parent_category_name The name of the parent category of the current outline.
*
- * @return array{0:array<string,array<string,string>>,1:array<array<string,array<string,string>>>}
+ * @return array{0:array<string,array<string,string>>,1:array<string,list<array<string,string>>>}
*/
private function loadFromOutline(array $outline, string $parent_category_name): array {
$categories_elements = [];
@@ -441,7 +447,7 @@ class FreshRSS_Import_Service {
];
}
- if (isset($outline['@outlines'])) {
+ if (is_array($outline['@outlines'] ?? null)) {
// The outline has children, it’s probably a category
if (!empty($outline['text']) && is_string($outline['text'])) {
$category_name = $outline['text'];
@@ -451,10 +457,11 @@ class FreshRSS_Import_Service {
$category_name = $parent_category_name;
}
- [$categories_elements, $categories_to_feeds] = $this->loadFromOutlines($outline['@outlines'], $category_name);
+ $children = array_filter($outline['@outlines'], 'is_array');
+ [$categories_elements, $categories_to_feeds] = $this->loadFromOutlines($children, $category_name);
unset($outline['@outlines']);
- $categories_elements[$category_name] = $outline;
+ $categories_elements[$category_name] = array_filter($outline, static fn($value, $key) => is_string($key) && is_string($value), ARRAY_FILTER_USE_BOTH);
}
// The xmlUrl means it’s a feed URL: add the outline to the array if it exists.
@@ -462,8 +469,8 @@ class FreshRSS_Import_Service {
if (!isset($categories_to_feeds[$parent_category_name])) {
$categories_to_feeds[$parent_category_name] = [];
}
-
- $categories_to_feeds[$parent_category_name][] = $outline;
+ $feed = array_filter($outline, static fn($value, $key) => is_string($key) && is_string($value), ARRAY_FILTER_USE_BOTH);
+ $categories_to_feeds[$parent_category_name][] = $feed;
}
return [$categories_elements, $categories_to_feeds];