From 182bfc9aea30213b0de9e077ba059ce59528b740 Mon Sep 17 00:00:00 2001 From: John Slegers Date: Thu, 3 Jul 2014 16:53:22 +0200 Subject: [PATCH] Patch 2 for arrays that contain only one elements 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. My local test environment = Linux Mint + PHP 5.4. This patch is identical to https://github.com/XaminProject/handlebars.php/pull/66, but applies to a different part of the code. --- src/Handlebars/Template.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Handlebars/Template.php b/src/Handlebars/Template.php index 3846c46..687bc6f 100644 --- a/src/Handlebars/Template.php +++ b/src/Handlebars/Template.php @@ -13,6 +13,7 @@ * @author Dmitriy Simushev * @author majortom731 * @author Jeff Turcotte + * @author John Slegers * @copyright 2010-2012 (c) Justin Hileman * @copyright 2012 (c) ParsPooyesh Co * @copyright 2013 (c) Behrooz Shabani @@ -353,7 +354,7 @@ class Template $buffer = ''; if (is_array($sectionVar) || $sectionVar instanceof \Traversable) { $isList = is_array($sectionVar) && - (array_keys($sectionVar) == range(0, count($sectionVar) - 1)); + (array_keys($sectionVar) === range(0, count($sectionVar) - 1)); $index = 0; $lastIndex = $isList ? (count($sectionVar) - 1) : false;