class PhpWriter

PHP code generator helpers.

Methods

static 
using(MacroNode $node)

No description

__construct(MacroTokens $tokens, $modifiers = null, array $context = null)

No description

string
write($mask)

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

string
formatModifiers($var, $isContent = false)

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.)

void
validateTokens(MacroTokens $tokens)

No description

removeCommentsPass(MacroTokens $tokens)

Removes PHP comments.

shortTernaryPass(MacroTokens $tokens)

Simplified ternary expressions without third part.

expandCastPass(MacroTokens $tokens)

Pseudocast (expand).

quotingPass(MacroTokens $tokens)

Quotes symbols to strings.

inOperatorPass(MacroTokens $tokens)

Syntax $entry in [item1, item2].

inlineModifierPass(MacroTokens $tokens)

Process inline filters ($var|filter)

modifierPass(MacroTokens $tokens, $var, $isContent = false)

Formats modifiers calling.

escapePass(MacroTokens $tokens)

Escapes expression in tokens.

Details

at line 28
static using(MacroNode $node)

No description

Parameters

MacroNode $node

at line 36
__construct(MacroTokens $tokens, $modifiers = null, array $context = null)

No description

Parameters

MacroTokens $tokens
$modifiers
array $context

at line 49
string write($mask)

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

Parameters

$mask

Return Value

string

at line 107
string formatModifiers($var, $isContent = false)

Formats modifiers calling.

Parameters

$var
$isContent

Return Value

string

at line 121
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 133
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 147
string formatWord($s)

Formats parameter to PHP string.

Parameters

$s

Return Value

string

at line 159
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 175
void validateTokens(MacroTokens $tokens)

No description

Parameters

MacroTokens $tokens

Return Value

void

Exceptions

CompileException

at line 220
MacroTokens removeCommentsPass(MacroTokens $tokens)

Removes PHP comments.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 236
MacroTokens shortTernaryPass(MacroTokens $tokens)

Simplified ternary expressions without third part.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 265
MacroTokens expandCastPass(MacroTokens $tokens)

Pseudocast (expand).

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 294
MacroTokens quotingPass(MacroTokens $tokens)

Quotes symbols to strings.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 314
MacroTokens inOperatorPass(MacroTokens $tokens)

Syntax $entry in [item1, item2].

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 350
MacroTokens inlineModifierPass(MacroTokens $tokens)

Process inline filters ($var|filter)

Parameters

MacroTokens $tokens

Return Value

MacroTokens

at line 415
MacroTokens modifierPass(MacroTokens $tokens, $var, $isContent = false)

Formats modifiers calling.

Parameters

MacroTokens $tokens
$var
$isContent

Return Value

MacroTokens

Exceptions

CompileException

at line 472
MacroTokens escapePass(MacroTokens $tokens)

Escapes expression in tokens.

Parameters

MacroTokens $tokens

Return Value

MacroTokens

Traits

Better OOP experience.