diff --git a/src/Visitor/Php/Symfony/ContainerAwareTransChoice.php b/src/Visitor/Php/Symfony/ContainerAwareTransChoice.php index 31940c7..704b450 100644 --- a/src/Visitor/Php/Symfony/ContainerAwareTransChoice.php +++ b/src/Visitor/Php/Symfony/ContainerAwareTransChoice.php @@ -42,9 +42,12 @@ public function enterNode(Node $node): ?Node } $name = (string) $node->name; - //If $this->get('translator')->trans('foobar') + //If $this->get('translator')->transChoice('foobar') if ('transChoice' === $name) { $label = $this->getStringArgument($node, 0); + if (null === $label) { + return null; + } $domain = $this->getStringArgument($node, 3); $this->addLocation($label, $node->getAttribute('startLine'), $node, ['domain' => $domain]); diff --git a/tests/Resources/Php/Symfony/ContainerAwareTransChoice.php b/tests/Resources/Php/Symfony/ContainerAwareTransChoice.php index 72683c8..799d87e 100644 --- a/tests/Resources/Php/Symfony/ContainerAwareTransChoice.php +++ b/tests/Resources/Php/Symfony/ContainerAwareTransChoice.php @@ -13,4 +13,10 @@ public function newAction() return array(); } + + public function transWithVariable() + { + $var = 'toto'; + $translated = $this->get('translator')->transChoice($var); + } }