Twig_NodeVisitor_Optimizer
extends OptimizerNodeVisitor
in package
Tries to optimize the AST.
Tags
Table of Contents
- OPTIMIZE_ALL = -1
- OPTIMIZE_FOR = 2
- OPTIMIZE_NONE = 0
- OPTIMIZE_RAW_FILTER = 4
- OPTIMIZE_VAR_ACCESS = 8
- $loops : mixed
- $loopsTargets : mixed
- $optimizers : mixed
- __construct() : mixed
- enterNode() : Node
- Called before child nodes are visited.
- getPriority() : mixed
- leaveNode() : Node|null
- Called after child nodes are visited.
- doEnterNode() : Node
- Called before child nodes are visited.
- doLeaveNode() : Node|null
- Called after child nodes are visited.
- addLoopToAll() : mixed
- addLoopToCurrent() : mixed
- enterOptimizeFor() : mixed
- Optimizes "for" tag by removing the "loop" variable creation whenever possible.
- leaveOptimizeFor() : mixed
- Optimizes "for" tag by removing the "loop" variable creation whenever possible.
- optimizePrintNode() : Node
- Optimizes print nodes.
- optimizeRawFilter() : Node
- Removes "raw" filters.
Constants
OPTIMIZE_ALL
public
mixed
OPTIMIZE_ALL
= -1
OPTIMIZE_FOR
public
mixed
OPTIMIZE_FOR
= 2
OPTIMIZE_NONE
public
mixed
OPTIMIZE_NONE
= 0
OPTIMIZE_RAW_FILTER
public
mixed
OPTIMIZE_RAW_FILTER
= 4
OPTIMIZE_VAR_ACCESS
public
mixed
OPTIMIZE_VAR_ACCESS
= 8
Properties
$loops
private
mixed
$loops
= []
$loopsTargets
private
mixed
$loopsTargets
= []
$optimizers
private
mixed
$optimizers
Methods
__construct()
public
__construct([int $optimizers = -1 ]) : mixed
Parameters
- $optimizers : int = -1
-
The optimizer mode
Return values
mixed —enterNode()
Called before child nodes are visited.
public
final enterNode(Node $node, Environment $env) : Node
Parameters
- $node : Node
- $env : Environment
Return values
Node —The modified node
getPriority()
public
getPriority() : mixed
Return values
mixed —leaveNode()
Called after child nodes are visited.
public
final leaveNode(Node $node, Environment $env) : Node|null
Parameters
- $node : Node
- $env : Environment
Return values
Node|null —The modified node or null if the node must be removed
doEnterNode()
Called before child nodes are visited.
protected
abstract doEnterNode(Node $node, Environment $env) : Node
Parameters
- $node : Node
- $env : Environment
Return values
Node —The modified node
doLeaveNode()
Called after child nodes are visited.
protected
abstract doLeaveNode(Node $node, Environment $env) : Node|null
Parameters
- $node : Node
- $env : Environment
Return values
Node|null —The modified node or null if the node must be removed
addLoopToAll()
private
addLoopToAll() : mixed
Return values
mixed —addLoopToCurrent()
private
addLoopToCurrent() : mixed
Return values
mixed —enterOptimizeFor()
Optimizes "for" tag by removing the "loop" variable creation whenever possible.
private
enterOptimizeFor(Node $node, Environment $env) : mixed
Parameters
- $node : Node
- $env : Environment
Return values
mixed —leaveOptimizeFor()
Optimizes "for" tag by removing the "loop" variable creation whenever possible.
private
leaveOptimizeFor(Node $node, Environment $env) : mixed
Parameters
- $node : Node
- $env : Environment
Return values
mixed —optimizePrintNode()
Optimizes print nodes.
private
optimizePrintNode(Node $node, Environment $env) : Node
It replaces:
- "echo $this->render(Parent)Block()" with "$this->display(Parent)Block()"
Parameters
- $node : Node
- $env : Environment
Return values
Node —optimizeRawFilter()
Removes "raw" filters.
private
optimizeRawFilter(Node $node, Environment $env) : Node
Parameters
- $node : Node
- $env : Environment