Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

simplification

  • Loading branch information...
commit d41d10ca28f7006fb4d00d0fe95b4d6d31bc55aa 1 parent 2dbb420
@arnaud-lb arnaud-lb authored
View
10 lib/Twig/ExpressionParser.php
@@ -184,14 +184,10 @@ public function parseStringExpression()
}
}
- $expr = null;
+ $expr = array_shift($nodes);
- foreach(array_reverse($nodes) as $node) {
- if (null === $expr) {
- $expr = $node;
- } else {
- $expr = new Twig_Node_Expression_Binary_Concat($node, $expr, $node->getLine());
- }
+ foreach($nodes as $node) {
+ $expr = new Twig_Node_Expression_Binary_Concat($expr, $node, $node->getLine());
}
return $expr;
View
15 test/Twig/Tests/ExpressionParserTest.php
@@ -149,31 +149,32 @@ public function getTestsForString()
),
array(
'{{ "foo #{bar} baz" }}', new Twig_Node_Expression_Binary_Concat(
- new Twig_Node_Expression_Constant('foo ', 1),
new Twig_Node_Expression_Binary_Concat(
+ new Twig_Node_Expression_Constant('foo ', 1),
new Twig_Node_Expression_Name('bar', 1),
- new Twig_Node_Expression_Constant(' baz', 1),
1
),
+ new Twig_Node_Expression_Constant(' baz', 1),
1
- ),
+ )
),
+
array(
'{{ "foo #{"foo #{bar} baz"} baz" }}', new Twig_Node_Expression_Binary_Concat(
- new Twig_Node_Expression_Constant('foo ', 1),
new Twig_Node_Expression_Binary_Concat(
+ new Twig_Node_Expression_Constant('foo ', 1),
new Twig_Node_Expression_Binary_Concat(
- new Twig_Node_Expression_Constant('foo ', 1),
new Twig_Node_Expression_Binary_Concat(
+ new Twig_Node_Expression_Constant('foo ', 1),
new Twig_Node_Expression_Name('bar', 1),
- new Twig_Node_Expression_Constant(' baz', 1),
1
),
+ new Twig_Node_Expression_Constant(' baz', 1),
1
),
- new Twig_Node_Expression_Constant(' baz', 1),
1
),
+ new Twig_Node_Expression_Constant(' baz', 1),
1
),
),
Please sign in to comment.
Something went wrong with that request. Please try again.