mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Fixed usage of LimitIterator
This commit is contained in:
committed by
Fabien Potencier
parent
84df881b8b
commit
f76e67f91d
@@ -697,7 +697,7 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null, $prese
|
||||
}
|
||||
|
||||
if ($start >= 0 && $length >= 0) {
|
||||
return iterator_to_array(new LimitIterator($item, $start, $length), $preserveKeys);
|
||||
return iterator_to_array(new LimitIterator($item, $start, $length === null ? -1 : $length), $preserveKeys);
|
||||
}
|
||||
|
||||
$item = iterator_to_array($item, $preserveKeys);
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
{{ '1234'|slice(1) }}
|
||||
{{ '1234'[1:] }}
|
||||
{{ '1234'[:1] }}
|
||||
|
||||
{{ arr|slice(3)|join('') }}
|
||||
{{ arr[2:]|join('') }}
|
||||
--DATA--
|
||||
return array('start' => 1, 'length' => 2, 'arr' => new ArrayObject(array(1, 2, 3, 4)))
|
||||
--EXPECT--
|
||||
@@ -40,3 +43,6 @@ bc
|
||||
234
|
||||
234
|
||||
1
|
||||
|
||||
4
|
||||
34
|
||||
Reference in New Issue
Block a user