Remove some PHPStan ignores and make others rule-specific.

This commit is contained in:
wn_
2024-11-12 03:38:45 +00:00
parent a784305cc7
commit dca2ae60a1
9 changed files with 8 additions and 16 deletions

View File

@@ -300,10 +300,9 @@ class API extends Handler {
}
function getArticle(): bool {
$article_ids = explode(',', clean($_REQUEST['article_id'] ?? ''));
$article_ids = array_filter(explode(',', clean($_REQUEST['article_id'] ?? '')));
$sanitize_content = self::_param_to_bool($_REQUEST['sanitize'] ?? true);
// @phpstan-ignore-next-line
if (count($article_ids)) {
$entries = ORM::for_table('ttrss_entries')
->table_alias('e')

View File

@@ -77,7 +77,7 @@ class Debug {
*/
public static function map_loglevel(int $level) : int {
if (in_array($level, self::ALL_LOG_LEVELS)) {
/** @phpstan-ignore-next-line */
/** @phpstan-ignore return.type (yes it is a Debug::LOG_* value) */
return $level;
} else {
user_error("Passed invalid debug log level: $level", E_USER_WARNING);

View File

@@ -43,7 +43,6 @@ class FeedItem_Atom extends FeedItem_Common {
$links = $this->elem->getElementsByTagName("link");
foreach ($links as $link) {
/** @phpstan-ignore-next-line */
if ($link->hasAttribute("href") &&
(!$link->hasAttribute("rel")
|| $link->getAttribute("rel") == "alternate"
@@ -181,7 +180,6 @@ class FeedItem_Atom extends FeedItem_Common {
$encs = [];
foreach ($links as $link) {
/** @phpstan-ignore-next-line */
if ($link->hasAttribute("href") && $link->hasAttribute("rel")) {
$base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link);

View File

@@ -1067,7 +1067,7 @@ class Feeds extends Handler_Protected {
if (!$url) return ["code" => 2];
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_PRE_SUBSCRIBE,
/** @phpstan-ignore-next-line */
/** @phpstan-ignore closure.unusedUse, closure.unusedUse, closure.unusedUse */
function ($result) use (&$url, &$auth_login, &$auth_pass) {
// arguments are updated inside the hook (if needed)
},

View File

@@ -53,9 +53,8 @@ class Handler_Public extends Handler {
$handler = $tmppluginhost->get_feed_handler(
PluginHost::feed_to_pfeed_id((int)$feed));
if ($handler) {
// 'get_headlines' is implemented by the plugin.
// @phpstan-ignore-next-line
if ($handler && implements_interface($handler, 'IVirtualFeed')) {
/** @var Plugin&IVirtualFeed $handler */
$qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id((int)$feed), $params);
} else {
user_error("Failed to find handler for plugin feed ID: $feed", E_USER_ERROR);

View File

@@ -386,8 +386,7 @@ class PluginHost {
* @param PluginHost::HOOK_* $type
*/
function del_hook(string $type, Plugin $sender): void {
/** @phpstan-ignore function.alreadyNarrowedType ($type might not exist) */
if (is_array($this->hooks[$type])) {
if (array_key_exists($type, $this->hooks)) {
foreach (array_keys($this->hooks[$type]) as $prio) {
$key = array_search($sender, $this->hooks[$type][$prio]);

View File

@@ -115,9 +115,6 @@ class Pref_Filters extends Handler_Protected {
$glue = $filter['match_any_rule'] ? " OR " : " AND ";
$scope_qpart = join($glue, $scope_qparts);
/** @phpstan-ignore-next-line */
if (!$scope_qpart) $scope_qpart = "true";
$rv = array();
//while ($found < $limit && $offset < $limit * 1000 && time() - $started < ini_get("max_execution_time") * 0.7) {

View File

@@ -50,7 +50,7 @@ class UserHelper {
*/
public static function map_access_level(int $level) : int {
if (in_array($level, self::ACCESS_LEVELS)) {
/** @phpstan-ignore-next-line */
/** @phpstan-ignore return.type (yes it is a UserHelper::ACCESS_LEVEL_* value) */
return $level;
} else {
user_error("Passed invalid user access level: $level", E_USER_WARNING);

View File

@@ -215,7 +215,7 @@
}
if (isset($options["daemon"])) {
// @phpstan-ignore-next-line
// @phpstan-ignore while.alwaysTrue (single process daemon will always run)
while (true) {
$quiet = (isset($options["quiet"])) ? "--quiet" : "";
$log = isset($options['log']) ? '--log '.$options['log'] : '';