public function Twig_Node::__toString in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/twig/twig/lib/Twig/Node.php \Twig_Node::__toString()
File
- vendor/
twig/ twig/ lib/ Twig/ Node.php, line 44
Class
- Twig_Node
- Represents a node in the AST.
Code
public function __toString() {
$attributes = array();
foreach ($this->attributes as $name => $value) {
$attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
}
$repr = array(
get_class($this) . '(' . implode(', ', $attributes),
);
if (count($this->nodes)) {
foreach ($this->nodes as $name => $node) {
$len = strlen($name) + 4;
$noderepr = array();
foreach (explode("\n", (string) $node) as $line) {
$noderepr[] = str_repeat(' ', $len) . $line;
}
$repr[] = sprintf(' %s: %s', $name, ltrim(implode("\n", $noderepr)));
}
$repr[] = ')';
}
else {
$repr[0] .= ')';
}
return implode("\n", $repr);
}