mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
simplified code
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user