From d88a3c805f18c8ea67dbc707cce6cf86ccd42364 Mon Sep 17 00:00:00 2001 From: nikic <+@ni-po.com> Date: Mon, 20 Dec 2010 18:39:16 +0100 Subject: [PATCH] remove $is_multitarget return in parseMultitargetExpression Furthermore slightly reordered code thus removing redundant expect() --- lib/Twig/ExpressionParser.php | 9 ++------- lib/Twig/TokenParser/Set.php | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/Twig/ExpressionParser.php b/lib/Twig/ExpressionParser.php index fdcbbe0..2a61583 100644 --- a/lib/Twig/ExpressionParser.php +++ b/lib/Twig/ExpressionParser.php @@ -336,13 +336,8 @@ class Twig_ExpressionParser public function parseMultitargetExpression() { - $lineno = $this->parser->getCurrentToken()->getLine(); $targets = array(); - $is_multitarget = false; while (true) { - if (!empty($targets)) { - $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Multiple assignments must be separated by a comma (,)'); - } if ($this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ')') || $this->parser->getStream()->test(Twig_Token::VAR_END_TYPE) || $this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) @@ -353,9 +348,9 @@ class Twig_ExpressionParser if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, ',')) { break; } - $is_multitarget = true; + $this->parser->getStream()->next(); } - return array($is_multitarget, new Twig_Node($targets)); + return new Twig_Node($targets); } } diff --git a/lib/Twig/TokenParser/Set.php b/lib/Twig/TokenParser/Set.php index 7bf935e..0cc1960 100644 --- a/lib/Twig/TokenParser/Set.php +++ b/lib/Twig/TokenParser/Set.php @@ -26,7 +26,7 @@ class Twig_TokenParser_Set extends Twig_TokenParser $capture = false; if ($stream->test(Twig_Token::OPERATOR_TYPE, '=')) { $stream->next(); - list(, $values) = $this->parser->getExpressionParser()->parseMultitargetExpression(); + $values = $this->parser->getExpressionParser()->parseMultitargetExpression(); $stream->expect(Twig_Token::BLOCK_END_TYPE); -- 1.7.2.5