Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / var-dumper / VarDumper.php
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 = \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));
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 }