class PhpWriter extends Object

PHP code generator helpers.

Methods

static 
using(MacroNode $node, Compiler $compiler = NULL)

No description

__construct(MacroTokens $tokens, $modifiers = NULL, Compiler $compiler = NULL)

No description

string
write($mask)

Expands %node.word, %node.array, %node.args, %escape(), %modify(), %var, %raw, %word in code.

string
formatModifiers($var)

Formats modifiers calling.

string
formatArgs(MacroTokens $tokens = NULL)

Formats macro arguments to PHP code. (It advances tokenizer to the end as a side effect.)

string
formatArray(MacroTokens $tokens = NULL)

Formats macro arguments to PHP array. (It advances tokenizer to the end as a side effect.)

string
formatWord($s)

Formats parameter to PHP string.

preprocess(MacroTokens $tokens = NULL)

Preprocessor for tokens. (It advances tokenizer to the end as a side effect.)

removeCommentsFilter(MacroTokens $tokens)

Removes PHP comments.

shortTernaryFilter(MacroTokens $tokens)

Simplified ternary expressions without third part.

shortArraysFilter(MacroTokens $tokens)

Simplified array syntax [...]

expandFilter(MacroTokens $tokens)

Pseudocast (expand).

quoteFilter(MacroTokens $tokens)

Quotes symbols to strings.

modifiersFilter(MacroTokens $tokens, $var)

Formats modifiers calling.

escapeFilter(MacroTokens $tokens)

Escapes expression in tokens.

Details

at line 28
static using(MacroNode $node, Compiler $compiler = NULL)

No description

Parameters

MacroNode $node
Compiler $compiler

at line 34
__construct(MacroTokens $tokens, $modifiers = NULL, Compiler $compiler = NULL)

No description

Parameters

MacroTokens $tokens
$modifiers
Compiler $compiler

at line 47
string write($mask)

Expands %node.word, %node.array, %node.args, %escape(), %modify(), %var, %raw, %word in code.

Parameters

$mask

Return Value

string

at line 106
string formatModifiers($var)

Formats modifiers calling.

Parameters

$var

Return Value

string

at line 120
string formatArgs(MacroTokens $tokens = NULL)

Formats macro arguments to PHP code. (It advances tokenizer to the end as a side effect.)

Parameters

MacroTokens $tokens

Return Value

string

at line 132
string formatArray(MacroTokens $tokens = NULL)

Formats macro arguments to PHP array. (It advances tokenizer to the end as a side effect.)

Parameters

MacroTokens $tokens

Return Value

string

at line 146
string formatWord($s)

Formats parameter to PHP string.

Parameters

$s

Return Value

string

at line 158
MacroTokens preprocess(MacroTokens $tokens = NULL)

Preprocessor for tokens. (It advances tokenizer to the end as a side effect.)

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 172
MacroTokens removeCommentsFilter(MacroTokens $tokens)

Removes PHP comments.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 188
MacroTokens shortTernaryFilter(MacroTokens $tokens)

Simplified ternary expressions without third part.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 217
MacroTokens shortArraysFilter(MacroTokens $tokens)

Simplified array syntax [...]

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 244
MacroTokens expandFilter(MacroTokens $tokens)

Pseudocast (expand).

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 271
MacroTokens quoteFilter(MacroTokens $tokens)

Quotes symbols to strings.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 293
MacroTokens modifiersFilter(MacroTokens $tokens, $var)

Formats modifiers calling.

Parameters

MacroTokens $tokens
$var

Return Value

MacroTokens

Exceptions

CompileException

at line 341
MacroTokens escapeFilter(MacroTokens $tokens)

Escapes expression in tokens.

Parameters

MacroTokens $tokens

Return Value

MacroTokens