diff options
Diffstat (limited to 'app/Models/Search.php')
| -rw-r--r-- | app/Models/Search.php | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/app/Models/Search.php b/app/Models/Search.php index a887ec2f7..3eb8b422a 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -17,17 +17,17 @@ class FreshRSS_Search implements \Stringable { private string $raw_input = ''; // The following properties are extracted from the raw input - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $entry_ids = null; - /** @var array<int>|null */ + /** @var list<int>|null */ private ?array $feed_ids = null; - /** @var array<int>|'*'|null */ + /** @var list<int>|'*'|null */ private $label_ids = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $label_names = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $intitle = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $intitle_regex = null; /** @var int|false|null */ private $min_date = null; @@ -37,34 +37,34 @@ class FreshRSS_Search implements \Stringable { private $min_pubdate = null; /** @var int|false|null */ private $max_pubdate = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $inurl = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $inurl_regex = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $author = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $author_regex = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $tags = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $tags_regex = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $search = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $search_regex = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_entry_ids = null; - /** @var array<int>|null */ + /** @var list<int>|null */ private ?array $not_feed_ids = null; - /** @var array<int>|'*'|null */ + /** @var list<int>|'*'|null */ private $not_label_ids = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_label_names = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_intitle = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_intitle_regex = null; /** @var int|false|null */ private $not_min_date = null; @@ -74,21 +74,21 @@ class FreshRSS_Search implements \Stringable { private $not_min_pubdate = null; /** @var int|false|null */ private $not_max_pubdate = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_inurl = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_inurl_regex = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_author = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_author_regex = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_tags = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_tags_regex = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_search = null; - /** @var array<string>|null */ + /** @var list<string>|null */ private ?array $not_search_regex = null; public function __construct(string $input) { @@ -137,54 +137,54 @@ class FreshRSS_Search implements \Stringable { return $this->raw_input; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getEntryIds(): ?array { return $this->entry_ids; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotEntryIds(): ?array { return $this->not_entry_ids; } - /** @return array<int>|null */ + /** @return list<int>|null */ public function getFeedIds(): ?array { return $this->feed_ids; } - /** @return array<int>|null */ + /** @return list<int>|null */ public function getNotFeedIds(): ?array { return $this->not_feed_ids; } - /** @return array<int>|'*'|null */ + /** @return list<int>|'*'|null */ public function getLabelIds(): array|string|null { return $this->label_ids; } - /** @return array<int>|'*'|null */ + /** @return list<int>|'*'|null */ public function getNotLabelIds(): array|string|null { return $this->not_label_ids; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getLabelNames(): ?array { return $this->label_names; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotLabelNames(): ?array { return $this->not_label_names; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getIntitle(): ?array { return $this->intitle; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getIntitleRegex(): ?array { return $this->intitle_regex; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotIntitle(): ?array { return $this->not_intitle; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotIntitleRegex(): ?array { return $this->not_intitle_regex; } @@ -223,90 +223,90 @@ class FreshRSS_Search implements \Stringable { return $this->not_max_pubdate ?: null; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getInurl(): ?array { return $this->inurl; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getInurlRegex(): ?array { return $this->inurl_regex; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotInurl(): ?array { return $this->not_inurl; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotInurlRegex(): ?array { return $this->not_inurl_regex; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getAuthor(): ?array { return $this->author; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getAuthorRegex(): ?array { return $this->author_regex; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotAuthor(): ?array { return $this->not_author; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotAuthorRegex(): ?array { return $this->not_author_regex; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getTags(): ?array { return $this->tags; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getTagsRegex(): ?array { return $this->tags_regex; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotTags(): ?array { return $this->not_tags; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotTagsRegex(): ?array { return $this->not_tags_regex; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getSearch(): ?array { return $this->search; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getSearchRegex(): ?array { return $this->search_regex; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotSearch(): ?array { return $this->not_search; } - /** @return array<string>|null */ + /** @return list<string>|null */ public function getNotSearchRegex(): ?array { return $this->not_search_regex; } /** - * @param array<string>|null $anArray - * @return array<string> + * @param list<string>|null $anArray + * @return list<string> */ private static function removeEmptyValues(?array $anArray): array { - return empty($anArray) ? [] : array_filter($anArray, static fn(string $value) => $value !== ''); + return empty($anArray) ? [] : array_values(array_filter($anArray, static fn(string $value) => $value !== '')); } /** - * @param array<string>|string $value - * @return ($value is array ? array<string> : string) + * @param list<string>|string $value + * @return ($value is string ? string : list<string>) */ - private static function decodeSpaces($value): array|string { + private static function decodeSpaces(array|string $value): array|string { if (is_array($value)) { - for ($i = count($value) - 1; $i >= 0; $i--) { - $value[$i] = self::decodeSpaces($value[$i]); + foreach ($value as &$val) { + $val = self::decodeSpaces($val); } } else { $value = trim(str_replace('+', ' ', $value)); @@ -315,8 +315,8 @@ class FreshRSS_Search implements \Stringable { } /** - * @param array<string> $strings - * @return array<string> + * @param list<string> $strings + * @return list<string> */ private static function htmlspecialchars_decodes(array $strings): array { return array_map(static fn(string $s) => htmlspecialchars_decode($s, ENT_QUOTES), $strings); @@ -365,7 +365,7 @@ class FreshRSS_Search implements \Stringable { foreach ($ids_lists as $ids_list) { $feed_ids = explode(',', $ids_list); $feed_ids = self::removeEmptyValues($feed_ids); - /** @var array<int> $feed_ids */ + /** @var list<int> $feed_ids */ $feed_ids = array_map('intval', $feed_ids); if (!empty($feed_ids)) { $this->feed_ids = array_merge($this->feed_ids, $feed_ids); @@ -383,7 +383,7 @@ class FreshRSS_Search implements \Stringable { foreach ($ids_lists as $ids_list) { $feed_ids = explode(',', $ids_list); $feed_ids = self::removeEmptyValues($feed_ids); - /** @var array<int> $feed_ids */ + /** @var list<int> $feed_ids */ $feed_ids = array_map('intval', $feed_ids); if (!empty($feed_ids)) { $this->not_feed_ids = array_merge($this->not_feed_ids, $feed_ids); @@ -408,7 +408,7 @@ class FreshRSS_Search implements \Stringable { } $label_ids = explode(',', $ids_list); $label_ids = self::removeEmptyValues($label_ids); - /** @var array<int> $label_ids */ + /** @var list<int> $label_ids */ $label_ids = array_map('intval', $label_ids); if (!empty($label_ids)) { $this->label_ids = array_merge($this->label_ids, $label_ids); @@ -430,7 +430,7 @@ class FreshRSS_Search implements \Stringable { } $label_ids = explode(',', $ids_list); $label_ids = self::removeEmptyValues($label_ids); - /** @var array<int> $label_ids */ + /** @var list<int> $label_ids */ $label_ids = array_map('intval', $label_ids); if (!empty($label_ids)) { $this->not_label_ids = array_merge($this->not_label_ids, $label_ids); |
