From 3487c922b3f34449fecdddebe1fd2ee3b8c42e65 Mon Sep 17 00:00:00 2001 From: wn_ Date: Fri, 12 Aug 2022 15:31:19 +0000 Subject: 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 --- plugins/af_comics/init.php | 5 ++++- plugins/af_redditimgur/init.php | 6 +++--- plugins/cache_starred_images/init.php | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php index a9a8f3faa..0649cf92c 100755 --- a/plugins/af_comics/init.php +++ b/plugins/af_comics/init.php @@ -19,7 +19,10 @@ class Af_Comics extends Plugin { require_once __DIR__ . "/filter_base.php"; - $filters = array_merge(glob(__DIR__ . "/filters.local/*.php"), glob(__DIR__ . "/filters/*.php")); + $filters = [ + ...(glob(__DIR__ . "/filters.local/*.php") ?: []), + ...(glob(__DIR__ . "/filters/*.php") ?: []), + ]; $names = []; foreach ($filters as $file) { diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 65a753056..898f0b49c 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -376,11 +376,11 @@ class Af_RedditImgur extends Plugin { } if ($post_is_nsfw && count($apply_nsfw_tags) > 0) { - $article["tags"] = array_merge($article["tags"], $apply_nsfw_tags); + array_push($article["tags"], ...$apply_nsfw_tags); } if (count($link_flairs) > 0) { - $article["tags"] = array_merge($article["tags"], FeedItem_Common::normalize_categories($link_flairs)); + array_push($article["tags"], ...FeedItem_Common::normalize_categories($link_flairs)); } $article["num_comments"] = $num_comments; @@ -937,7 +937,7 @@ class Af_RedditImgur extends Plugin { $src_domain = parse_url($src, PHP_URL_HOST); if ($src_domain) - foreach (array_merge($this->domain_blacklist, $also_blacklist) as $domain) { + foreach ([...$this->domain_blacklist, ...$also_blacklist] as $domain) { if (strstr($src_domain, $domain) !== false) { return true; } diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index feec81d62..eed5264c6 100755 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -84,10 +84,10 @@ class Cache_Starred_Images extends Plugin { Debug::log("expiring {$this->cache->get_dir()} and {$this->cache_status->get_dir()}..."); - $files = array_merge( - glob($this->cache->get_dir() . "/*-*"), - glob($this->cache_status->get_dir() . "/*.status") - ); + $files = [ + ...(glob($this->cache->get_dir() . "/*-*") ?: []), + ...(glob($this->cache_status->get_dir() . "/*.status") ?: []), + ]; asort($files); -- cgit v1.2.3