4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\VarDumper;
14 use Symfony\Component\VarDumper\Cloner\VarCloner;
15 use Symfony\Component\VarDumper\Dumper\CliDumper;
16 use Symfony\Component\VarDumper\Dumper\HtmlDumper;
18 // Load the global dump() function
19 require_once __DIR__.'/Resources/functions/dump.php';
22 * @author Nicolas Grekas <p@tchwork.com>
26 private static $handler;
28 public static function dump($var)
30 if (null === self::$handler) {
31 $cloner = new VarCloner();
32 $dumper = \in_array(\PHP_SAPI, array('cli', 'phpdbg'), true) ? new CliDumper() : new HtmlDumper();
33 self::$handler = function ($var) use ($cloner, $dumper) {
34 $dumper->dump($cloner->cloneVar($var));
38 return \call_user_func(self::$handler, $var);
41 public static function setHandler(callable $callable = null)
43 $prevHandler = self::$handler;
44 self::$handler = $callable;