From 2eb3c150c2f63b4e4e11ec699fae144e60dc7109 Mon Sep 17 00:00:00 2001 From: wn_ Date: Mon, 6 Jan 2025 14:30:54 +0000 Subject: Fix a return type warning in 'Pref_Filters'. 'Pref_Filters#get_details()' gets passed the ID of an existing filter, so we don't need to handle some edge case of it not existing. --- classes/Pref_Filters.php | 84 +++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 44 deletions(-) (limited to 'classes') diff --git a/classes/Pref_Filters.php b/classes/Pref_Filters.php index 719094263..26ae03e16 100644 --- a/classes/Pref_Filters.php +++ b/classes/Pref_Filters.php @@ -763,58 +763,54 @@ class Pref_Filters extends Handler_Protected { ->group_by_expr('f.title, f.match_any_rule, f.inverse') ->find_one(); - if ($filter) { - $title = $filter->title ?: __('[No caption]'); - $title_summary = [ - sprintf( - _ngettext("%s (%d rule)", "%s (%d rules)", (int) $filter->num_rules), - $title, - $filter->num_rules)]; - - if ($filter->match_any_rule) array_push($title_summary, __("matches any rule")); - if ($filter->inverse) array_push($title_summary, __("inverse")); - - $actions = ORM::for_table("ttrss_filters2_actions") - ->where("filter_id", $id) - ->order_by_asc('id') - ->find_many(); - - /** @var array $actions_summary */ - $actions_summary = []; - $cumulative_score = 0; - - // we're going to show a summary adjustment so we skip individual score action descriptions here - foreach ($actions as $action) { - if ($action->action_id == self::ACTION_SCORE) { - $cumulative_score += (int) $action->action_param; - continue; - } + $title = $filter->title ?: __('[No caption]'); + $title_summary = [ + sprintf( + _ngettext("%s (%d rule)", "%s (%d rules)", (int) $filter->num_rules), + $title, + $filter->num_rules)]; + + if ($filter->match_any_rule) array_push($title_summary, __("matches any rule")); + if ($filter->inverse) array_push($title_summary, __("inverse")); + + $actions = ORM::for_table("ttrss_filters2_actions") + ->where("filter_id", $id) + ->order_by_asc('id') + ->find_many(); - array_push($actions_summary, "
  • " . self::_get_action_name($action) . "
  • "); - } + /** @var array $actions_summary */ + $actions_summary = []; + $cumulative_score = 0; - // inject a fake action description using cumulative filter score - if ($cumulative_score != 0) { - array_unshift($actions_summary, - "
  • " . self::_get_action_name(["action_id" => self::ACTION_SCORE, "action_param" => $cumulative_score]) . "
  • "); + // we're going to show a summary adjustment so we skip individual score action descriptions here + foreach ($actions as $action) { + if ($action->action_id == self::ACTION_SCORE) { + $cumulative_score += (int) $action->action_param; + continue; } - if (count($actions_summary) > self::MAX_ACTIONS_TO_DISPLAY) { - $actions_not_shown = count($actions_summary) - self::MAX_ACTIONS_TO_DISPLAY; - $actions_summary = array_slice($actions_summary, 0, self::MAX_ACTIONS_TO_DISPLAY); + array_push($actions_summary, "
  • " . self::_get_action_name($action) . "
  • "); + } - array_push($actions_summary, - "
  • " . sprintf(_ngettext("(+%d action)", "(+%d actions)", $actions_not_shown), $actions_not_shown)) . "
  • "; - } + // inject a fake action description using cumulative filter score + if ($cumulative_score != 0) { + array_unshift($actions_summary, + "
  • " . self::_get_action_name(["action_id" => self::ACTION_SCORE, "action_param" => $cumulative_score]) . "
  • "); + } - return [ - 'title' => $title, - 'title_summary' => implode(', ', $title_summary), - 'actions_summary' => implode('', $actions_summary), - ]; + if (count($actions_summary) > self::MAX_ACTIONS_TO_DISPLAY) { + $actions_not_shown = count($actions_summary) - self::MAX_ACTIONS_TO_DISPLAY; + $actions_summary = array_slice($actions_summary, 0, self::MAX_ACTIONS_TO_DISPLAY); + + array_push($actions_summary, + "
  • " . sprintf(_ngettext("(+%d action)", "(+%d actions)", $actions_not_shown), $actions_not_shown)) . "
  • "; } - return []; + return [ + 'title' => $title, + 'title_summary' => implode(', ', $title_summary), + 'actions_summary' => implode('', $actions_summary), + ]; } function join(): void { -- cgit v1.2.3-54-g00ecf