Update EachHelper.php

For arrays that contain only one element, `(array_keys($tmp) == range(0, count($tmp) - 1)` always returns true.

`(array_keys($tmp) === range(0, count($tmp) - 1)` works as expected.
This commit is contained in:
John Slegers 2014-07-02 18:59:58 +02:00
parent 3c58c8eeed
commit c28709eb76

View File

@ -59,7 +59,7 @@ class EachHelper implements Helper
$template->setStopToken(false);
$buffer = $template->render($context);
} elseif (is_array($tmp) || $tmp instanceof \Traversable) {
$isList = is_array($tmp) && (array_keys($tmp) == range(0, count($tmp) - 1));
$isList = is_array($tmp) && (array_keys($tmp) === range(0, count($tmp) - 1));
$index = 0;
$lastIndex = $isList ? (count($tmp) - 1) : false;