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 26
static using(MacroNode $node, Compiler $compiler = NULL)

No description

Parameters

MacroNode $node
Compiler $compiler

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

No description

Parameters

MacroTokens $tokens
$modifiers
Compiler $compiler

at line 45
string write($mask)

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

Parameters

$mask

Return Value

string

at line 104
string formatModifiers($var)

Formats modifiers calling.

Parameters

$var

Return Value

string

at line 118
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 130
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 144
string formatWord($s)

Formats parameter to PHP string.

Parameters

$s

Return Value

string

at line 156
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 170
MacroTokens removeCommentsFilter(MacroTokens $tokens)

Removes PHP comments.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 186
MacroTokens shortTernaryFilter(MacroTokens $tokens)

Simplified ternary expressions without third part.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 215
MacroTokens shortArraysFilter(MacroTokens $tokens)

Simplified array syntax [...]

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 242
MacroTokens expandFilter(MacroTokens $tokens)

Pseudocast (expand).

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 269
MacroTokens quoteFilter(MacroTokens $tokens)

Quotes symbols to strings.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

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

Formats modifiers calling.

Parameters

MacroTokens $tokens
$var

Return Value

MacroTokens

Exceptions

CompileException

at line 339
MacroTokens escapeFilter(MacroTokens $tokens)

Escapes expression in tokens.

Parameters

MacroTokens $tokens

Return Value

MacroTokens