summaryrefslogtreecommitdiff
path: root/classes/rssutils.php
diff options
context:
space:
mode:
authorwn_ <[email protected]>2022-08-12 15:31:19 +0000
committerwn_ <[email protected]>2022-08-12 17:58:38 +0000
commit3487c922b3f34449fecdddebe1fd2ee3b8c42e65 (patch)
tree57b18bf1a6ec210aa26a80cf1f2d2fdf0888f5da /classes/rssutils.php
parenta63c949a5522a8fdeae2dfa77bb39565727f7a0a (diff)
Replace use of 'array_merge' with the spread operator and 'array_push' in various places.
This isn't supported for arrays with string keys until PHP 8.1. https://wiki.php.net/rfc/spread_operator_for_array
Diffstat (limited to 'classes/rssutils.php')
-rwxr-xr-xclasses/rssutils.php15
1 files changed, 6 insertions, 9 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php
index e590f1665..fe295417a 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"),
- fn($f) => filemtime($f) < time() - 86400 * Config::get(Config::CACHE_MAX_DAYS));
+ fn(string $f) => filemtime($f) < time() - 86400 * Config::get(Config::CACHE_MAX_DAYS));
foreach ($icon_files as $icon) {
$feed_id = basename($icon, ".ico");
@@ -733,7 +733,7 @@ class RSSUtils {
$article_labels = Article::_get_labels($base_entry_id, $feed_obj->owner_uid);
$existing_tags = Article::_get_tags($base_entry_id, $feed_obj->owner_uid);
- $entry_tags = array_unique(array_merge($entry_tags, $existing_tags));
+ $entry_tags = array_unique([...$entry_tags, ...$existing_tags]);
} else {
$base_entry_id = false;
$entry_stored_hash = "";
@@ -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(fn($f) => $f['id'], $matched_filters);
+ $matched_filter_ids = array_map(fn(array $f) => $f['id'], $matched_filters);
if (count($matched_filter_ids) > 0) {
$filter_objs = ORM::for_table('ttrss_filters2')
@@ -1190,8 +1190,7 @@ class RSSUtils {
// check for manual tags (we have to do it here since they're loaded from filters)
foreach ($article_filters as $f) {
if ($f["type"] == "tag") {
- $entry_tags = array_merge($entry_tags,
- FeedItem_Common::normalize_categories(explode(",", $f["param"])));
+ $entry_tags = [...$entry_tags, ...FeedItem_Common::normalize_categories(explode(",", $f["param"]))];
}
}
@@ -1796,12 +1795,10 @@ class RSSUtils {
owner_uid = ? AND enabled = true ORDER BY order_id, title");
$sth->execute([$owner_uid]);
- $check_cats = array_merge(
- Feeds::_get_parent_cats($cat_id, $owner_uid),
- [$cat_id]);
+ $check_cats = [...Feeds::_get_parent_cats($cat_id, $owner_uid), $cat_id];
$check_cats_str = join(",", $check_cats);
- $check_cats_fullids = array_map(fn($a) => "CAT:$a", $check_cats);
+ $check_cats_fullids = array_map(fn(int $a) => "CAT:$a", $check_cats);
while ($line = $sth->fetch()) {
$filter_id = $line["id"];