aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Search.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-12-27 12:12:49 +0100
committerGravatar GitHub <noreply@github.com> 2024-12-27 12:12:49 +0100
commitb1d24fbdb7d1cc948c946295035dad6df550fb7e (patch)
tree7b4365a04097a779659474fbb9281a9661512522 /app/Models/Search.php
parent897e4a3f4a273d50c28157edb67612b2d7fa2e6f (diff)
PHPStan 2.0 (#7131)
* PHPStan 2.0 fix https://github.com/FreshRSS/FreshRSS/issues/6989 https://github.com/phpstan/phpstan/releases/tag/2.0.0 https://github.com/phpstan/phpstan/blob/2.0.x/UPGRADING.md * More * More * Done * fix i18n CLI * Restore a PHPStan Next test For work towards PHPStan Level 10 * 4 more on Level 10 * fix getTagsForEntry * API at Level 10 * More Level 10 * Finish Minz at Level 10 * Finish CLI at Level 10 * Finish Controllers at Level 10 * More Level 10 * More * Pass bleedingEdge * Clean PHPStan options and add TODOs * Level 10 for main config * More * Consitency array vs. list * Sanitize themes get_infos * Simplify TagDAO->getTagsForEntries() * Finish reportAnyTypeWideningInVarTag * Prepare checkBenevolentUnionTypes and checkImplicitMixed * Fixes * Refix * Another fix * Casing of __METHOD__ constant
Diffstat (limited to 'app/Models/Search.php')
-rw-r--r--app/Models/Search.php140
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);