From 6e3a1c401608146e5302f7124404b7a0895484e0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Dec 2011 08:37:53 +0100 Subject: [PATCH] added missing preserveKeys argument to the reverse filter --- CHANGELOG | 1 + lib/Twig/Extension/Core.php | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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); } /** -- 1.7.2.5