for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the PHP Translation package.
*
* (c) PHP Translation team <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Translation\Extractor\Visitor\Php\Symfony;
use PhpParser\Node;
use PhpParser\NodeVisitor;
use Translation\Extractor\Visitor\Php\BasePHPVisitor;
/**
* @author Tobias Nyholm <[email protected]>
final class ContainerAwareTransChoice extends BasePHPVisitor implements NodeVisitor
{
* {@inheritdoc}
public function beforeTraverse(array $nodes): ?Node
return null;
}
public function enterNode(Node $node): ?Node
if (!$node instanceof Node\Expr\MethodCall) {
if (!\is_string($node->name) && !$node->name instanceof Node\Identifier) {
$name = (string) $node->name;
//If $this->get('translator')->transChoice('foobar')
if ('transChoice' === $name) {
$label = $this->getStringArgument($node, 0);
if (null === $label) {
$domain = $this->getStringArgument($node, 3);
$this->addLocation($label, $node->getAttribute('startLine'), $node, ['domain' => $domain]);
public function leaveNode(Node $node): ?Node
public function afterTraverse(array $nodes): ?Node