remove $is_multitarget return in parseMultitargetExpression
authornikic <+@ni-po.com>
Mon, 20 Dec 2010 17:39:16 +0000 (18:39 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Mon, 20 Dec 2010 18:06:42 +0000 (19:06 +0100)
Furthermore slightly reordered code thus removing redundant expect()

lib/Twig/ExpressionParser.php
lib/Twig/TokenParser/Set.php

index fdcbbe0..2a61583 100644 (file)
@@ -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);
     }
 }
index 7bf935e..0cc1960 100644 (file)
@@ -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);