protected function Twig_NodeVisitor_Optimizer::doEnterNode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php \Twig_NodeVisitor_Optimizer::doEnterNode()
Called before child nodes are visited.
Parameters
Twig_Node $node The node to visit:
Twig_Environment $env The Twig environment instance:
Return value
Twig_Node The modified node
Overrides Twig_BaseNodeVisitor::doEnterNode
File
- vendor/
twig/ twig/ lib/ Twig/ NodeVisitor/ Optimizer.php, line 53
Class
- Twig_NodeVisitor_Optimizer
- Twig_NodeVisitor_Optimizer tries to optimizes the AST.
Code
protected function doEnterNode(Twig_Node $node, Twig_Environment $env) {
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
$this
->enterOptimizeFor($node, $env);
}
if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env
->isStrictVariables() && !$env
->hasExtension('sandbox')) {
if ($this->inABody) {
if (!$node instanceof Twig_Node_Expression) {
if (get_class($node) !== 'Twig_Node') {
array_unshift($this->prependedNodes, array());
}
}
else {
$node = $this
->optimizeVariables($node, $env);
}
}
elseif ($node instanceof Twig_Node_Body) {
$this->inABody = true;
}
}
return $node;
}