PhpWriter
class PhpWriter
PHP code generator helpers.
Methods
No description
Expands %node.word, %node.array, %node.args, %node.line, %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.)
Nullsafe operator $var?->prop?->elem[1]?->call()?->item Null-coalescing-safe operator $var??->prop??->elem[1]??->call()??->item
Details
at line 53
__construct(MacroTokens $tokens, string|null $modifiers = null, array|null $context = null)
No description
at line 65
string
write(string $mask, mixed ...$args)
Expands %node.word, %node.array, %node.args, %node.line, %escape(), %modify(), %var, %raw, %word in code.
at line 132
string
formatModifiers(string $var, bool $isContent = false)
Formats modifiers calling.
at line 148
string
formatArgs(MacroTokens|null $tokens = null)
Formats macro arguments to PHP code. (It advances tokenizer to the end as a side effect.)
at line 160
string
formatArray(MacroTokens|null $tokens = null)
Formats macro arguments to PHP array. (It advances tokenizer to the end as a side effect.)
at line 174
string
formatWord(string $s)
Formats parameter to PHP string.
at line 190
MacroTokens
preprocess(MacroTokens|null $tokens = null)
Preprocessor for tokens. (It advances tokenizer to the end as a side effect.)
at line 207
void
validateTokens(MacroTokens $tokens)
No description
at line 254
void
validateKeywords(MacroTokens $tokens)
No description
at line 285
MacroTokens
removeCommentsPass(MacroTokens $tokens)
Removes PHP comments.
at line 299
MacroTokens
replaceFunctionsPass(MacroTokens $tokens)
Replace global functions with custom ones.
at line 327
MacroTokens
shortTernaryPass(MacroTokens $tokens)
Simplified ternary expressions without third part.
at line 365
MacroTokens
optionalChainingPass(MacroTokens $tokens)
Nullsafe operator $var?->prop?->elem[1]?->call()?->item Null-coalescing-safe operator $var??->prop??->elem[1]??->call()??->item
at line 467
MacroTokens
expandCastPass(MacroTokens $tokens)
Pseudocast (expand).
at line 496
MacroTokens
quotingPass(MacroTokens $tokens)
Quotes symbols to strings.
at line 519
MacroTokens
namedArgumentsPass(MacroTokens $tokens)
Converts named arguments name: value to 'name' => value
at line 543
MacroTokens
modernArraySyntax(MacroTokens $tokens)
Converts [name: value] to ['name' => value]
at line 573
MacroTokens
inOperatorPass(MacroTokens $tokens)
Syntax $entry in [item1, item2].
at line 610
MacroTokens
sandboxPass(MacroTokens $tokens)
Applies sandbox policy.
at line 734
MacroTokens
inlineModifierPass(MacroTokens $tokens)
Process inline filters ($var|filter)
at line 803
MacroTokens
modifierPass(MacroTokens $tokens, $var, bool $isContent = false)
Formats modifiers calling.
at line 881
MacroTokens
escapePass(MacroTokens $tokens)
Escapes expression in tokens.
Traits
Better OOP experience.