diff options
author | fox <[email protected]> | 2023-03-07 16:50:13 +0300 |
---|---|---|
committer | fox <[email protected]> | 2023-03-07 16:50:13 +0300 |
commit | c4026b408b824769de6152d0c3bf0eb504a1e935 (patch) | |
tree | c81e07021256dba549c0771c230535192bac0004 /classes | |
parent | d210ae50ad14ded6cf204242bc072c82b9e8e70c (diff) | |
parent | 029cb8f4420a99aef225413f3c32ec1db35717a8 (diff) |
Merge pull request 'Bump PHPStan to 1.10.3, address some new warnings' (#103) from wn/tt-rss:feature/bump-phpstan into master
Reviewed-on: https://dev.tt-rss.org/tt-rss/tt-rss/pulls/103
Diffstat (limited to 'classes')
-rwxr-xr-x | classes/feeditem/rss.php | 17 | ||||
-rwxr-xr-x | classes/pluginhost.php | 2 | ||||
-rwxr-xr-x | classes/pref/feeds.php | 7 | ||||
-rw-r--r-- | classes/prefs.php | 12 |
4 files changed, 15 insertions, 23 deletions
diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index e07fd1d06..b5710ef4f 100755 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -84,15 +84,6 @@ class FeedItem_RSS extends FeedItem_Common { /** @var DOMElement|null */ $contentB = $this->elem->getElementsByTagName("description")->item(0); - if ($contentA && !$contentB) { - return $this->subtree_or_text($contentA); - } - - - if ($contentB && !$contentA) { - return $this->subtree_or_text($contentB); - } - if ($contentA && $contentB) { $resultA = $this->subtree_or_text($contentA); $resultB = $this->subtree_or_text($contentB); @@ -100,6 +91,14 @@ class FeedItem_RSS extends FeedItem_Common { return mb_strlen($resultA) > mb_strlen($resultB) ? $resultA : $resultB; } + if ($contentA) { + return $this->subtree_or_text($contentA); + } + + if ($contentB) { + return $this->subtree_or_text($contentB); + } + return ''; } diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 1159e8ed1..9e3cf1ba1 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -588,7 +588,7 @@ class PluginHost { function lookup_command(string $command) { $command = "-" . strtolower($command); - if (array_key_exists($command, $this->commands) && is_array($this->commands[$command])) { + if (array_key_exists($command, $this->commands)) { return $this->commands[$command]["class"]; } else { return false; diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 679eb12e9..36dfbef76 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -241,7 +241,12 @@ class Pref_Feeds extends Handler_Protected { //$root['param'] += count($cat['items']); } - /* Uncategorized is a special case */ + /** + * Uncategorized is a special case. + * + * Define a minimal array shape to help PHPStan with the type of $cat['items'] + * @var array{items: array<int, array<string, mixed>>} $cat + */ $cat = [ 'id' => 'CAT:0', 'bare_id' => 0, diff --git a/classes/prefs.php b/classes/prefs.php index 378fea293..9d68a14b7 100644 --- a/classes/prefs.php +++ b/classes/prefs.php @@ -325,14 +325,6 @@ class Prefs { return self::get_instance()->_set($pref_name, $value, $owner_uid, $profile_id); } - private function _delete(string $pref_name, int $owner_uid, ?int $profile_id): bool { - $sth = $this->pdo->prepare("DELETE FROM ttrss_user_prefs2 - WHERE pref_name = :name AND owner_uid = :uid AND - (profile = :profile OR (:profile IS NULL AND profile IS NULL))"); - - return $sth->execute(["uid" => $owner_uid, "profile" => $profile_id, "name" => $pref_name ]); - } - /** * @param bool|int|string $value */ @@ -350,10 +342,6 @@ class Prefs { $value = Config::cast_to($value, $type_hint); - // is this a good idea or not? probably not (user-set value remains user-set even if its at default) - //if ($value == $def_val) - // return $this->_delete($pref_name, $owner_uid, $profile_id); - if ($value == $this->_get($pref_name, $owner_uid, $profile_id)) return false; |