aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-07-08 17:02:43 +0200
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>2024-08-06 12:13:26 +0200
commitbb94da69a611d0ff225a48244ad1b22b653dde1c (patch)
treeca1f6c7ab4cc5589fe564fea8683fb711262d0f9 /core/Command
parentdb16a32ac3bf851b0f16034c6fbf348f3bb30577 (diff)
downloadnextcloud-server-bb94da69a611d0ff225a48244ad1b22b653dde1c.tar.gz
nextcloud-server-bb94da69a611d0ff225a48244ad1b22b653dde1c.zip
fix(occ): Fix compatibility with PHP<8.2
iterator_to_array cannot take an array parameter prior to 8.2 Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/Base.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/Command/Base.php b/core/Command/Base.php
index a19b3586f0a..0af5981e942 100644
--- a/core/Command/Base.php
+++ b/core/Command/Base.php
@@ -40,10 +40,12 @@ class Base extends Command implements CompletionAwareInterface {
protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, iterable $items, string $prefix = ' - '): void {
switch ($input->getOption('output')) {
case self::OUTPUT_FORMAT_JSON:
- $output->writeln(json_encode(iterator_to_array($items)));
+ $items = (is_array($items) ? $items : iterator_to_array($items));
+ $output->writeln(json_encode($items));
break;
case self::OUTPUT_FORMAT_JSON_PRETTY:
- $output->writeln(json_encode(iterator_to_array($items), JSON_PRETTY_PRINT));
+ $items = (is_array($items) ? $items : iterator_to_array($items));
+ $output->writeln(json_encode($items, JSON_PRETTY_PRINT));
break;
default:
foreach ($items as $key => $item) {