*
* @param Twig_Environment $env The twig environment instance
*/
- public function __construct(Twig_Environment $env = null)
- {
- if (null !== $env) {
- $this->setEnvironment($env);
- }
- }
-
- public function setEnvironment(Twig_Environment $env)
+ public function __construct(Twig_Environment $env)
{
$this->env = $env;
}
public function setLexer(Twig_LexerInterface $lexer)
{
$this->lexer = $lexer;
- $lexer->setEnvironment($this);
}
public function tokenize($source, $name = null)
public function setParser(Twig_ParserInterface $parser)
{
$this->parser = $parser;
- $parser->setEnvironment($this);
}
public function parse(Twig_TokenStream $tokens)
public function setCompiler(Twig_CompilerInterface $compiler)
{
$this->compiler = $compiler;
- $compiler->setEnvironment($this);
}
public function compile(Twig_NodeInterface $node)
const REGEX_STRING = '/(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')/Asm';
const REGEX_PUNCTUATION = '/[\[\](){}?:.,|]/A';
- public function __construct(Twig_Environment $env = null, array $options = array())
+ public function __construct(Twig_Environment $env, array $options = array())
{
- if (null !== $env) {
- $this->setEnvironment($env);
- }
+ $this->env = $env;
$this->options = array_merge(array(
'tag_comment' => array('{#', '#}'),
return new Twig_TokenStream($tokens, $this->filename);
}
- public function setEnvironment(Twig_Environment $env)
- {
- $this->env = $env;
- }
-
/**
* Parses the next token and returns it.
*/
protected $macros;
protected $env;
- public function __construct(Twig_Environment $env = null)
- {
- if (null !== $env) {
- $this->setEnvironment($env);
- }
- }
-
- public function setEnvironment(Twig_Environment $env)
+ public function __construct(Twig_Environment $env)
{
$this->env = $env;
}