summaryrefslogtreecommitdiff
path: root/classes/counters.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/counters.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/counters.php')
-rw-r--r--classes/counters.php38
1 files changed, 17 insertions, 21 deletions
diff --git a/classes/counters.php b/classes/counters.php
index 8756b5acf..bc4d2d4a3 100644
--- a/classes/counters.php
+++ b/classes/counters.php
@@ -5,13 +5,13 @@ class Counters {
* @return array<int, array<string, int|string>>
*/
static function get_all(): array {
- return array_merge(
- self::get_global(),
- self::get_virt(),
- self::get_labels(),
- self::get_feeds(),
- self::get_cats()
- );
+ return [
+ ...self::get_global(),
+ ...self::get_virt(),
+ ...self::get_labels(),
+ ...self::get_feeds(),
+ ...self::get_cats(),
+ ];
}
/**
@@ -20,13 +20,13 @@ class Counters {
* @return array<int, array<string, int|string>>
*/
static function get_conditional(array $feed_ids = null, array $label_ids = null): array {
- return array_merge(
- self::get_global(),
- self::get_virt(),
- self::get_labels($label_ids),
- self::get_feeds($feed_ids),
- self::get_cats(is_array($feed_ids) ? Feeds::_cats_of($feed_ids, $_SESSION["uid"], true) : null)
- );
+ return [
+ ...self::get_global(),
+ ...self::get_virt(),
+ ...self::get_labels($label_ids),
+ ...self::get_feeds($feed_ids),
+ ...self::get_cats(is_array($feed_ids) ? Feeds::_cats_of($feed_ids, $_SESSION["uid"], true) : null)
+ ];
}
/**
@@ -93,11 +93,7 @@ class Counters {
ue.feed_id = f.id AND
ue.owner_uid = ?");
- $sth->execute(array_merge(
- [$_SESSION['uid']],
- $cat_ids,
- [$_SESSION['uid']]
- ));
+ $sth->execute([$_SESSION['uid'], ...$cat_ids, $_SESSION['uid']]);
} else {
$sth = $pdo->prepare("SELECT fc.id,
@@ -170,7 +166,7 @@ class Counters {
WHERE f.id = ue.feed_id AND ue.owner_uid = ? AND f.id IN ($feed_ids_qmarks)
GROUP BY f.id");
- $sth->execute(array_merge([$_SESSION['uid']], $feed_ids));
+ $sth->execute([$_SESSION['uid'], ...$feed_ids]);
} else {
$sth = $pdo->prepare("SELECT f.id,
f.title,
@@ -319,7 +315,7 @@ class Counters {
LEFT JOIN ttrss_user_entries AS u1 ON u1.ref_id = article_id AND u1.owner_uid = ?
WHERE ttrss_labels2.owner_uid = ? AND ttrss_labels2.id IN ($label_ids_qmarks)
GROUP BY ttrss_labels2.id, ttrss_labels2.caption");
- $sth->execute(array_merge([$_SESSION["uid"], $_SESSION["uid"]], $label_ids));
+ $sth->execute([$_SESSION["uid"], $_SESSION["uid"], ...$label_ids]);
} else {
$sth = $pdo->prepare("SELECT id,
caption,