MMOframework
Pourquoi l'IA Playground Bibliothèques Documentation Rechercher Agence
FR EN
Index

Printer

MMO\client\scs · 1 symbole · générée le 27 Oct 2026

class

Printer

Printer.php:27

Prints an ast (Parser) back as Simple CSS source.

class MMO\client\scs\Printer
Espace de noms
MMO\client\scs
This is the reverse of the parser, and the only part of the package that writes `.scs` rather than css. It exists because a stylesheet is sometimes *generated* from another one rather than compiled: the theme configurator ([`ThemeConfigurator`](https://mmoframework.fr/fr/documentation/mmo.client/php/ThemeConfigurator.md#themeconfigurator)) parses the token sources, replaces the values a user changed, and prints the whole thing back -- which is how a generated theme keeps the derivations of the file it came from (`bg: $palette.n50` stays an expression) instead of freezing every token into a literal. What it does *not* keep is comments: the lexer drops them, so a printed file is the code, not the source. ```php $ast = (new Parser(file_get_contents('tokens.scs'), 'tokens.scs'))->parse(); echo (new Printer())->print($ast); ```

Index

indent
atRule($node, $depth)
block($head, $body, $depth)
call($node)
condition($node, $depth)@if ... { } @else { }.
expression($node)
forPrelude($node)$i in 1..6 or $key:$value in $collection
map($node)
params($params, $always)
print($node)
statement($node, $depth)
statements($statements, $depth)
string($node)
terms($node)The terms of a value list, joined the way Evaluator::render reads them back.
theme($node, $depth)@theme [scope] { group { name: value; } } -- the dotted paths are folded back into the groups they were written as, in the order the file declared them.
useCall($node)
value($node)
__construct($indent)

Propriétés1

indent

protected string $indent
Type
string

Méthodes17

block($head, $body, $depth)

Printer.php:155
protected function block(string $head, array $body, int $depth): string
$headstringthe text before the brace
$bodyarray
$depthint
retournestring

condition($node, $depth)

Printer.php:133

@if ... { } @else { }.

protected function condition(MMO\client\scs\nodes\IfNode $node, int $depth): stringAn `@elseif` is parsed as an `@if` alone in the else branch of another one, and it is printed back that way -- `@else { @if ... }` rather than `@elseif ...`. The two are the same statement to the compiler, so a printed file behaves identically; it is simply one level deeper than the source was written.
$nodeIfNode
$depthint
retournestring

expression($node)

Printer.php:48
function expression(MMO\client\scs\nodes\Node $node): string
$nodeNodean expression node
retournestringthe expression as it would be written in a source
(new Printer())->expression($themeNode->entries['color.bg']); // '$palette.n50'

forPrelude($node)

Printer.php:160

$i in 1..6 or $key:$value in $collection

protected function forPrelude(MMO\client\scs\nodes\ForNode $node): string
$nodeForNode
retournestring

params($params, $always)

Printer.php:172
protected function params(array $params, bool $always = false): string
$paramsarray[['name' => string, 'default' => ?Node], ...]
$always = falsebooltrue to print () even with no parameter (an @fn is always a call)
retournestring

print($node)

Printer.php:37
function print( MMO\client\scs\nodes\StylesheetNode|MMO\client\scs\nodes\Node|array $node ): string
$nodeStylesheetNode | Node | arraywhat to print: a stylesheet, a statement list, or one statement
retournestringthe source, newline terminated when it is a statement

statement($node, $depth)

Printer.php:67
protected function statement(MMO\client\scs\nodes\Node $node, int $depth): string
$nodeNode
$depthint
retournestring

statements($statements, $depth)

Printer.php:61
protected function statements(array $statements, int $depth): string
$statementsarray
$depthint
retournestring

theme($node, $depth)

Printer.php:101

@theme [scope] { group { name: value; } } -- the dotted paths are folded back into the groups they were written as, in the order the file declared them.

protected function theme(MMO\client\scs\nodes\ThemeNode $node, int $depth): string
$nodeThemeNode
$depthint
retournestring

__construct($indent)

Printer.php:31
function __construct(string $indent = ' ')
$indent = ' 'stringone level of indentation