mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Use LimitIterator on Iterable objects within the splice filter
This commit is contained in:
@@ -692,7 +692,16 @@ function twig_array_merge($arr1, $arr2)
|
||||
function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
|
||||
{
|
||||
if ($item instanceof Traversable) {
|
||||
$item = iterator_to_array($item, false);
|
||||
|
||||
if ($item instanceof IteratorAggregate) {
|
||||
$item = $item->getIterator();
|
||||
}
|
||||
|
||||
if ($start >= 0 && $length >= 0) {
|
||||
return iterator_to_array(new LimitIterator($item, $start, $length), $preserveKeys);
|
||||
}
|
||||
|
||||
$item = iterator_to_array($item, $preserveKeys);
|
||||
}
|
||||
|
||||
if (is_array($item)) {
|
||||
|
||||
Reference in New Issue
Block a user