1--TEST--
2"for" tag iterates over iterable and countable objects
3--TEMPLATE--
4{% for item in items %}
5  * {{ item }}
6  * {{ loop.index }}/{{ loop.index0 }}
7  * {{ loop.revindex }}/{{ loop.revindex0 }}
8  * {{ loop.first }}/{{ loop.last }}/{{ loop.length }}
9
10{% endfor %}
11
12{% for key, value in items %}
13  * {{ key }}/{{ value }}
14{% endfor %}
15
16{% for key in items|keys %}
17  * {{ key }}
18{% endfor %}
19--DATA--
20class ItemsIteratorCountable implements Iterator, \Countable
21{
22  protected $values = ['foo' => 'bar', 'bar' => 'foo'];
23  public function current() { return current($this->values); }
24  public function key() { return key($this->values); }
25  public function next() { return next($this->values); }
26  public function rewind() { return reset($this->values); }
27  public function valid() { return false !== current($this->values); }
28  public function count() { return count($this->values); }
29}
30return ['items' => new ItemsIteratorCountable()]
31--EXPECT--
32  * bar
33  * 1/0
34  * 2/1
35  * 1//2
36
37  * foo
38  * 2/1
39  * 1/0
40  * /1/2
41
42
43  * foo/bar
44  * bar/foo
45
46  * foo
47  * bar
48