Skip to content

Commit

Permalink
fix(occ): Fix compatibility with PHP<8.2
Browse files Browse the repository at this point in the history
iterator_to_array cannot take an array parameter prior to 8.2

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Jul 8, 2024
1 parent 3e28a89 commit 61763bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/Command/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ protected function configure() {
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) {
Expand Down

0 comments on commit 61763bf

Please sign in to comment.