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
This commit is contained in:
wn_
2022-08-12 15:31:19 +00:00
parent a63c949a55
commit 3487c922b3
17 changed files with 71 additions and 72 deletions

View File

@@ -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,