4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
15 class Twig_Extension_Debug extends Twig_Extension
17 public function getFunctions()
19 // dump is safe if var_dump is overridden by xdebug
20 $isDumpOutputHtmlSafe = extension_loaded('xdebug')
21 // false means that it was not set (and the default is on) or it explicitly enabled
22 && (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump'))
23 // false means that it was not set (and the default is on) or it explicitly enabled
24 // xdebug.overload_var_dump produces HTML only when html_errors is also enabled
25 && (false === ini_get('html_errors') || ini_get('html_errors'))
30 new Twig_SimpleFunction('dump', 'twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
34 public function getName()
40 function twig_var_dump(Twig_Environment $env, $context)
42 if (!$env->isDebug()) {
48 $count = func_num_args();
51 foreach ($context as $key => $value) {
52 if (!$value instanceof Twig_Template) {
59 for ($i = 2; $i < $count; ++$i) {
60 var_dump(func_get_arg($i));
64 return ob_get_clean();
67 class_alias('Twig_Extension_Debug', 'Twig\Extension\DebugExtension', false);