simplified code

This commit is contained in:
Fabien Potencier
2010-12-15 13:31:15 +01:00
parent a855b1898a
commit 45cfd21d4c
4 changed files with 4 additions and 28 deletions
+1 -8
View File
@@ -28,14 +28,7 @@ class Twig_Compiler implements Twig_CompilerInterface
*
* @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;
}
-3
View File
@@ -261,7 +261,6 @@ class Twig_Environment
public function setLexer(Twig_LexerInterface $lexer)
{
$this->lexer = $lexer;
$lexer->setEnvironment($this);
}
public function tokenize($source, $name = null)
@@ -281,7 +280,6 @@ class Twig_Environment
public function setParser(Twig_ParserInterface $parser)
{
$this->parser = $parser;
$parser->setEnvironment($this);
}
public function parse(Twig_TokenStream $tokens)
@@ -301,7 +299,6 @@ class Twig_Environment
public function setCompiler(Twig_CompilerInterface $compiler)
{
$this->compiler = $compiler;
$compiler->setEnvironment($this);
}
public function compile(Twig_NodeInterface $node)
+2 -9
View File
@@ -38,11 +38,9 @@ class Twig_Lexer implements Twig_LexerInterface
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('{#', '#}'),
@@ -91,11 +89,6 @@ class Twig_Lexer implements Twig_LexerInterface
return new Twig_TokenStream($tokens, $this->filename);
}
public function setEnvironment(Twig_Environment $env)
{
$this->env = $env;
}
/**
* Parses the next token and returns it.
*/
+1 -8
View File
@@ -21,14 +21,7 @@ class Twig_Parser implements Twig_ParserInterface
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;
}