\Twig_Compiler

Compiles a node to PHP code.

Summary

Methods
Properties
Constants
__construct()
getEnvironment()
getSource()
compile()
subcompile()
raw()
write()
string()
repr()
addDebugInfo()
getDebugInfo()
indent()
outdent()
getVarName()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$lastLine
$source
$indentation
$env
$debugInfo
$sourceOffset
$sourceLine
$varNameSalt
N/A

Properties

$lastLine

$lastLine : 

Type

$source

$source : 

Type

$indentation

$indentation : 

Type

$env

$env : 

Type

$debugInfo

$debugInfo : 

Type

$sourceOffset

$sourceOffset : 

Type

$sourceLine

$sourceLine : 

Type

$varNameSalt

$varNameSalt : 

Type

Methods

__construct()

__construct(\Twig_Environment  $env) 

Parameters

\Twig_Environment $env

getEnvironment()

getEnvironment() : \Twig_Environment

Returns the environment instance related to this compiler.

Returns

\Twig_Environment

getSource()

getSource() : string

Gets the current PHP code after compilation.

Returns

string —

The PHP code

compile()

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

Compiles a node.

Parameters

\Twig_Node $node

The node to compile

integer $indentation

The current indentation

Returns

$this

subcompile()

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

Parameters

\Twig_Node $node
$raw

raw()

raw(string  $string) : $this

Adds a raw string to the compiled code.

Parameters

string $string

The string

Returns

$this

write()

write(  $strings) : $this

Writes a string to the compiled code by adding indentation.

Parameters

$strings

Returns

$this

string()

string(string  $value) : $this

Adds a quoted string to the compiled code.

Parameters

string $value

The string

Returns

$this

repr()

repr(mixed  $value) : $this

Returns a PHP representation of a given value.

Parameters

mixed $value

The value to convert

Returns

$this

addDebugInfo()

addDebugInfo(\Twig_Node  $node) : $this

Adds debugging information.

Parameters

\Twig_Node $node

Returns

$this

getDebugInfo()

getDebugInfo() 

indent()

indent(integer  $step = 1) : $this

Indents the generated code.

Parameters

integer $step

The number of indentation to add

Returns

$this

outdent()

outdent(integer  $step = 1) : $this

Outdents the generated code.

Parameters

integer $step

The number of indentation to remove

Throws

\LogicException

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

Returns

$this

getVarName()

getVarName()