ControlStructuresOptimizer
class ControlStructuresOptimizer extends AbstractOptimizer
Optimize the control structures of a script
Removes brackets in control structures wherever possible. Prevents the generation of EXT_STMT opcodes where they're not strictly required.
Properties
protected int | $cnt | from AbstractOptimizer | |
protected int | $i | from AbstractOptimizer | |
protected bool | $changed | from AbstractOptimizer | |
protected array | $tokens | from AbstractOptimizer | |
protected int | $braces | ||
protected array | $context |
Methods
Optimize control structures in stored tokens
Reset the internal state of this optimizer
Move the internal cursor until it reaches given string
Remove one tab of indentation off a range of PHP tokens
Test whether current block ends with an if or elseif control structure
Test whether the token at current index is a control structure
Test whether current block is followed by an elseif/else structure
Test whether braces must be preserved in current context
Process the control structure starting at current index
Process the block ending at current index
Remove the braces surrounding current context
Skip the condition of a control structure
Details
in
AbstractOptimizer at line 41
string
optimize(string $php)
Optimize the control structures of a script
Removes brackets in control structures wherever possible. Prevents the generation of EXT_STMT opcodes where they're not strictly required.
at line 94
protected void
optimizeTokens()
Optimize control structures in stored tokens
at line 269
protected void
reset(string $php)
Reset the internal state of this optimizer
in
AbstractOptimizer at line 84
protected string
serialize()
Serialize the tokens back to source
in
AbstractOptimizer at line 104
protected void
skipToString(string $str)
Move the internal cursor until it reaches given string
in
AbstractOptimizer at line 114
protected void
skipWhitespace()
Skip all whitespace
in
AbstractOptimizer at line 126
protected void
unindentBlock(int $start, int $end)
Remove one tab of indentation off a range of PHP tokens
at line 33
protected bool
blockEndsWithIf()
Test whether current block ends with an if or elseif control structure
at line 43
protected bool
isControlStructure()
Test whether the token at current index is a control structure
at line 57
protected bool
isFollowedByElse()
Test whether current block is followed by an elseif/else structure
at line 81
protected bool
mustPreserveBraces()
Test whether braces must be preserved in current context
at line 127
protected void
processControlStructure()
Process the control structure starting at current index
at line 191
protected void
processEndOfBlock()
Process the block ending at current index
at line 209
protected void
removeBracesInCurrentContext()
Remove the braces surrounding current context
at line 289
protected void
skipCondition()
Skip the condition of a control structure