function twig_join_filter($value, $glue = '')
{
if ($value instanceof Traversable) {
- $value = iterator_to_array($value);
+ $value = iterator_to_array($value, false);
}
return implode($glue, (array) $value);
return $value;
}
-class Foo implements IteratorAggregate
+class Foo implements Iterator
{
const BAR_NAME = 'bar';
+ public $position = 0;
+ public $array = array(1, 2);
+
public function bar($param1 = null, $param2 = null)
{
return 'bar'.($param1 ? '_'.$param1 : '').($param2 ? '-'.$param2 : '');
}
- public function getIterator()
- {
- return new ArrayObject(array(1, 2));
- }
-
public function getFoo()
{
return 'foo';
{
return strtolower($value);
}
+
+ public function rewind()
+ {
+ $this->position = 0;
+ }
+
+ public function current()
+ {
+ return $this->array[$this->position];
+ }
+
+ public function key()
+ {
+ return 'a';
+ }
+
+ public function next()
+ {
+ ++$this->position;
+ }
+
+ public function valid()
+ {
+ return isset($this->array[$this->position]);
+ }
}
class TestTokenParser_☃ extends Twig_TokenParser