Documentation

Compiler
in package

Compiles a node to PHP code.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

$debugInfo  : mixed
$env  : mixed
$indentation  : mixed
$lastLine  : mixed
$source  : mixed
$sourceLine  : mixed
$sourceOffset  : mixed
$varNameSalt  : mixed
__construct()  : mixed
addDebugInfo()  : $this
Adds debugging information.
compile()  : $this
Compiles a node.
getDebugInfo()  : mixed
getEnvironment()  : Environment
Returns the environment instance related to this compiler.
getSource()  : string
Gets the current PHP code after compilation.
getVarName()  : mixed
indent()  : $this
Indents the generated code.
outdent()  : $this
Outdents the generated code.
raw()  : $this
Adds a raw string to the compiled code.
repr()  : $this
Returns a PHP representation of a given value.
string()  : $this
Adds a quoted string to the compiled code.
subcompile()  : mixed
write()  : $this
Writes a string to the compiled code by adding indentation.

Properties

$debugInfo

private mixed $debugInfo = []

$sourceOffset

private mixed $sourceOffset

$varNameSalt

private mixed $varNameSalt = 0

Methods

addDebugInfo()

Adds debugging information.

public addDebugInfo(Node $node) : $this
Parameters
$node : Node
Return values
$this

compile()

Compiles a node.

public compile(Node $node, int $indentation) : $this
Parameters
$node : Node
$indentation : int

The current indentation

Return values
$this

getDebugInfo()

public getDebugInfo() : mixed
Return values
mixed

getSource()

Gets the current PHP code after compilation.

public getSource() : string
Return values
string

The PHP code

getVarName()

public getVarName() : mixed
Return values
mixed

indent()

Indents the generated code.

public indent([int $step = 1 ]) : $this
Parameters
$step : int = 1

The number of indentation to add

Return values
$this

outdent()

Outdents the generated code.

public outdent([int $step = 1 ]) : $this
Parameters
$step : int = 1

The number of indentation to remove

Tags
throws
LogicException

When trying to outdent too much so the indentation would become negative

Return values
$this

raw()

Adds a raw string to the compiled code.

public raw(string $string) : $this
Parameters
$string : string

The string

Return values
$this

repr()

Returns a PHP representation of a given value.

public repr(mixed $value) : $this
Parameters
$value : mixed

The value to convert

Return values
$this

string()

Adds a quoted string to the compiled code.

public string(string $value) : $this
Parameters
$value : string

The string

Return values
$this

subcompile()

public subcompile(Node $node[, mixed $raw = true ]) : mixed
Parameters
$node : Node
$raw : mixed = true
Return values
mixed

write()

Writes a string to the compiled code by adding indentation.

public write(mixed ...$strings) : $this
Parameters
$strings : mixed
Return values
$this

Search results