Compiler

Implements\Twig_CompilerInterface

Compiles a node to PHP code.

author

Fabien Potencier fabien@symfony.com

package

Default

Methods

__construct

__construct(\Twig\Environment $env)

Arguments

$env

\Twig\Environment

Adds debugging information.

addDebugInfo(\Twig_NodeInterface $node): $this

Arguments

Response

$this

Appends an indentation to the current PHP code after compilation.

addIndentation(): $this
deprecated

since 1.27 (to be removed in 2.0).

Response

$this

Compiles a node.

compile(\Twig_NodeInterface $node,integer $indentation): $this

Arguments

$indentation

integer

The current indentation

Response

$this

getDebugInfo

getDebugInfo()

Returns the environment instance related to this compiler.

getEnvironment(): \Twig\Environment

Response

\Twig\Environment

getFilename

getFilename()
deprecated

since 1.25 (to be removed in 2.0)

Gets the current PHP code after compilation.

getSource(): string

Response

string

The PHP code

getVarName

getVarName()

Indents the generated code.

indent(integer $step = 1): $this

Arguments

$step

integer

The number of indentation to add

Response

$this

Outdents the generated code.

outdent(integer $step = 1): $this
Throws
\LogicException

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

Arguments

$step

integer

The number of indentation to remove

Response

$this

Adds a raw string to the compiled code.

raw(string $string): $this

Arguments

$string

string

The string

Response

$this

Returns a PHP representation of a given value.

repr(mixed $value): $this

Arguments

$value

mixed

The value to convert

Response

$this

Adds a quoted string to the compiled code.

string(string $value): $this

Arguments

$value

string

The string

Response

$this

subcompile

subcompile(\Twig_NodeInterface $node, $raw = true)

Arguments

$raw

Writes a string to the compiled code by adding indentation.

write(): $this

Response

$this

Properties

lastLine

lastLine :

Type(s)

source

source :

Type(s)

indentation

indentation :

Type(s)

env

env :

Type(s)

debugInfo

debugInfo :

Type(s)

sourceOffset

sourceOffset :

Type(s)

sourceLine

sourceLine :

Type(s)

filename

filename :

Type(s)

varNameSalt

varNameSalt :

Type(s)