comparison vendor/symfony/var-dumper/VarDumper.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 7a779792577d
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\VarDumper;
13
14 use Symfony\Component\VarDumper\Cloner\VarCloner;
15 use Symfony\Component\VarDumper\Dumper\CliDumper;
16 use Symfony\Component\VarDumper\Dumper\HtmlDumper;
17
18 // Load the global dump() function
19 require_once __DIR__.'/Resources/functions/dump.php';
20
21 /**
22 * @author Nicolas Grekas <p@tchwork.com>
23 */
24 class VarDumper
25 {
26 private static $handler;
27
28 public static function dump($var)
29 {
30 if (null === self::$handler) {
31 $cloner = new VarCloner();
32 $dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();
33 self::$handler = function ($var) use ($cloner, $dumper) {
34 $dumper->dump($cloner->cloneVar($var));
35 };
36 }
37
38 return call_user_func(self::$handler, $var);
39 }
40
41 public static function setHandler(callable $callable = null)
42 {
43 $prevHandler = self::$handler;
44 self::$handler = $callable;
45
46 return $prevHandler;
47 }
48 }