From 721bebc3615777a0336c50d41c58da0f8936aa4a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 Aug 2012 14:04:14 +0200 Subject: [PATCH] fixed an error when a token parser pass a closure as a test to the subparse() method (closes #818) --- CHANGELOG | 2 +- lib/Twig/Parser.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1c62de1..fa87445 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.9.3 (2012-XX-XX) - * n/a + * fixed an error when a token parser pass a closure as a test to the subparse() method * 1.9.2 (2012-08-25) diff --git a/lib/Twig/Parser.php b/lib/Twig/Parser.php index 66f5d2a..5264238 100644 --- a/lib/Twig/Parser.php +++ b/lib/Twig/Parser.php @@ -162,7 +162,12 @@ class Twig_Parser implements Twig_ParserInterface $subparser = $this->handlers->getTokenParser($token->getValue()); if (null === $subparser) { if (null !== $test) { - throw new Twig_Error_Syntax(sprintf('Unexpected tag name "%s" (expecting closing tag for the "%s" tag defined near line %s)', $token->getValue(), $test[0]->getTag(), $lineno), $token->getLine(), $this->stream->getFilename()); + $error = sprintf('Unexpected tag name "%s"', $token->getValue()); + if (is_array($test) && isset($test[0]) && is_object($test[0])) { + $error .= sprintf(' (expecting closing tag for the "%s" tag defined near line %s)', $test[0]->getTag(), $lineno); + } + + throw new Twig_Error_Syntax($error, $token->getLine(), $this->stream->getFilename()); } $message = sprintf('Unknown tag name "%s"', $token->getValue()); -- 1.7.2.5