From: Fabien Potencier Date: Sat, 3 Dec 2011 07:37:53 +0000 (+0100) Subject: added missing preserveKeys argument to the reverse filter X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=6e3a1c401608146e5302f7124404b7a0895484e0;p=web%2Fkonrad%2Ftwig.git added missing preserveKeys argument to the reverse filter --- diff --git a/CHANGELOG b/CHANGELOG index 40d6281..e96f033 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ * 1.4.0 + * added missing preserveKeys argument to the reverse filter * fixed macros containing filter tag calls * 1.4.0-RC2 (2011-11-27) diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index d9e6cdf..1dbf6be 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -412,21 +412,22 @@ function twig_get_array_keys_filter($array) /** * Reverses an array. * - * @param array|Traversable $array An array or a Traversable instance + * @param array|Traversable $array An array or a Traversable instance + * @param Boolean $preserveKeys Whether to preserve key or not * * return array The array reversed */ -function twig_reverse_filter($array) +function twig_reverse_filter($array, $preserveKeys = false) { if (is_object($array) && $array instanceof Traversable) { - return array_reverse(iterator_to_array($array)); + return array_reverse(iterator_to_array($array), $preserveKeys); } if (!is_array($array)) { return array(); } - return array_reverse($array); + return array_reverse($array, $preserveKeys); } /**