PhpWriter
class PhpWriter
PHP code generator helpers.
Methods
Expands %node.word, %node.array, %node.args, %escape(), %modify(), %var, %raw, %word in code.
Formats modifiers calling.
Formats macro arguments to PHP code. (It advances tokenizer to the end as a side effect.)
Formats macro arguments to PHP array. (It advances tokenizer to the end as a side effect.)
Formats parameter to PHP string.
Preprocessor for tokens. (It advances tokenizer to the end as a side effect.)
Formats modifiers calling.
Details
at line 42
__construct(MacroTokens $tokens, string $modifiers = null, array $context = null)
No description
at line 53
string
write(string $mask, ...$args)
Expands %node.word, %node.array, %node.args, %escape(), %modify(), %var, %raw, %word in code.
at line 117
string
formatModifiers(string $var, bool $isContent = false)
Formats modifiers calling.
at line 130
string
formatArgs(MacroTokens $tokens = null)
Formats macro arguments to PHP code. (It advances tokenizer to the end as a side effect.)
at line 141
string
formatArray(MacroTokens $tokens = null)
Formats macro arguments to PHP array. (It advances tokenizer to the end as a side effect.)
at line 153
string
formatWord(string $s)
Formats parameter to PHP string.
at line 164
MacroTokens
preprocess(MacroTokens $tokens = null)
Preprocessor for tokens. (It advances tokenizer to the end as a side effect.)
at line 179
void
validateTokens(MacroTokens $tokens)
No description
at line 216
MacroTokens
removeCommentsPass(MacroTokens $tokens)
Removes PHP comments.
at line 231
MacroTokens
replaceFunctionsPass(MacroTokens $tokens)
Replace global functions with custom ones.
at line 257
MacroTokens
shortTernaryPass(MacroTokens $tokens)
Simplified ternary expressions without third part.
at line 297
MacroTokens
optionalChainingPass(MacroTokens $tokens)
Optional Chaining $var?->prop?->elem[1]?->call()?->item
at line 371
MacroTokens
expandCastPass(MacroTokens $tokens)
Pseudocast (expand).
at line 399
MacroTokens
quotingPass(MacroTokens $tokens)
Quotes symbols to strings.
at line 419
MacroTokens
inOperatorPass(MacroTokens $tokens)
Syntax $entry in [item1, item2].
at line 454
MacroTokens
inlineModifierPass(MacroTokens $tokens)
Process inline filters ($var|filter)
at line 517
MacroTokens
modifierPass(MacroTokens $tokens, string|array $var, bool $isContent = false)
Formats modifiers calling.
at line 572
MacroTokens
escapePass(MacroTokens $tokens)
Escapes expression in tokens.
Traits
Better OOP experience.