From: Fabien Potencier Date: Fri, 28 May 2010 06:44:36 +0000 (+0200) Subject: tweaked some ::__toString() methods for Node classes X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=78e5c04490321f5b3a3a3e7ba6683d184f850b1e;p=konrad%2Ftwig.git tweaked some ::__toString() methods for Node classes --- diff --git a/lib/Twig/Node/Debug.php b/lib/Twig/Node/Debug.php index c22d1cc..074fd06 100644 --- a/lib/Twig/Node/Debug.php +++ b/lib/Twig/Node/Debug.php @@ -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); diff --git a/lib/Twig/Node/Expression/Array.php b/lib/Twig/Node/Expression/Array.php index ba26b04..48586ea 100644 --- a/lib/Twig/Node/Expression/Array.php +++ b/lib/Twig/Node/Expression/Array.php @@ -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[] = ')'; diff --git a/lib/Twig/Node/Expression/Constant.php b/lib/Twig/Node/Expression/Constant.php index 533b218..c2a4d0c 100644 --- a/lib/Twig/Node/Expression/Constant.php +++ b/lib/Twig/Node/Expression/Constant.php @@ -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) diff --git a/lib/Twig/Node/Expression/Name.php b/lib/Twig/Node/Expression/Name.php index 46a1e6f..00a0160 100644 --- a/lib/Twig/Node/Expression/Name.php +++ b/lib/Twig/Node/Expression/Name.php @@ -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) diff --git a/lib/Twig/Node/Include.php b/lib/Twig/Node/Include.php index 542f476..4e613d2 100644 --- a/lib/Twig/Node/Include.php +++ b/lib/Twig/Node/Include.php @@ -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() diff --git a/lib/Twig/Node/Text.php b/lib/Twig/Node/Text.php index 8133bb9..7f55810 100644 --- a/lib/Twig/Node/Text.php +++ b/lib/Twig/Node/Text.php @@ -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)