@@ -75,8 +75,10 @@ public function doEnterNode(Node $node, Environment $env)
75
75
}
76
76
77
77
$ wrappingNode = $ node ->getNode ('node ' );
78
- $ testNode = clone $ wrappingNode ;
79
- $ defaultNode = $ node ->getNode ('arguments ' )->getNode (0 );
78
+
79
+ $ testNode = clone $ wrappingNode ;
80
+ $ arguments = iterator_to_array ($ node ->getNode ('arguments ' ));
81
+ $ defaultNode = $ arguments [0 ];
80
82
81
83
// if the |transchoice filter is used, delegate the call to the TranslationExtension
82
84
// so that we can catch a possible exception when the default translation has not yet
@@ -95,22 +97,23 @@ public function doEnterNode(Node $node, Environment $env)
95
97
return $ node ;
96
98
}
97
99
100
+ $ wrappingNodeArguments = iterator_to_array ($ wrappingNode ->getNode ('arguments ' ));
101
+
98
102
// if the |trans filter has replacements parameters
99
103
// (e.g. |trans({'%foo%': 'bar'}))
100
- if ($ wrappingNode -> getNode ( ' arguments ' )-> hasNode ( 0 )) {
104
+ if (isset ( $ wrappingNodeArguments [ 0 ] )) {
101
105
$ lineno = $ wrappingNode ->getTemplateLine ();
102
106
103
107
// remove the replacements from the test node
104
- $ testNode ->setNode ('arguments ' , clone $ testNode ->getNode ('arguments ' ));
105
- $ testNode ->getNode ('arguments ' )->setNode (0 , new ArrayExpression (array (), $ lineno ));
108
+ $ testNodeArguments = iterator_to_array ($ testNode ->getNode ('arguments ' ));
109
+ $ testNodeArguments [0 ] = new ArrayExpression ([], $ lineno );
110
+ $ testNode ->setNode ('arguments ' , new Node ($ testNodeArguments ));
106
111
107
112
// wrap the default node in a |replace filter
108
113
$ defaultNode = new FilterExpression (
109
- clone $ node -> getNode ( ' arguments ' )-> getNode ( 0 ) ,
114
+ $ arguments[ 0 ] ,
110
115
new ConstantExpression ('replace ' , $ lineno ),
111
- new Node (array (
112
- clone $ wrappingNode ->getNode ('arguments ' )->getNode (0 )
113
- )),
116
+ new Node ([$ wrappingNodeArguments [0 ]]),
114
117
$ lineno
115
118
);
116
119
}
0 commit comments