Skip to content

Commit 9710dec

Browse files
author
Benoît Burnichon
committed
PHPCS of TwigFileExtractor
1 parent 2a21e7a commit 9710dec

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Diff for: Translation/Extractor/File/TwigFileExtractor.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class TwigFileExtractor implements FileVisitorInterface, \Twig_NodeVisitorInterf
4545
private $traverser;
4646

4747
/**
48-
* @var array|\Twig_Node
48+
* @var \Twig_Node[]
4949
*/
5050
private $stack = array();
5151

@@ -110,13 +110,15 @@ public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
110110
$message->addSource(new FileSource((string) $this->file, $node->getLine()));
111111

112112
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) {
114116
break;
115117
}
116118

117-
$name = $this->stack[$i]->getNode('filter')->getAttribute('value');
119+
$name = $currentNode->getNode('filter')->getAttribute('value');
118120
if ('desc' === $name || 'meaning' === $name) {
119-
$arguments = $this->stack[$i]->getNode('arguments');
121+
$arguments = $currentNode->getNode('arguments');
120122
if (!$arguments->hasNode(0)) {
121123
throw new RuntimeException(sprintf('The "%s" filter requires exactly one argument, the description text.', $name));
122124
}
@@ -208,6 +210,11 @@ public function visitPhpFile(\SplFileInfo $file, MessageCatalogue $catalogue, ar
208210
{
209211
}
210212

213+
/**
214+
* Inject a Logger
215+
*
216+
* @param LoggerInterface $logger
217+
*/
211218
public function setLogger(LoggerInterface $logger)
212219
{
213220
$this->logger = $logger;
@@ -216,6 +223,7 @@ public function setLogger(LoggerInterface $logger)
216223
/**
217224
* @param \Twig_Node $node
218225
* @return bool
226+
* @throws RuntimeException
219227
*/
220228
private function checkNodeIsConstant(\Twig_Node $node)
221229
{

0 commit comments

Comments
 (0)