deprecated Twig_Compiler::addIndentation()

This commit is contained in:
Fabien Potencier
2016-10-23 22:42:22 -07:00
parent 7e5c06a3be
commit bc499a47e1
4 changed files with 12 additions and 5 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.27.0 (2016-XX-XX) * 1.27.0 (2016-XX-XX)
* deprecated Twig_Compiler::addIndentation()
* fixed regression when registering two extensions having the same class name * fixed regression when registering two extensions having the same class name
* deprecated Twig_LoaderInterface::getSource() (implement Twig_SourceContextLoaderInterface instead) * deprecated Twig_LoaderInterface::getSource() (implement Twig_SourceContextLoaderInterface instead)
* fixed the filesystem loader with relative paths * fixed the filesystem loader with relative paths
+3
View File
@@ -148,6 +148,9 @@ Compiler
* As of Twig 1.26, the ``Twig_Compiler::getFilename()`` has been deprecated. * As of Twig 1.26, the ``Twig_Compiler::getFilename()`` has been deprecated.
You should not use it anyway as its values is not reliable. You should not use it anyway as its values is not reliable.
* As of Twig 1.27, the ``Twig_Compiler::addIndentation()`` has been deprecated.
Use ``Twig_Compiler::write('')`` instead.
Loaders Loaders
------- -------
+6 -3
View File
@@ -97,7 +97,7 @@ class Twig_Compiler implements Twig_CompilerInterface
public function subcompile(Twig_NodeInterface $node, $raw = true) public function subcompile(Twig_NodeInterface $node, $raw = true)
{ {
if (false === $raw) { if (false === $raw) {
$this->addIndentation(); $this->source .= str_repeat(' ', $this->indentation * 4);
} }
$node->compile($this); $node->compile($this);
@@ -128,8 +128,7 @@ class Twig_Compiler implements Twig_CompilerInterface
{ {
$strings = func_get_args(); $strings = func_get_args();
foreach ($strings as $string) { foreach ($strings as $string) {
$this->addIndentation(); $this->source .= str_repeat(' ', $this->indentation * 4).$string;
$this->source .= $string;
} }
return $this; return $this;
@@ -139,9 +138,13 @@ class Twig_Compiler implements Twig_CompilerInterface
* Appends an indentation to the current PHP code after compilation. * Appends an indentation to the current PHP code after compilation.
* *
* @return Twig_Compiler The current compiler instance * @return Twig_Compiler The current compiler instance
*
* @deprecated since 1.27 (to be removed in 2.0).
*/ */
public function addIndentation() public function addIndentation()
{ {
@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use write(\'\') instead.', E_USER_DEPRECATED);
$this->source .= str_repeat(' ', $this->indentation * 4); $this->source .= str_repeat(' ', $this->indentation * 4);
return $this; return $this;
+2 -2
View File
@@ -70,7 +70,7 @@ class Twig_Node_Macro extends Twig_Node
foreach ($this->getNode('arguments') as $name => $default) { foreach ($this->getNode('arguments') as $name => $default) {
$compiler $compiler
->addIndentation() ->write('')
->string($name) ->string($name)
->raw(' => $__'.$name.'__') ->raw(' => $__'.$name.'__')
->raw(",\n") ->raw(",\n")
@@ -78,7 +78,7 @@ class Twig_Node_Macro extends Twig_Node
} }
$compiler $compiler
->addIndentation() ->write('')
->string(self::VARARGS_NAME) ->string(self::VARARGS_NAME)
->raw(' => ') ->raw(' => ')
; ;