@@ -45,7 +45,7 @@ class TwigFileExtractor implements FileVisitorInterface, \Twig_NodeVisitorInterf
45
45
private $ traverser ;
46
46
47
47
/**
48
- * @var array| \Twig_Node
48
+ * @var \Twig_Node[]
49
49
*/
50
50
private $ stack = array ();
51
51
@@ -110,13 +110,15 @@ public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
110
110
$ message ->addSource (new FileSource ((string ) $ this ->file , $ node ->getLine ()));
111
111
112
112
for ($ i =count ($ this ->stack )-2 ; $ i >=0 ; $ i -=1 ) {
113
- if (!$ this ->stack [$ i ] instanceof \Twig_Node_Expression_Filter) {
113
+ $ currentNode = $ this ->stack [$ i ];
114
+
115
+ if (!$ currentNode instanceof \Twig_Node_Expression_Filter) {
114
116
break ;
115
117
}
116
118
117
- $ name = $ this -> stack [ $ i ] ->getNode ('filter ' )->getAttribute ('value ' );
119
+ $ name = $ currentNode ->getNode ('filter ' )->getAttribute ('value ' );
118
120
if ('desc ' === $ name || 'meaning ' === $ name ) {
119
- $ arguments = $ this -> stack [ $ i ] ->getNode ('arguments ' );
121
+ $ arguments = $ currentNode ->getNode ('arguments ' );
120
122
if (!$ arguments ->hasNode (0 )) {
121
123
throw new RuntimeException (sprintf ('The "%s" filter requires exactly one argument, the description text. ' , $ name ));
122
124
}
@@ -208,6 +210,11 @@ public function visitPhpFile(\SplFileInfo $file, MessageCatalogue $catalogue, ar
208
210
{
209
211
}
210
212
213
+ /**
214
+ * Inject a Logger
215
+ *
216
+ * @param LoggerInterface $logger
217
+ */
211
218
public function setLogger (LoggerInterface $ logger )
212
219
{
213
220
$ this ->logger = $ logger ;
@@ -216,6 +223,7 @@ public function setLogger(LoggerInterface $logger)
216
223
/**
217
224
* @param \Twig_Node $node
218
225
* @return bool
226
+ * @throws RuntimeException
219
227
*/
220
228
private function checkNodeIsConstant (\Twig_Node $ node )
221
229
{
0 commit comments