Browse code

deprecated Twig_Compiler::addIndentation()

Fabien Potencier authored on 24/10/2016 05:42:22
Showing 4 changed files
... ...
@@ -1,5 +1,6 @@
1 1
 * 1.27.0 (2016-XX-XX)
2 2
 
3
+ * deprecated Twig_Compiler::addIndentation()
3 4
  * fixed regression when registering two extensions having the same class name
4 5
  * deprecated Twig_LoaderInterface::getSource() (implement Twig_SourceContextLoaderInterface instead)
5 6
  * fixed the filesystem loader with relative paths
... ...
@@ -148,6 +148,9 @@ Compiler
148 148
 * As of Twig 1.26, the ``Twig_Compiler::getFilename()`` has been deprecated.
149 149
   You should not use it anyway as its values is not reliable.
150 150
 
151
+* As of Twig 1.27, the ``Twig_Compiler::addIndentation()`` has been deprecated.
152
+  Use ``Twig_Compiler::write('')`` instead.
153
+
151 154
 Loaders
152 155
 -------
153 156
 
... ...
@@ -97,7 +97,7 @@ class Twig_Compiler implements Twig_CompilerInterface
97 97
     public function subcompile(Twig_NodeInterface $node, $raw = true)
98 98
     {
99 99
         if (false === $raw) {
100
-            $this->addIndentation();
100
+            $this->source .= str_repeat(' ', $this->indentation * 4);
101 101
         }
102 102
 
103 103
         $node->compile($this);
... ...
@@ -128,8 +128,7 @@ class Twig_Compiler implements Twig_CompilerInterface
128 128
     {
129 129
         $strings = func_get_args();
130 130
         foreach ($strings as $string) {
131
-            $this->addIndentation();
132
-            $this->source .= $string;
131
+            $this->source .= str_repeat(' ', $this->indentation * 4).$string;
133 132
         }
134 133
 
135 134
         return $this;
... ...
@@ -139,9 +138,13 @@ class Twig_Compiler implements Twig_CompilerInterface
139 138
      * Appends an indentation to the current PHP code after compilation.
140 139
      *
141 140
      * @return Twig_Compiler The current compiler instance
141
+     *
142
+     * @deprecated since 1.27 (to be removed in 2.0).
142 143
      */
143 144
     public function addIndentation()
144 145
     {
146
+        @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use write(\'\') instead.', E_USER_DEPRECATED);
147
+
145 148
         $this->source .= str_repeat(' ', $this->indentation * 4);
146 149
 
147 150
         return $this;
... ...
@@ -70,7 +70,7 @@ class Twig_Node_Macro extends Twig_Node
70 70
 
71 71
         foreach ($this->getNode('arguments') as $name => $default) {
72 72
             $compiler
73
-                ->addIndentation()
73
+                ->write('')
74 74
                 ->string($name)
75 75
                 ->raw(' => $__'.$name.'__')
76 76
                 ->raw(",\n")
... ...
@@ -78,7 +78,7 @@ class Twig_Node_Macro extends Twig_Node
78 78
         }
79 79
 
80 80
         $compiler
81
-            ->addIndentation()
81
+            ->write('')
82 82
             ->string(self::VARARGS_NAME)
83 83
             ->raw(' => ')
84 84
         ;