Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed the join filter when several items have the same key

  • Loading branch information...
commit b44dba5c7c1d13f514d55cadcdc4fbc38ad4e652 1 parent 64e3ce6
@fabpot authored
Showing with 30 additions and 7 deletions.
  1. +1 −1  lib/Twig/Extension/Core.php
  2. +29 −6 test/Twig/Tests/integrationTest.php
View
2  lib/Twig/Extension/Core.php
@@ -489,7 +489,7 @@ function twig_array_merge($arr1, $arr2)
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);
View
35 test/Twig/Tests/integrationTest.php
@@ -114,20 +114,18 @@ function test_foo($value = 'foo')
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';
@@ -157,6 +155,31 @@ public function strToLower($value)
{
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
Please sign in to comment.
Something went wrong with that request. Please try again.