deprecated some more methods on Twig_Environment

This commit is contained in:
Fabien Potencier
2016-09-18 18:36:04 -07:00
parent c418d07c64
commit e548cbe3a4
2 changed files with 29 additions and 5 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
* 1.24.3 (2016-XX-XX) * 1.25.0 (2016-XX-XX)
* n/a * deprecated Twig_Environment::getLexer(), Twig_Environment::getParser(), Twig_Environment::getCompiler()
* 1.24.2 (2016-09-01) * 1.24.2 (2016-09-01)
+27 -3
View File
@@ -546,9 +546,13 @@ class Twig_Environment
* Gets the Lexer instance. * Gets the Lexer instance.
* *
* @return Twig_LexerInterface A Twig_LexerInterface instance * @return Twig_LexerInterface A Twig_LexerInterface instance
*
* @deprecated since 1.25 (to be removed in 2.0)
*/ */
public function getLexer() public function getLexer()
{ {
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
if (null === $this->lexer) { if (null === $this->lexer) {
$this->lexer = new Twig_Lexer($this); $this->lexer = new Twig_Lexer($this);
} }
@@ -578,16 +582,24 @@ class Twig_Environment
*/ */
public function tokenize($source, $name = null) public function tokenize($source, $name = null)
{ {
return $this->getLexer()->tokenize($source, $name); if (null === $this->lexer) {
$this->lexer = new Twig_Lexer($this);
}
return $this->lexer->tokenize($source, $name);
} }
/** /**
* Gets the Parser instance. * Gets the Parser instance.
* *
* @return Twig_ParserInterface A Twig_ParserInterface instance * @return Twig_ParserInterface A Twig_ParserInterface instance
*
* @deprecated since 1.25 (to be removed in 2.0)
*/ */
public function getParser() public function getParser()
{ {
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
if (null === $this->parser) { if (null === $this->parser) {
$this->parser = new Twig_Parser($this); $this->parser = new Twig_Parser($this);
} }
@@ -616,16 +628,24 @@ class Twig_Environment
*/ */
public function parse(Twig_TokenStream $stream) public function parse(Twig_TokenStream $stream)
{ {
return $this->getParser()->parse($stream); if (null === $this->parser) {
$this->parser = new Twig_Parser($this);
}
return $this->parser->parse($stream);
} }
/** /**
* Gets the Compiler instance. * Gets the Compiler instance.
* *
* @return Twig_CompilerInterface A Twig_CompilerInterface instance * @return Twig_CompilerInterface A Twig_CompilerInterface instance
*
* @deprecated since 1.25 (to be removed in 2.0)
*/ */
public function getCompiler() public function getCompiler()
{ {
@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
if (null === $this->compiler) { if (null === $this->compiler) {
$this->compiler = new Twig_Compiler($this); $this->compiler = new Twig_Compiler($this);
} }
@@ -652,7 +672,11 @@ class Twig_Environment
*/ */
public function compile(Twig_NodeInterface $node) public function compile(Twig_NodeInterface $node)
{ {
return $this->getCompiler()->compile($node)->getSource(); if (null === $this->compiler) {
$this->compiler = new Twig_Compiler($this);
}
return $this->compiler->compile($node)->getSource();
} }
/** /**