Returns a PHP representation of a given value.
mixed $value The value to convert:
Twig_Compiler The current compiler instance
public function repr($value) {
if (is_int($value) || is_float($value)) {
if (false !== ($locale = setlocale(LC_NUMERIC, 0))) {
setlocale(LC_NUMERIC, 'C');
}
$this
->raw($value);
if (false !== $locale) {
setlocale(LC_NUMERIC, $locale);
}
}
elseif (null === $value) {
$this
->raw('null');
}
elseif (is_bool($value)) {
$this
->raw($value ? 'true' : 'false');
}
elseif (is_array($value)) {
$this
->raw('array(');
$i = 0;
foreach ($value as $key => $value) {
if ($i++) {
$this
->raw(', ');
}
$this
->repr($key);
$this
->raw(' => ');
$this
->repr($value);
}
$this
->raw(')');
}
else {
$this
->string($value);
}
return $this;
}