Skip to content

Commit

Permalink
reset keys when converting generator to array
Browse files Browse the repository at this point in the history
  • Loading branch information
cappuc committed Mar 19, 2024
1 parent 80c9ac7 commit a573d66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Nodes/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function evaluate(RenderContext $context): mixed
}

if ($output instanceof \Generator) {
$output = iterator_to_array($output);
$output = iterator_to_array($output, preserve_keys: false);
}

foreach ($this->filters as [$filterName, $filterArgs, $filterNamedArgs]) {
Expand Down Expand Up @@ -112,7 +112,7 @@ protected function renderOutput(mixed $output): string
}

if ($output instanceof \Generator) {
$output = iterator_to_array($output);
$output = iterator_to_array($output, preserve_keys: false);
}

if (is_array($output)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Nodes/VariableLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function evaluate(RenderContext $context): mixed
$object = $context->findVariable($name);

if ($object instanceof \Generator && $this->lookups !== []) {
$object = iterator_to_array($object);
$object = iterator_to_array($object, preserve_keys: false);
}

foreach ($this->lookups as $i => $lookup) {
Expand Down

0 comments on commit a573d66

Please sign in to comment.