abstract class AbstractOptimizer

Properties

protected int $cnt
protected int $i
protected bool $changed
protected array $tokens

Methods

string
optimize(string $php)

Optimize the control structures of a script

void
optimizeTokens()

Optimize the stored tokens

void
reset(string $php)

Reset the internal state of this optimizer

string
serialize()

Serialize the tokens back to source

void
skipToString(string $str)

Move the internal cursor until it reaches given string

void
skipWhitespace()

Skip all whitespace

void
unindentBlock(int $start, int $end)

Remove one tab of indentation off a range of PHP tokens

Details

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.

Parameters

string $php

Original code

Return Value

string

Optimized code

at line 63
abstract protected void optimizeTokens()

Optimize the stored tokens

Return Value

void

at line 71
protected void reset(string $php)

Reset the internal state of this optimizer

Parameters

string $php

PHP source

Return Value

void

at line 84
protected string serialize()

Serialize the tokens back to source

Return Value

string

at line 104
protected void skipToString(string $str)

Move the internal cursor until it reaches given string

Parameters

string $str

String to reach

Return Value

void

at line 114
protected void skipWhitespace()

Skip all whitespace

Return Value

void

at line 126
protected void unindentBlock(int $start, int $end)

Remove one tab of indentation off a range of PHP tokens

Parameters

int $start

Index of the first token to unindent

int $end

Index of the last token to unindent

Return Value

void