You are here

protected function Twig_NodeVisitor_Optimizer::leaveOptimizeFor in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/NodeVisitor/Optimizer.php \Twig_NodeVisitor_Optimizer::leaveOptimizeFor()

Optimizes "for" tag by removing the "loop" variable creation whenever possible.

Parameters

Twig_NodeInterface $node A Node:

Twig_Environment $env The current Twig environment:

1 call to Twig_NodeVisitor_Optimizer::leaveOptimizeFor()
Twig_NodeVisitor_Optimizer::leaveNode in vendor/Twig/NodeVisitor/Optimizer.php
Called after child nodes are visited.

File

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

Class

Twig_NodeVisitor_Optimizer
Twig_NodeVisitor_Optimizer tries to optimizes the AST.

Code

protected function leaveOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env) {
  if ($node instanceof Twig_Node_For) {
    array_shift($this->loops);
    array_shift($this->loopsTargets);
    array_shift($this->loopsTargets);
  }
}