tweaked some ::__toString() methods for Node classes
authorFabien Potencier <fabien.potencier@gmail.com>
Fri, 28 May 2010 06:44:36 +0000 (08:44 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Fri, 28 May 2010 11:39:44 +0000 (13:39 +0200)
lib/Twig/Node/Debug.php
lib/Twig/Node/Expression/Array.php
lib/Twig/Node/Expression/Constant.php
lib/Twig/Node/Expression/Name.php
lib/Twig/Node/Include.php
lib/Twig/Node/Text.php

index c22d1cc..074fd06 100644 (file)
@@ -11,6 +11,11 @@ class Twig_Node_Debug extends Twig_Node
         $this->expr = $expr;
     }
 
+    public function __toString()
+    {
+        return get_class($this).'('.$this->expr.')';
+    }
+
     public function compile($compiler)
     {
         $compiler->addDebugInfo($this);
index ba26b04..48586ea 100644 (file)
@@ -23,8 +23,8 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression implements Twig_No
     {
         $repr = array(get_class($this).'(');
         foreach ($this->elements as $name => $node) {
-            foreach (explode("\n", '  '.$name.' => '.$node) as $line) {
-                $repr[] = '    '.$line;
+            foreach (explode("\n", '\''.$name.'\' => '.$node) as $line) {
+                $repr[] = '  '.$line;
             }
         }
         $repr[] = ')';
index 533b218..c2a4d0c 100644 (file)
@@ -21,7 +21,7 @@ class Twig_Node_Expression_Constant extends Twig_Node_Expression
 
     public function __toString()
     {
-        return get_class($this).'('.$this->value.')';
+        return get_class($this).'(\''.$this->value.'\')';
     }
 
     public function compile($compiler)
index 46a1e6f..00a0160 100644 (file)
@@ -21,7 +21,7 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression
 
     public function __toString()
     {
-        return get_class($this).'('.$this->name.')';
+        return get_class($this).'(\''.$this->name.'\')';
     }
 
     public function compile($compiler)
index 542f476..4e613d2 100644 (file)
@@ -34,7 +34,7 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeListInterface
 
     public function __toString()
     {
-        return get_class($this).'('.$this->expr.')';
+        return get_class($this).'('.$this->expr.($this->sandboxed ? ', sandboxed' : '').($this->variables ? ', '.$this->variables : '').')';
     }
 
     public function getNodes()
index 8133bb9..7f55810 100644 (file)
@@ -29,7 +29,7 @@ class Twig_Node_Text extends Twig_Node
 
     public function __toString()
     {
-        return get_class($this).'('.$this->data.')';
+        return get_class($this).'(\''.str_replace("\n", '\n', $this->data).'\')';
     }
 
     public function compile($compiler)