summaryrefslogtreecommitdiff
path: root/plugins
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 /plugins
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 'plugins')
-rwxr-xr-xplugins/af_comics/init.php5
-rwxr-xr-xplugins/af_redditimgur/init.php6
-rwxr-xr-xplugins/cache_starred_images/init.php8
3 files changed, 11 insertions, 8 deletions
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);