diff --git a/classes/db/migrations.php b/classes/db/migrations.php index 5f969c513..ffce2af5f 100644 --- a/classes/db/migrations.php +++ b/classes/db/migrations.php @@ -189,14 +189,11 @@ class Db_Migrations { $filename = "{$this->base_path}/{$this->base_filename}"; if (file_exists($filename)) { - $lines = array_filter(preg_split("/[\r\n]/", file_get_contents($filename)), - function ($line) { - return strlen(trim($line)) > 0 && strpos($line, "--") !== 0; - }); + $lines = array_filter(preg_split("/[\r\n]/", file_get_contents($filename)), + fn($line) => strlen(trim($line)) > 0 && strpos($line, "--") !== 0); - return array_filter(explode(";", implode("", $lines)), function ($line) { - return strlen(trim($line)) > 0 && !in_array(strtolower($line), ["begin", "commit"]); - }); + return array_filter(explode(";", implode("", $lines)), + fn($line) => strlen(trim($line)) > 0 && !in_array(strtolower($line), ["begin", "commit"])); } else { user_error("Requested schema file ${filename} not found.", E_USER_ERROR); diff --git a/classes/digest.php b/classes/digest.php index 15203166b..3e943e6dd 100644 --- a/classes/digest.php +++ b/classes/digest.php @@ -163,9 +163,7 @@ class Digest $article_labels_formatted = ""; if (is_array($article_labels) && count($article_labels) > 0) { - $article_labels_formatted = implode(", ", array_map(function($a) { - return $a[1]; - }, $article_labels)); + $article_labels_formatted = implode(", ", array_map(fn($a) => $a[1], $article_labels)); } $tpl->setVariable('FEED_TITLE', $line["feed_title"]); diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 3e651297e..01b58005b 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -872,13 +872,13 @@ class Pref_Prefs extends Handler_Protected { PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED), PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); - $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { - return in_array(get_class($plugin), $feed_handler_whitelist) === false; }); + $feed_handlers = array_filter($feed_handlers, + fn($plugin) => in_array(get_class($plugin), $feed_handler_whitelist) === false); if (count($feed_handlers) > 0) { print_error( T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: %s" , - implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) + implode(", ", array_map(fn($plugin) => get_class($plugin), $feed_handlers)) ) . " (".__("More info...").")" ); } @@ -1067,9 +1067,7 @@ class Pref_Prefs extends Handler_Protected { } } - $rv = array_values(array_filter($rv, function ($item) { - return $item["rv"]["need_update"]; - })); + $rv = array_values(array_filter($rv, fn($item) => $item["rv"]["need_update"])); return $rv; } diff --git a/classes/rssutils.php b/classes/rssutils.php index e039284f2..e590f1665 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -39,7 +39,7 @@ class RSSUtils { // check icon files once every Config::get(Config::CACHE_MAX_DAYS) days $icon_files = array_filter(glob(Config::get(Config::ICONS_DIR) . "/*.ico"), - function($f) { return filemtime($f) < time() - 86400 * Config::get(Config::CACHE_MAX_DAYS); }); + fn($f) => filemtime($f) < time() - 86400 * Config::get(Config::CACHE_MAX_DAYS)); foreach ($icon_files as $icon) { $feed_id = basename($icon, ".ico"); @@ -865,7 +865,7 @@ class RSSUtils { $pluginhost->run_hooks(PluginHost::HOOK_FILTER_TRIGGERED, $feed, $feed_obj->owner_uid, $article, $matched_filters, $matched_rules, $article_filters); - $matched_filter_ids = array_map(function($f) { return $f['id']; }, $matched_filters); + $matched_filter_ids = array_map(fn($f) => $f['id'], $matched_filters); if (count($matched_filter_ids) > 0) { $filter_objs = ORM::for_table('ttrss_filters2') @@ -1801,7 +1801,7 @@ class RSSUtils { [$cat_id]); $check_cats_str = join(",", $check_cats); - $check_cats_fullids = array_map(function($a) { return "CAT:$a"; }, $check_cats); + $check_cats_fullids = array_map(fn($a) => "CAT:$a", $check_cats); while ($line = $sth->fetch()) { $filter_id = $line["id"];