You are here

protected function Twig_NodeVisitor_Optimizer::optimizeVariables in Translation template extractor 7.3

Same name and namespace in other branches
  1. 6.3 vendor/Twig/NodeVisitor/Optimizer.php \Twig_NodeVisitor_Optimizer::optimizeVariables()
1 call to Twig_NodeVisitor_Optimizer::optimizeVariables()
Twig_NodeVisitor_Optimizer::doEnterNode in vendor/Twig/NodeVisitor/Optimizer.php
Called before child nodes are visited.

File

vendor/Twig/NodeVisitor/Optimizer.php, line 112

Class

Twig_NodeVisitor_Optimizer
Twig_NodeVisitor_Optimizer tries to optimizes the AST.

Code

protected function optimizeVariables(Twig_NodeInterface $node, Twig_Environment $env) {
  if ('Twig_Node_Expression_Name' === get_class($node) && $node
    ->isSimple()) {
    $this->prependedNodes[0][] = $node
      ->getAttribute('name');
    return new Twig_Node_Expression_TempName($node
      ->getAttribute('name'), $node
      ->getLine());
  }
  return $node;
}