Guest User

Untitled

a guest
Feb 23rd, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 216.05 KB | None | 0 0
  1. <?php
  2. class Kint
  3. {
  4.     public static $enabled_mode = true;
  5.     public static $mode_default = self::MODE_RICH;
  6.     public static $mode_default_cli = self::MODE_CLI;
  7.     public static $return;
  8.     public static $file_link_format = '';
  9.     public static $display_called_from = true;
  10.     public static $app_root_dirs = array();
  11.     public static $max_depth = 6;
  12.     public static $expanded = false;
  13.     public static $cli_detection = true;
  14.     public static $aliases = array(
  15.         array(
  16.             'Kint',
  17.             'dump'
  18.         ) ,
  19.         array(
  20.             'Kint',
  21.             'trace'
  22.         ) ,
  23.         array(
  24.             'Kint',
  25.             'dumpArray'
  26.         ) ,
  27.     );
  28.     public static $renderers = array(
  29.         self::MODE_RICH => 'Kint_Renderer_Rich',
  30.         self::MODE_PLAIN => 'Kint_Renderer_Plain',
  31.         self::MODE_TEXT => 'Kint_Renderer_Text',
  32.         self::MODE_CLI => 'Kint_Renderer_Cli',
  33.     );
  34.     const MODE_RICH = 'r';
  35.     const MODE_TEXT = 't';
  36.     const MODE_CLI = 'c';
  37.     const MODE_PLAIN = 'p';
  38.     public static $plugins = array(
  39.         'Kint_Parser_Base64',
  40.         'Kint_Parser_Blacklist',
  41.         'Kint_Parser_ClassMethods',
  42.         'Kint_Parser_ClassStatics',
  43.         'Kint_Parser_Closure',
  44.         'Kint_Parser_Color',
  45.         'Kint_Parser_DateTime',
  46.         'Kint_Parser_FsPath',
  47.         'Kint_Parser_Iterator',
  48.         'Kint_Parser_Json',
  49.         'Kint_Parser_Microtime',
  50.         'Kint_Parser_SimpleXMLElement',
  51.         'Kint_Parser_SplFileInfo',
  52.         'Kint_Parser_SplObjectStorage',
  53.         'Kint_Parser_Stream',
  54.         'Kint_Parser_Table',
  55.         'Kint_Parser_Throwable',
  56.         'Kint_Parser_Timestamp',
  57.         'Kint_Parser_ToString',
  58.         'Kint_Parser_Trace',
  59.         'Kint_Parser_Xml',
  60.     );
  61.     private static $plugin_pool = array();
  62.     private static $dump_array = false;
  63.     private static $names = array();
  64.     public static function settings(array $settings = null)
  65.     {
  66.         static $keys = array(
  67.             'aliases',
  68.             'app_root_dirs',
  69.             'cli_detection',
  70.             'display_called_from',
  71.             'enabled_mode',
  72.             'expanded',
  73.             'file_link_format',
  74.             'max_depth',
  75.             'mode_default',
  76.             'mode_default_cli',
  77.             'renderers',
  78.             'return',
  79.             'plugins',
  80.         );
  81.         $out = array();
  82.         foreach ($keys as $key)
  83.         {
  84.             $out[$key] = self::$$key;
  85.         }
  86.         if ($settings !== null)
  87.         {
  88.             $in = array_intersect_key($settings, $out);
  89.             foreach ($in as $key => $val)
  90.             {
  91.                 self::$$key = $val;
  92.             }
  93.         }
  94.         return $out;
  95.     }
  96.     public static function trace($trace = null)
  97.     {
  98.         if ($trace === null)
  99.         {
  100.             if (KINT_PHP525)
  101.             {
  102.                 $trace = debug_backtrace(true);
  103.             }
  104.             else
  105.             {
  106.                 $trace = debug_backtrace();
  107.             }
  108.         }
  109.         else
  110.         {
  111.             return self::dump($trace);
  112.         }
  113.         Kint_Parser_Trace::normalizeAliases(self::$aliases);
  114.         $trimmed_trace = array();
  115.         foreach ($trace as $frame)
  116.         {
  117.             if (Kint_Parser_Trace::frameIsListed($frame, self::$aliases))
  118.             {
  119.                 $trimmed_trace = array();
  120.             }
  121.             $trimmed_trace[] = $frame;
  122.         }
  123.         return self::dumpArray(array(
  124.             $trimmed_trace
  125.         ) , array(
  126.             Kint_Object::blank('Kint::trace()', 'debug_backtrace()')
  127.         ));
  128.     }
  129.     public static function dumpArray(array $data, array $names = null)
  130.     {
  131.         self::$names = $names;
  132.         self::$dump_array = true;
  133.         $out = self::dump($data);
  134.         self::$names = null;
  135.         self::$dump_array = false;
  136.         return $out;
  137.     }
  138.     public static function dump($data = null)
  139.     {
  140.         if (!self::$enabled_mode)
  141.         {
  142.             return 0;
  143.         }
  144.         $stash = self::settings();
  145.         $num_args = func_num_args();
  146.         list($params, $modifiers, $callee, $caller, $minitrace) = self::getCalleeInfo(defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace() , $num_args);
  147.         if (self::$enabled_mode === true)
  148.         {
  149.             self::$enabled_mode = self::$mode_default;
  150.             if (PHP_SAPI === 'cli' && self::$cli_detection === true)
  151.             {
  152.                 self::$enabled_mode = self::$mode_default_cli;
  153.             }
  154.         }
  155.         if (in_array('~', $modifiers))
  156.         {
  157.             self::$enabled_mode = self::MODE_TEXT;
  158.         }
  159.         if (!array_key_exists(self::$enabled_mode, self::$renderers))
  160.         {
  161.             $renderer = self::$renderers[self::MODE_PLAIN];
  162.         }
  163.         else
  164.         {
  165.             $renderer = self::$renderers[self::$enabled_mode];
  166.         }
  167.         if (in_array('-', $modifiers))
  168.         {
  169.             while (ob_get_level())
  170.             {
  171.                 ob_end_clean();
  172.             }
  173.         }
  174.         if (in_array('!', $modifiers))
  175.         {
  176.             self::$expanded = true;
  177.         }
  178.         if (in_array('+', $modifiers))
  179.         {
  180.             self::$max_depth = false;
  181.         }
  182.         if (in_array('@', $modifiers))
  183.         {
  184.             self::$return = true;
  185.         }
  186.         $renderer = new $renderer(array(
  187.             'num_args' => $num_args,
  188.             'params' => $params,
  189.             'modifiers' => $modifiers,
  190.             'callee' => $callee,
  191.             'caller' => $caller,
  192.             'minitrace' => $minitrace,
  193.             'settings' => self::settings() ,
  194.             'stash' => $stash,
  195.         ));
  196.         $plugins = array();
  197.         foreach (self::$plugins as $plugin)
  198.         {
  199.             if ($plugin instanceof Kint_Parser_Plugin)
  200.             {
  201.                 $plugins[] = $plugin;
  202.             }
  203.             elseif (is_string($plugin) && is_subclass_of($plugin, 'Kint_Parser_Plugin'))
  204.             {
  205.                 if (!isset(self::$plugin_pool[$plugin]))
  206.                 {
  207.                     $p = new $plugin();
  208.                     self::$plugin_pool[$plugin] = $p;
  209.                 }
  210.                 $plugins[] = self::$plugin_pool[$plugin];
  211.             }
  212.         }
  213.         $plugins = $renderer->parserPlugins($plugins);
  214.         $output = $renderer->preRender();
  215.         $parser = new Kint_Parser(self::$max_depth, empty($caller['class']) ? null : $caller['class']);
  216.         foreach ($plugins as $plugin)
  217.         {
  218.             $parser->addPlugin($plugin);
  219.         }
  220.         if (!self::$dump_array && (!isset($params[0]['name']) || $params[0]['name'] == '1') && $num_args === 1 && $data === 1)
  221.         {
  222.             if (KINT_PHP525)
  223.             {
  224.                 $data = debug_backtrace(true);
  225.             }
  226.             else
  227.             {
  228.                 $data = debug_backtrace();
  229.             }
  230.             $trace = array();
  231.             foreach ($data as $index => $frame)
  232.             {
  233.                 if (Kint_Parser_Trace::frameIsListed($frame, self::$aliases))
  234.                 {
  235.                     $trace = array();
  236.                 }
  237.                 $trace[] = $frame;
  238.             }
  239.             $lastframe = reset($trace);
  240.             $tracename = $lastframe['function'] . '(1)';
  241.             if (isset($lastframe['class'], $lastframe['type']))
  242.             {
  243.                 $tracename = $lastframe['class'] . $lastframe['type'] . $tracename;
  244.             }
  245.             $tracebase = Kint_Object::blank($tracename, 'debug_backtrace()');
  246.             if (empty($trace))
  247.             {
  248.                 $output .= $renderer->render($tracebase->transplant(new Kint_Object_Trace()));
  249.             }
  250.             else
  251.             {
  252.                 $output .= $renderer->render($parser->parse($trace, $tracebase));
  253.             }
  254.         }
  255.         else
  256.         {
  257.             $data = func_get_args();
  258.             if ($data === array())
  259.             {
  260.                 $output .= $renderer->render(new Kint_Object_Nothing());
  261.             }
  262.             if (self::$dump_array)
  263.             {
  264.                 $data = $data[0];
  265.             }
  266.             static $blacklist = array(
  267.                 'null',
  268.                 'true',
  269.                 'false',
  270.                 'array(...)',
  271.                 'array()',
  272.                 '"..."',
  273.                 'b"..."',
  274.                 '[...]',
  275.                 '[]',
  276.                 '(...)',
  277.                 '()'
  278.             );
  279.             foreach ($data as $i => $argument)
  280.             {
  281.                 if (isset(self::$names[$i]))
  282.                 {
  283.                     $output .= $renderer->render($parser->parse($argument, self::$names[$i]));
  284.                     continue;
  285.                 }
  286.                 if (!isset($params[$i]['name']) || is_numeric($params[$i]['name']) || in_array(str_replace("'", '"', strtolower($params[$i]['name'])) , $blacklist, true))
  287.                 {
  288.                     $name = null;
  289.                 }
  290.                 else
  291.                 {
  292.                     $name = $params[$i]['name'];
  293.                 }
  294.                 if (isset($params[$i]['path']))
  295.                 {
  296.                     $access_path = $params[$i]['path'];
  297.                     if (!empty($params[$i]['expression']))
  298.                     {
  299.                         $access_path = '(' . $access_path . ')';
  300.                     }
  301.                 }
  302.                 else
  303.                 {
  304.                     $access_path = '$' . $i;
  305.                 }
  306.                 $output .= $renderer->render($parser->parse($argument, Kint_Object::blank($name, $access_path)));
  307.             }
  308.         }
  309.         $output .= $renderer->postRender();
  310.         if (self::$return)
  311.         {
  312.             self::settings($stash);
  313.             return $output;
  314.         }
  315.         self::settings($stash);
  316.         echo $output;
  317.         return 0;
  318.     }
  319.     public static function shortenPath($file)
  320.     {
  321.         $file = array_values(array_filter(explode('/', str_replace('\\', '/', $file)) , 'strlen'));
  322.         $longest_match = 0;
  323.         $match = '/';
  324.         foreach (self::$app_root_dirs as $path => $alias)
  325.         {
  326.             if (empty($path))
  327.             {
  328.                 continue;
  329.             }
  330.             $path = array_values(array_filter(explode('/', str_replace('\\', '/', $path)) , 'strlen'));
  331.             if (array_slice($file, 0, count($path)) === $path && count($path) > $longest_match)
  332.             {
  333.                 $longest_match = count($path);
  334.                 $match = $alias;
  335.             }
  336.         }
  337.         if ($longest_match)
  338.         {
  339.             $file = array_merge(array(
  340.                 $match
  341.             ) , array_slice($file, $longest_match));
  342.             return implode('/', $file);
  343.         }
  344.         else
  345.         {
  346.             $kint = array_values(array_filter(explode('/', str_replace('\\', '/', KINT_DIR)) , 'strlen'));
  347.             foreach ($file as $i => $part)
  348.             {
  349.                 if (!isset($kint[$i]) || $kint[$i] !== $part)
  350.                 {
  351.                     return ($i ? '.../' : '/') . implode('/', array_slice($file, $i));
  352.                 }
  353.             }
  354.             return '/' . implode('/', $file);
  355.         }
  356.     }
  357.     public static function getIdeLink($file, $line)
  358.     {
  359.         return str_replace(array(
  360.             '%f',
  361.             '%l'
  362.         ) , array(
  363.             $file,
  364.             $line
  365.         ) , self::$file_link_format);
  366.     }
  367.     private static function getCalleeInfo($trace, $num_params)
  368.     {
  369.         Kint_Parser_Trace::normalizeAliases(self::$aliases);
  370.         $miniTrace = array();
  371.         foreach ($trace as $index => $frame)
  372.         {
  373.             if (Kint_Parser_Trace::frameIsListed($frame, self::$aliases))
  374.             {
  375.                 $miniTrace = array();
  376.             }
  377.             if (!Kint_Parser_Trace::frameIsListed($frame, array(
  378.                 'spl_autoload_call'
  379.             )))
  380.             {
  381.                 $miniTrace[] = $frame;
  382.             }
  383.         }
  384.         $callee = reset($miniTrace);
  385.         $caller = next($miniTrace);
  386.         if (!$callee)
  387.         {
  388.             $callee = null;
  389.         }
  390.         if (!$caller)
  391.         {
  392.             $caller = null;
  393.         }
  394.         unset($miniTrace[0]);
  395.         foreach ($miniTrace as $index => & $frame)
  396.         {
  397.             if (!isset($frame['file'], $frame['line']))
  398.             {
  399.                 unset($miniTrace[$index]);
  400.             }
  401.             else
  402.             {
  403.                 unset($frame['object'], $frame['args']);
  404.             }
  405.         }
  406.         $miniTrace = array_values($miniTrace);
  407.         if (!isset($callee['file'], $callee['line']) || !is_readable($callee['file']))
  408.         {
  409.             return array(
  410.                 null,
  411.                 array() ,
  412.                 $callee,
  413.                 $caller,
  414.                 $miniTrace
  415.             );
  416.         }
  417.         if (empty($callee['class']))
  418.         {
  419.             $callfunc = $callee['function'];
  420.         }
  421.         else
  422.         {
  423.             $callfunc = array(
  424.                 $callee['class'],
  425.                 $callee['function']
  426.             );
  427.         }
  428.         $calls = Kint_SourceParser::getFunctionCalls(file_get_contents($callee['file']) , $callee['line'], $callfunc);
  429.         $return = array(
  430.             null,
  431.             array() ,
  432.             $callee,
  433.             $caller,
  434.             $miniTrace
  435.         );
  436.         foreach ($calls as $call)
  437.         {
  438.             $is_unpack = false;
  439.             if (KINT_PHP56)
  440.             {
  441.                 foreach ($call['parameters'] as $i => & $param)
  442.                 {
  443.                     if (strpos($param['name'], '...') === 0)
  444.                     {
  445.                         if ($i === count($call['parameters']) - 1)
  446.                         {
  447.                             for ($j = 1;$j + $i < $num_params;++$j)
  448.                             {
  449.                                 $call['parameters'][] = array(
  450.                                     'name' => 'array_values(' . substr($param['name'], 3) . ')[' . $j . ']',
  451.                                     'path' => 'array_values(' . substr($param['path'], 3) . ')[' . $j . ']',
  452.                                     'expression' => false,
  453.                                 );
  454.                             }
  455.                             $param['name'] = 'reset(' . substr($param['name'], 3) . ')';
  456.                             $param['path'] = 'reset(' . substr($param['path'], 3) . ')';
  457.                             $param['expression'] = false;
  458.                         }
  459.                         else
  460.                         {
  461.                             $call['parameters'] = array_slice($call['parameters'], 0, $i);
  462.                         }
  463.                         $is_unpack = true;
  464.                         break;
  465.                     }
  466.                 }
  467.             }
  468.             if ($is_unpack || count($call['parameters']) === $num_params)
  469.             {
  470.                 if ($return[0] === null)
  471.                 {
  472.                     $return = array(
  473.                         $call['parameters'],
  474.                         $call['modifiers'],
  475.                         $callee,
  476.                         $caller,
  477.                         $miniTrace
  478.                     );
  479.                 }
  480.                 else
  481.                 {
  482.                     return array(
  483.                         null,
  484.                         array() ,
  485.                         $callee,
  486.                         $caller,
  487.                         $miniTrace
  488.                     );
  489.                 }
  490.             }
  491.         }
  492.         return $return;
  493.     }
  494.     public static function composerGetExtras($key = 'kint')
  495.     {
  496.         $extras = array();
  497.         if (!KINT_PHP53)
  498.         {
  499.             return $extras;
  500.         }
  501.         $folder = KINT_DIR . '/vendor';
  502.         for ($i = 0;$i < 4;++$i)
  503.         {
  504.             $installed = $folder . '/composer/installed.json';
  505.             if (file_exists($installed) && is_readable($installed))
  506.             {
  507.                 $packages = json_decode(file_get_contents($installed) , true);
  508.                 foreach ($packages as $package)
  509.                 {
  510.                     if (isset($package['extra'][$key]) && is_array($package['extra'][$key]))
  511.                     {
  512.                         $extras = array_replace($extras, $package['extra'][$key]);
  513.                     }
  514.                 }
  515.                 $folder = dirname($folder);
  516.                 if (file_exists($folder . '/composer.json') && is_readable($folder . '/composer.json'))
  517.                 {
  518.                     $composer = json_decode(file_get_contents($folder . '/composer.json') , true);
  519.                     if (isset($composer['extra'][$key]) && is_array($composer['extra'][$key]))
  520.                     {
  521.                         $extras = array_replace($extras, $composer['extra'][$key]);
  522.                     }
  523.                 }
  524.                 break;
  525.             }
  526.             else
  527.             {
  528.                 $folder = dirname($folder);
  529.             }
  530.         }
  531.         return $extras;
  532.     }
  533.     public static function composerGetDisableHelperFunctions()
  534.     {
  535.         $extras = self::composerGetExtras();
  536.         return !empty($extras['disable-helper-functions']);
  537.     }
  538. }
  539. class Kint_Object
  540. {
  541.     const ACCESS_NONE = null;
  542.     const ACCESS_PUBLIC = 'public';
  543.     const ACCESS_PROTECTED = 'protected';
  544.     const ACCESS_PRIVATE = 'private';
  545.     const OPERATOR_NONE = null;
  546.     const OPERATOR_ARRAY = '=>';
  547.     const OPERATOR_OBJECT = '->';
  548.     const OPERATOR_STATIC = '::';
  549.     public $name;
  550.     public $type;
  551.     public $static = false;
  552.     public $const = false;
  553.     public $access = self::ACCESS_NONE;
  554.     public $owner_class;
  555.     public $access_path;
  556.     public $operator = self::OPERATOR_NONE;
  557.     public $reference = false;
  558.     public $size = null;
  559.     public $depth = 0;
  560.     public $representations = array();
  561.     public $value = null;
  562.     public $hints = array();
  563.     public function __construct()
  564.     {
  565.     }
  566.     public function addRepresentation(Kint_Object_Representation $rep, $pos = null)
  567.     {
  568.         if (isset($this->representations[$rep->name]))
  569.         {
  570.             return false;
  571.         }
  572.         if ($this->value === null)
  573.         {
  574.             $this->value = $rep;
  575.         }
  576.         if ($pos === null)
  577.         {
  578.             $this->representations[$rep->name] = $rep;
  579.         }
  580.         else
  581.         {
  582.             $this->representations = array_merge(array_slice($this->representations, 0, $pos) , array(
  583.                 $rep->name => $rep
  584.             ) , array_slice($this->representations, $pos));
  585.         }
  586.         return true;
  587.     }
  588.     public function replaceRepresentation(Kint_Object_Representation $rep, $pos = null)
  589.     {
  590.         if ($pos === null)
  591.         {
  592.             $this->representations[$rep->name] = $rep;
  593.         }
  594.         else
  595.         {
  596.             $this->removeRepresentation($rep->name);
  597.             $this->addRepresentation($rep, $pos);
  598.         }
  599.     }
  600.     public function removeRepresentation($name)
  601.     {
  602.         unset($this->representations[$name]);
  603.     }
  604.     public function getRepresentation($name)
  605.     {
  606.         if (isset($this->representations[$name]))
  607.         {
  608.             return $this->representations[$name];
  609.         }
  610.     }
  611.     public function getRepresentations()
  612.     {
  613.         return $this->representations;
  614.     }
  615.     public function clearRepresentations()
  616.     {
  617.         $this->representations = array();
  618.     }
  619.     public function getType()
  620.     {
  621.         return $this->type;
  622.     }
  623.     public function getModifiers()
  624.     {
  625.         $out = $this->getAccess();
  626.         if ($this->const)
  627.         {
  628.             $out .= ' const';
  629.         }
  630.         if ($this->static)
  631.         {
  632.             $out .= ' static';
  633.         }
  634.         if (strlen($out))
  635.         {
  636.             return ltrim($out);
  637.         }
  638.     }
  639.     public function getAccess()
  640.     {
  641.         switch ($this->access)
  642.         {
  643.             case self::ACCESS_PRIVATE:
  644.                 return 'private';
  645.             case self::ACCESS_PROTECTED:
  646.                 return 'protected';
  647.             case self::ACCESS_PUBLIC:
  648.                 return 'public';
  649.         }
  650.     }
  651.     public function getName()
  652.     {
  653.         return $this->name;
  654.     }
  655.     public function getOperator()
  656.     {
  657.         if ($this->operator === self::OPERATOR_ARRAY)
  658.         {
  659.             return '=>';
  660.         }
  661.         elseif ($this->operator === self::OPERATOR_OBJECT)
  662.         {
  663.             return '->';
  664.         }
  665.         elseif ($this->operator === self::OPERATOR_STATIC)
  666.         {
  667.             return '::';
  668.         }
  669.         return;
  670.     }
  671.     public function getSize()
  672.     {
  673.         return $this->size;
  674.     }
  675.     public function getValueShort()
  676.     {
  677.         if ($rep = $this->value)
  678.         {
  679.             if ($this->type === 'boolean')
  680.             {
  681.                 return $rep->contents ? 'true' : 'false';
  682.             }
  683.             elseif ($this->type === 'integer' || $this->type === 'double')
  684.             {
  685.                 return $rep->contents;
  686.             }
  687.         }
  688.     }
  689.     public function getAccessPath()
  690.     {
  691.         return $this->access_path;
  692.     }
  693.     public static function blank($name = null, $access_path = null)
  694.     {
  695.         $o = new self();
  696.         $o->name = $name;
  697.         $o->access_path = $name;
  698.         if ($access_path)
  699.         {
  700.             $o->access_path = $access_path;
  701.         }
  702.         return $o;
  703.     }
  704.     public function transplant(Kint_Object $new)
  705.     {
  706.         $new->name = $this->name;
  707.         $new->size = $this->size;
  708.         $new->access_path = $this->access_path;
  709.         $new->access = $this->access;
  710.         $new->static = $this->static;
  711.         $new->const = $this->const;
  712.         $new->type = $this->type;
  713.         $new->depth = $this->depth;
  714.         $new->owner_class = $this->owner_class;
  715.         $new->operator = $this->operator;
  716.         $new->reference = $this->reference;
  717.         $new->value = $this->value;
  718.         $new->representations += $this->representations;
  719.         $new->hints = array_merge($this->hints, $new->hints);
  720.         return $new;
  721.     }
  722.     public static function isSequential(array $array)
  723.     {
  724.         return array_keys($array) === range(0, count($array) - 1);
  725.     }
  726.     public static function sortByAccess(Kint_Object $a, Kint_Object $b)
  727.     {
  728.         static $sorts = array(
  729.             self::ACCESS_PUBLIC => 1,
  730.             self::ACCESS_PROTECTED => 2,
  731.             self::ACCESS_PRIVATE => 3,
  732.             self::ACCESS_NONE => 4,
  733.         );
  734.         return $sorts[$a->access] - $sorts[$b->access];
  735.     }
  736.     public static function sortByName(Kint_Object $a, Kint_Object $b)
  737.     {
  738.         $ret = strnatcasecmp($a->name, $b->name);
  739.         if ($ret === 0)
  740.         {
  741.             return is_int($a->name) - is_int($b->name);
  742.         }
  743.         return $ret;
  744.     }
  745. }
  746. class Kint_Parser
  747. {
  748.     public $caller_class;
  749.     public $max_depth;
  750.     private $marker;
  751.     private $object_hashes = array();
  752.     private $parse_break = false;
  753.     private $plugins = array();
  754.     const TRIGGER_NONE = 0;
  755.     const TRIGGER_BEGIN = 1;
  756.     const TRIGGER_SUCCESS = 2;
  757.     const TRIGGER_RECURSION = 4;
  758.     const TRIGGER_DEPTH_LIMIT = 8;
  759.     const TRIGGER_COMPLETE = 14;
  760.     public function __construct($max_depth = false, $c = null)
  761.     {
  762.         $this->marker = uniqid("kint\0", true);
  763.         $this->caller_class = $c;
  764.         $this->max_depth = $max_depth;
  765.     }
  766.     public function parse(&$var, Kint_Object $o)
  767.     {
  768.         $o->type = strtolower(gettype($var));
  769.         if (!$this->applyPlugins($var, $o, self::TRIGGER_BEGIN))
  770.         {
  771.             return $o;
  772.         }
  773.         switch ($o->type)
  774.         {
  775.             case 'array':
  776.                 return $this->parseArray($var, $o);
  777.             case 'boolean':
  778.             case 'double':
  779.             case 'integer':
  780.             case 'null':
  781.                 return $this->parseGeneric($var, $o);
  782.             case 'object':
  783.                 return $this->parseObject($var, $o);
  784.             case 'resource':
  785.                 return $this->parseResource($var, $o);
  786.             case 'string':
  787.                 return $this->parseString($var, $o);
  788.             default:
  789.                 return $this->parseUnknown($var, $o);
  790.         }
  791.     }
  792.     private function parseGeneric(&$var, Kint_Object $o)
  793.     {
  794.         $rep = new Kint_Object_Representation('Contents');
  795.         $rep->contents = $var;
  796.         $rep->implicit_label = true;
  797.         $o->addRepresentation($rep);
  798.         $this->applyPlugins($var, $o, self::TRIGGER_SUCCESS);
  799.         return $o;
  800.     }
  801.     private function parseString(&$var, Kint_Object $o)
  802.     {
  803.         $string = $o->transplant(new Kint_Object_Blob());
  804.         $string->encoding = Kint_Object_Blob::detectEncoding($var);
  805.         $string->size = Kint_Object_Blob::strlen($var, $string->encoding);
  806.         $rep = new Kint_Object_Representation('Contents');
  807.         $rep->contents = $var;
  808.         $rep->implicit_label = true;
  809.         $string->addRepresentation($rep);
  810.         $this->applyPlugins($var, $string, self::TRIGGER_SUCCESS);
  811.         return $string;
  812.     }
  813.     private function parseArray(array & $var, Kint_Object $o)
  814.     {
  815.         $array = $o->transplant(new Kint_Object());
  816.         $array->size = count($var);
  817.         if (isset($var[$this
  818.             ->marker]))
  819.         {
  820.             --$array->size;
  821.             $array->hints[] = 'recursion';
  822.             $this->applyPlugins($var, $array, self::TRIGGER_RECURSION);
  823.             return $array;
  824.         }
  825.         $rep = new Kint_Object_Representation('Contents');
  826.         $rep->implicit_label = true;
  827.         $array->addRepresentation($rep);
  828.         if ($array->size)
  829.         {
  830.             if ($this->max_depth && $o->depth >= $this->max_depth)
  831.             {
  832.                 $array->hints[] = 'depth_limit';
  833.                 $this->applyPlugins($var, $array, self::TRIGGER_DEPTH_LIMIT);
  834.                 return $array;
  835.             }
  836.             if (KINT_PHP522)
  837.             {
  838.                 $copy = array_values($var);
  839.             }
  840.             $i = 0;
  841.             $var[$this
  842.                 ->marker] = $array->depth;
  843.             foreach ($var as $key => & $val)
  844.             {
  845.                 if ($key === $this->marker)
  846.                 {
  847.                     continue;
  848.                 }
  849.                 $child = new Kint_Object();
  850.                 $child->name = $key;
  851.                 $child->depth = $array->depth + 1;
  852.                 $child->access = Kint_Object::ACCESS_NONE;
  853.                 $child->operator = Kint_Object::OPERATOR_ARRAY;
  854.                 if ($array->access_path !== null)
  855.                 {
  856.                     if (is_string($key) && (string)(int)$key === $key)
  857.                     {
  858.                         $child->access_path = 'array_values(' . $array->access_path . ')[' . $i . ']';
  859.                     }
  860.                     else
  861.                     {
  862.                         $child->access_path = $array->access_path . '[' . var_export($key, true) . ']';
  863.                     }
  864.                 }
  865.                 if (KINT_PHP522)
  866.                 {
  867.                     $stash = $val;
  868.                     $copy[$i] = $this->marker;
  869.                     if ($val === $this->marker)
  870.                     {
  871.                         $child->reference = true;
  872.                         $val = $stash;
  873.                     }
  874.                 }
  875.                 $rep->contents[] = $this->parse($val, $child);
  876.                 ++$i;
  877.             }
  878.             $this->applyPlugins($var, $array, self::TRIGGER_SUCCESS);
  879.             unset($var[$this->marker]);
  880.             return $array;
  881.         }
  882.         else
  883.         {
  884.             $this->applyPlugins($var, $array, self::TRIGGER_SUCCESS);
  885.             return $array;
  886.         }
  887.     }
  888.     private function parseObject(&$var, Kint_Object $o)
  889.     {
  890.         if (KINT_PHP53 || function_exists('spl_object_hash'))
  891.         {
  892.             $hash = spl_object_hash($var);
  893.         }
  894.         else
  895.         {
  896.             ob_start();
  897.             var_dump($var);
  898.             preg_match('/#(\d+)/', ob_get_clean() , $match);
  899.             $hash = $match[1];
  900.         }
  901.         $values = (array)$var;
  902.         $object = $o->transplant(new Kint_Object_Instance());
  903.         $object->classname = get_class($var);
  904.         $object->hash = $hash;
  905.         $object->size = count($values);
  906.         if (isset($this->object_hashes[$hash]))
  907.         {
  908.             $object->hints[] = 'recursion';
  909.             $this->applyPlugins($var, $object, self::TRIGGER_RECURSION);
  910.             return $object;
  911.         }
  912.         $this->object_hashes[$hash] = $object;
  913.         if ($this->max_depth && $o->depth >= $this->max_depth)
  914.         {
  915.             $object->hints[] = 'depth_limit';
  916.             $this->applyPlugins($var, $object, self::TRIGGER_DEPTH_LIMIT);
  917.             unset($this->object_hashes[$hash]);
  918.             return $object;
  919.         }
  920.         if ($var instanceof ArrayObject)
  921.         {
  922.             $ArrayObject_flags_stash = $var->getFlags();
  923.             $var->setFlags(ArrayObject::STD_PROP_LIST);
  924.         }
  925.         $reflector = new ReflectionObject($var);
  926.         if ($reflector->isUserDefined())
  927.         {
  928.             $object->filename = $reflector->getFileName();
  929.             $object->startline = $reflector->getStartLine();
  930.         }
  931.         $rep = new Kint_Object_Representation('Properties');
  932.         if (KINT_PHP522)
  933.         {
  934.             $copy = array_values($values);
  935.         }
  936.         $i = 0;
  937.         foreach ($values as $key => & $val)
  938.         {
  939.             $child = new Kint_Object();
  940.             $child->depth = $object->depth + 1;
  941.             $child->owner_class = $object->classname;
  942.             $child->operator = Kint_Object::OPERATOR_OBJECT;
  943.             $child->access = Kint_Object::ACCESS_PUBLIC;
  944.             $split_key = explode("\0", $key, 3);
  945.             if (count($split_key) === 3 && $split_key[0] === '')
  946.             {
  947.                 $child->name = $split_key[2];
  948.                 if ($split_key[1] === '*')
  949.                 {
  950.                     $child->access = Kint_Object::ACCESS_PROTECTED;
  951.                 }
  952.                 else
  953.                 {
  954.                     $child->access = Kint_Object::ACCESS_PRIVATE;
  955.                     $child->owner_class = $split_key[1];
  956.                 }
  957.             }
  958.             elseif (KINT_PHP72)
  959.             {
  960.                 $child->name = (string)$key;
  961.             }
  962.             else
  963.             {
  964.                 $child->name = $key;
  965.             }
  966.             if ($this->childHasPath($object, $child))
  967.             {
  968.                 $child->access_path = $object->access_path;
  969.                 if (!KINT_PHP72 && is_int($child->name))
  970.                 {
  971.                     $child->access_path = 'array_values((array) ' . $child->access_path . ')[' . $i . ']';
  972.                 }
  973.                 elseif (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $child->name))
  974.                 {
  975.                     $child->access_path .= '->' . $child->name;
  976.                 }
  977.                 else
  978.                 {
  979.                     $child->access_path .= '->{' . var_export((string)$child->name, true) . '}';
  980.                 }
  981.             }
  982.             if (KINT_PHP522)
  983.             {
  984.                 $stash = $val;
  985.                 $copy[$i] = $this->marker;
  986.                 if ($val === $this->marker)
  987.                 {
  988.                     $child->reference = true;
  989.                     $val = $stash;
  990.                 }
  991.             }
  992.             $rep->contents[] = $this->parse($val, $child);
  993.             ++$i;
  994.         }
  995.         if (isset($ArrayObject_flags_stash))
  996.         {
  997.             $var->setFlags($ArrayObject_flags_stash);
  998.         }
  999.         usort($rep->contents, array(
  1000.             'Kint_Parser',
  1001.             'sortObjectProperties'
  1002.         ));
  1003.         $object->addRepresentation($rep);
  1004.         $this->applyPlugins($var, $object, self::TRIGGER_SUCCESS);
  1005.         unset($this->object_hashes[$hash]);
  1006.         return $object;
  1007.     }
  1008.     private function parseResource(&$var, Kint_Object $o)
  1009.     {
  1010.         $resource = $o->transplant(new Kint_Object_Resource());
  1011.         $resource->resource_type = get_resource_type($var);
  1012.         $this->applyPlugins($var, $resource, self::TRIGGER_SUCCESS);
  1013.         return $resource;
  1014.     }
  1015.     private function parseUnknown(&$var, Kint_Object $o)
  1016.     {
  1017.         $o->type = 'unknown';
  1018.         $this->applyPlugins($var, $o, self::TRIGGER_SUCCESS);
  1019.         return $o;
  1020.     }
  1021.     public function addPlugin(Kint_Parser_Plugin $p)
  1022.     {
  1023.         if (!$types = $p->getTypes())
  1024.         {
  1025.             return false;
  1026.         }
  1027.         if (!$triggers = $p->getTriggers())
  1028.         {
  1029.             return false;
  1030.         }
  1031.         $p->setParser($this);
  1032.         foreach ($types as $type)
  1033.         {
  1034.             if (!isset($this->plugins[$type]))
  1035.             {
  1036.                 $this->plugins[$type] = array(
  1037.                     self::TRIGGER_BEGIN => array() ,
  1038.                     self::TRIGGER_SUCCESS => array() ,
  1039.                     self::TRIGGER_RECURSION => array() ,
  1040.                     self::TRIGGER_DEPTH_LIMIT => array() ,
  1041.                 );
  1042.             }
  1043.             foreach ($this->plugins[$type] as $trigger => & $pool)
  1044.             {
  1045.                 if ($triggers & $trigger)
  1046.                 {
  1047.                     $pool[] = $p;
  1048.                 }
  1049.             }
  1050.         }
  1051.         return true;
  1052.     }
  1053.     public function clearPlugins()
  1054.     {
  1055.         $this->plugins = array();
  1056.     }
  1057.     private function applyPlugins(&$var, Kint_Object & $o, $trigger)
  1058.     {
  1059.         $break_stash = $this->parse_break;
  1060.         $this->parse_break = false;
  1061.         $plugins = array();
  1062.         if (isset($this->plugins[$o->type][$trigger]))
  1063.         {
  1064.             $plugins = $this->plugins[$o->type][$trigger];
  1065.         }
  1066.         foreach ($plugins as $plugin)
  1067.         {
  1068.             try
  1069.             {
  1070.                 $plugin->parse($var, $o, $trigger);
  1071.             }
  1072.             catch(Exception $e)
  1073.             {
  1074.                 trigger_error('An exception (' . get_class($e) . ') was thrown in ' . $e->getFile() . ' on line ' . $e->getLine() . ' while executing Kint Parser Plugin "' . get_class($plugin) . '". Error message: ' . $e->getMessage() , E_USER_WARNING);
  1075.             }
  1076.             if ($this->parse_break)
  1077.             {
  1078.                 $this->parse_break = $break_stash;
  1079.                 return false;
  1080.             }
  1081.         }
  1082.         $this->parse_break = $break_stash;
  1083.         return true;
  1084.     }
  1085.     public function haltParse()
  1086.     {
  1087.         $this->parse_break = true;
  1088.     }
  1089.     public function childHasPath(Kint_Object_Instance $parent, Kint_Object $child)
  1090.     {
  1091.         if ($parent->type === 'object' && ($parent->access_path !== null || $child->static || $child->const))
  1092.         {
  1093.             if ($child->access === Kint_Object::ACCESS_PUBLIC)
  1094.             {
  1095.                 return true;
  1096.             }
  1097.             elseif ($child->access === Kint_Object::ACCESS_PRIVATE && $this->caller_class && $this->caller_class === $child->owner_class)
  1098.             {
  1099.                 if (KINT_PHP53 || (!$child->static && !$child->const))
  1100.                 {
  1101.                     return true;
  1102.                 }
  1103.             }
  1104.             elseif ($child->access === Kint_Object::ACCESS_PROTECTED && $this->caller_class)
  1105.             {
  1106.                 if (is_a($this->caller_class, $child->owner_class, true) || is_a($child->owner_class, $this->caller_class, true))
  1107.                 {
  1108.                     return true;
  1109.                 }
  1110.             }
  1111.         }
  1112.         return false;
  1113.     }
  1114.     public function getCleanArray(array $array)
  1115.     {
  1116.         unset($array[$this->marker]);
  1117.         return $array;
  1118.     }
  1119.     private static function sortObjectProperties(Kint_Object $a, Kint_Object $b)
  1120.     {
  1121.         $sort = Kint_Object::sortByAccess($a, $b);
  1122.         if ($sort)
  1123.         {
  1124.             return $sort;
  1125.         }
  1126.         $sort = Kint_Object::sortByName($a, $b);
  1127.         if ($sort)
  1128.         {
  1129.             return $sort;
  1130.         }
  1131.         return Kint_Object_Instance::sortByHierarchy($a->owner_class, $b->owner_class);
  1132.     }
  1133. }
  1134. abstract class Kint_Renderer
  1135. {
  1136.     protected $parameters;
  1137.     abstract public function render(Kint_Object $o);
  1138.     public function __construct(array $parameters)
  1139.     {
  1140.         $this->parameters = $parameters;
  1141.     }
  1142.     public function matchPlugins(array $plugins, array $hints)
  1143.     {
  1144.         $out = array();
  1145.         foreach ($hints as $key)
  1146.         {
  1147.             if (isset($plugins[$key]))
  1148.             {
  1149.                 $out[$key] = $plugins[$key];
  1150.             }
  1151.         }
  1152.         return $out;
  1153.     }
  1154.     public function parserPlugins(array $plugins)
  1155.     {
  1156.         return $plugins;
  1157.     }
  1158.     public function preRender()
  1159.     {
  1160.         return '';
  1161.     }
  1162.     public function postRender()
  1163.     {
  1164.         return '';
  1165.     }
  1166. }
  1167. class Kint_SourceParser
  1168. {
  1169.     private static $ignore = array(
  1170.         T_CLOSE_TAG => true,
  1171.         T_COMMENT => true,
  1172.         T_DOC_COMMENT => true,
  1173.         T_INLINE_HTML => true,
  1174.         T_OPEN_TAG => true,
  1175.         T_OPEN_TAG_WITH_ECHO => true,
  1176.         T_WHITESPACE => true,
  1177.     );
  1178.     private static $operator = array(
  1179.         T_AND_EQUAL => true,
  1180.         T_BOOLEAN_AND => true,
  1181.         T_BOOLEAN_OR => true,
  1182.         T_ARRAY_CAST => true,
  1183.         T_BOOL_CAST => true,
  1184.         T_CLONE => true,
  1185.         T_CONCAT_EQUAL => true,
  1186.         T_DEC => true,
  1187.         T_DIV_EQUAL => true,
  1188.         T_DOUBLE_CAST => true,
  1189.         T_INC => true,
  1190.         T_INCLUDE => true,
  1191.         T_INCLUDE_ONCE => true,
  1192.         T_INSTANCEOF => true,
  1193.         T_INT_CAST => true,
  1194.         T_IS_EQUAL => true,
  1195.         T_IS_GREATER_OR_EQUAL => true,
  1196.         T_IS_IDENTICAL => true,
  1197.         T_IS_NOT_EQUAL => true,
  1198.         T_IS_NOT_IDENTICAL => true,
  1199.         T_IS_SMALLER_OR_EQUAL => true,
  1200.         T_LOGICAL_AND => true,
  1201.         T_LOGICAL_OR => true,
  1202.         T_LOGICAL_XOR => true,
  1203.         T_MINUS_EQUAL => true,
  1204.         T_MOD_EQUAL => true,
  1205.         T_MUL_EQUAL => true,
  1206.         T_NEW => true,
  1207.         T_OBJECT_CAST => true,
  1208.         T_OR_EQUAL => true,
  1209.         T_PLUS_EQUAL => true,
  1210.         T_REQUIRE => true,
  1211.         T_REQUIRE_ONCE => true,
  1212.         T_SL => true,
  1213.         T_SL_EQUAL => true,
  1214.         T_SR => true,
  1215.         T_SR_EQUAL => true,
  1216.         T_STRING_CAST => true,
  1217.         T_UNSET_CAST => true,
  1218.         T_XOR_EQUAL => true,
  1219.         '!' => true,
  1220.         '%' => true,
  1221.         '&' => true,
  1222.         '*' => true,
  1223.         '+' => true,
  1224.         '-' => true,
  1225.         '.' => true,
  1226.         '/' => true,
  1227.         ':' => true,
  1228.         '<' => true,
  1229.         '=' => true,
  1230.         '>' => true,
  1231.         '?' => true,
  1232.         '^' => true,
  1233.         '|' => true,
  1234.         '~' => true,
  1235.     );
  1236.     private static $strip = array(
  1237.         '(' => true,
  1238.         ')' => true,
  1239.         '[' => true,
  1240.         ']' => true,
  1241.         '{' => true,
  1242.         '}' => true,
  1243.         T_OBJECT_OPERATOR => true,
  1244.         T_DOUBLE_COLON => true,
  1245.     );
  1246.     public static function getFunctionCalls($source, $line, $function)
  1247.     {
  1248.         static $up = array(
  1249.             '(' => true,
  1250.             '[' => true,
  1251.             '{' => true,
  1252.             T_CURLY_OPEN => true,
  1253.             T_DOLLAR_OPEN_CURLY_BRACES => true,
  1254.         );
  1255.         static $down = array(
  1256.             ')' => true,
  1257.             ']' => true,
  1258.             '}' => true,
  1259.         );
  1260.         static $modifiers = array(
  1261.             '!',
  1262.             '@',
  1263.             '~',
  1264.             '+',
  1265.             '-',
  1266.         );
  1267.         if (KINT_PHP53)
  1268.         {
  1269.             self::$strip[T_NS_SEPARATOR] = true;
  1270.         }
  1271.         if (KINT_PHP56)
  1272.         {
  1273.             self::$operator[T_POW] = true;
  1274.             self::$operator[T_POW_EQUAL] = true;
  1275.         }
  1276.         if (KINT_PHP70)
  1277.         {
  1278.             self::$operator[T_SPACESHIP] = true;
  1279.         }
  1280.         $tokens = token_get_all($source);
  1281.         $cursor = 1;
  1282.         $function_calls = array();
  1283.         $prev_tokens = array(
  1284.             null,
  1285.             null,
  1286.             null
  1287.         );
  1288.         if (is_array($function))
  1289.         {
  1290.             $class = explode('\\', $function[0]);
  1291.             $class = strtolower(end($class));
  1292.             $function = strtolower($function[1]);
  1293.         }
  1294.         else
  1295.         {
  1296.             $class = null;
  1297.             $function = strtolower($function);
  1298.         }
  1299.         foreach ($tokens as $index => $token)
  1300.         {
  1301.             if (!is_array($token))
  1302.             {
  1303.                 continue;
  1304.             }
  1305.             $cursor += substr_count($token[1], "\n");
  1306.             if ($cursor > $line)
  1307.             {
  1308.                 break;
  1309.             }
  1310.             if (isset(self::$ignore[$token[0]]))
  1311.             {
  1312.                 continue;
  1313.             }
  1314.             else
  1315.             {
  1316.                 $prev_tokens = array(
  1317.                     $prev_tokens[1],
  1318.                     $prev_tokens[2],
  1319.                     $token
  1320.                 );
  1321.             }
  1322.             if ($token[0] !== T_STRING || strtolower($token[1]) !== $function)
  1323.             {
  1324.                 continue;
  1325.             }
  1326.             if ($tokens[self::realTokenIndex($tokens, $index, 1) ] !== '(')
  1327.             {
  1328.                 continue;
  1329.             }
  1330.             if ($class === null)
  1331.             {
  1332.                 if ($prev_tokens[1] && in_array($prev_tokens[1][0], array(
  1333.                     T_DOUBLE_COLON,
  1334.                     T_OBJECT_OPERATOR
  1335.                 )))
  1336.                 {
  1337.                     continue;
  1338.                 }
  1339.             }
  1340.             else
  1341.             {
  1342.                 if (!$prev_tokens[1] || $prev_tokens[1][0] !== T_DOUBLE_COLON)
  1343.                 {
  1344.                     continue;
  1345.                 }
  1346.                 if (!$prev_tokens[0] || $prev_tokens[0][0] !== T_STRING || strtolower($prev_tokens[0][1]) !== $class)
  1347.                 {
  1348.                     continue;
  1349.                 }
  1350.             }
  1351.             $inner_cursor = $cursor;
  1352.             $depth = 0;
  1353.             $offset = 1;
  1354.             $instring = false;
  1355.             $realtokens = false;
  1356.             $params = array();
  1357.             $shortparam = array();
  1358.             $param_start = 1;
  1359.             while (isset($tokens[$index + $offset]))
  1360.             {
  1361.                 $token = $tokens[$index + $offset];
  1362.                 if (is_array($token))
  1363.                 {
  1364.                     $inner_cursor += substr_count($token[1], "\n");
  1365.                 }
  1366.                 if (!isset(self::$ignore[$token[0]]) && !isset($down[$token[0]]))
  1367.                 {
  1368.                     $realtokens = true;
  1369.                 }
  1370.                 if (isset($up[$token[0]]))
  1371.                 {
  1372.                     if ($depth === 0)
  1373.                     {
  1374.                         $param_start = $offset + 1;
  1375.                     }
  1376.                     elseif ($depth === 1)
  1377.                     {
  1378.                         $shortparam[] = $token;
  1379.                         $realtokens = false;
  1380.                     }
  1381.                     ++$depth;
  1382.                 }
  1383.                 elseif (isset($down[$token[0]]))
  1384.                 {
  1385.                     --$depth;
  1386.                     if ($depth === 1)
  1387.                     {
  1388.                         if ($realtokens)
  1389.                         {
  1390.                             $shortparam[] = '...';
  1391.                         }
  1392.                         $shortparam[] = $token;
  1393.                     }
  1394.                 }
  1395.                 elseif ($token[0] === '"')
  1396.                 {
  1397.                     if ($instring)
  1398.                     {
  1399.                         --$depth;
  1400.                         if ($depth === 1)
  1401.                         {
  1402.                             $shortparam[] = '...';
  1403.                         }
  1404.                     }
  1405.                     else
  1406.                     {
  1407.                         ++$depth;
  1408.                     }
  1409.                     $instring = !$instring;
  1410.                     $shortparam[] = '"';
  1411.                 }
  1412.                 elseif ($depth === 1)
  1413.                 {
  1414.                     if ($token[0] === ',')
  1415.                     {
  1416.                         $params[] = array(
  1417.                             'full' => array_slice($tokens, $index + $param_start, $offset - $param_start) ,
  1418.                             'short' => $shortparam,
  1419.                         );
  1420.                         $shortparam = array();
  1421.                         $param_start = $offset + 1;
  1422.                     }
  1423.                     elseif ($token[0] === T_CONSTANT_ENCAPSED_STRING && strlen($token[1]) > 2)
  1424.                     {
  1425.                         $shortparam[] = $token[1][0] . '...' . $token[1][0];
  1426.                     }
  1427.                     else
  1428.                     {
  1429.                         $shortparam[] = $token;
  1430.                     }
  1431.                 }
  1432.                 if ($depth <= 0)
  1433.                 {
  1434.                     $params[] = array(
  1435.                         'full' => array_slice($tokens, $index + $param_start, $offset - $param_start) ,
  1436.                         'short' => $shortparam,
  1437.                     );
  1438.                     break;
  1439.                 }
  1440.                 ++$offset;
  1441.             }
  1442.             if ($inner_cursor < $line)
  1443.             {
  1444.                 continue;
  1445.             }
  1446.             foreach ($params as & $param)
  1447.             {
  1448.                 $name = self::tokensFormatted($param['short']);
  1449.                 $expression = false;
  1450.                 foreach ($name as $token)
  1451.                 {
  1452.                     if (self::tokenIsOperator($token))
  1453.                     {
  1454.                         $expression = true;
  1455.                         break;
  1456.                     }
  1457.                 }
  1458.                 $param = array(
  1459.                     'name' => self::tokensToString($name) ,
  1460.                     'path' => self::tokensToString(self::tokensTrim($param['full'])) ,
  1461.                     'expression' => $expression,
  1462.                 );
  1463.             }
  1464.             $mods = array();
  1465.             --$index;
  1466.             while (isset($tokens[$index]))
  1467.             {
  1468.                 if (isset(self::$ignore[$tokens[$index][0]]))
  1469.                 {
  1470.                     --$index;
  1471.                     continue;
  1472.                 }
  1473.                 elseif (is_array($tokens[$index]) && empty($mods))
  1474.                 {
  1475.                     if ($tokens[$index][0] === T_DOUBLE_COLON || $tokens[$index][0] === T_STRING || (KINT_PHP53 && $tokens[$index][0] === T_NS_SEPARATOR))
  1476.                     {
  1477.                         --$index;
  1478.                         continue;
  1479.                     }
  1480.                     else
  1481.                     {
  1482.                         break;
  1483.                     }
  1484.                 }
  1485.                 elseif (in_array($tokens[$index][0], $modifiers))
  1486.                 {
  1487.                     $mods[] = $tokens[$index];
  1488.                     --$index;
  1489.                     continue;
  1490.                 }
  1491.                 else
  1492.                 {
  1493.                     break;
  1494.                 }
  1495.             }
  1496.             $function_calls[] = array(
  1497.                 'parameters' => $params,
  1498.                 'modifiers' => $mods,
  1499.             );
  1500.         }
  1501.         return $function_calls;
  1502.     }
  1503.     private static function realTokenIndex(array $tokens, $index, $direction)
  1504.     {
  1505.         $index += $direction;
  1506.         while (isset($tokens[$index]))
  1507.         {
  1508.             if (!isset(self::$ignore[$tokens[$index][0]]))
  1509.             {
  1510.                 return $index;
  1511.             }
  1512.             $index += $direction;
  1513.         }
  1514.         return null;
  1515.     }
  1516.     private static function tokenIsOperator($token)
  1517.     {
  1518.         return $token !== '...' && isset(self::$operator[$token[0]]);
  1519.     }
  1520.     private static function tokensToString(array $tokens)
  1521.     {
  1522.         $out = '';
  1523.         foreach ($tokens as $token)
  1524.         {
  1525.             if (is_string($token))
  1526.             {
  1527.                 $out .= $token;
  1528.             }
  1529.             elseif (is_array($token))
  1530.             {
  1531.                 $out .= $token[1];
  1532.             }
  1533.         }
  1534.         return $out;
  1535.     }
  1536.     private static function tokensTrim(array $tokens)
  1537.     {
  1538.         foreach ($tokens as $index => $token)
  1539.         {
  1540.             if (isset(self::$ignore[$token[0]]))
  1541.             {
  1542.                 unset($tokens[$index]);
  1543.             }
  1544.             else
  1545.             {
  1546.                 break;
  1547.             }
  1548.         }
  1549.         $tokens = array_reverse($tokens);
  1550.         foreach ($tokens as $index => $token)
  1551.         {
  1552.             if (isset(self::$ignore[$token[0]]))
  1553.             {
  1554.                 unset($tokens[$index]);
  1555.             }
  1556.             else
  1557.             {
  1558.                 break;
  1559.             }
  1560.         }
  1561.         return array_reverse($tokens);
  1562.     }
  1563.     private static function tokensFormatted(array $tokens)
  1564.     {
  1565.         $space = false;
  1566.         $tokens = self::tokensTrim($tokens);
  1567.         $output = array();
  1568.         $last = null;
  1569.         foreach ($tokens as $index => $token)
  1570.         {
  1571.             if (isset(self::$ignore[$token[0]]))
  1572.             {
  1573.                 if ($space)
  1574.                 {
  1575.                     continue;
  1576.                 }
  1577.                 $next = $tokens[self::realTokenIndex($tokens, $index, 1) ];
  1578.                 if (isset(self::$strip[$last[0]]) && !self::tokenIsOperator($next))
  1579.                 {
  1580.                     continue;
  1581.                 }
  1582.                 elseif (isset(self::$strip[$next[0]]) && $last && !self::tokenIsOperator($last))
  1583.                 {
  1584.                     continue;
  1585.                 }
  1586.                 $token = ' ';
  1587.                 $space = true;
  1588.             }
  1589.             else
  1590.             {
  1591.                 $space = false;
  1592.                 $last = $token;
  1593.             }
  1594.             $output[] = $token;
  1595.         }
  1596.         return $output;
  1597.     }
  1598. }
  1599. class Kint_Object_Blob extends Kint_Object
  1600. {
  1601.     public static $char_encodings = array(
  1602.         'ASCII',
  1603.         'UTF-8',
  1604.     );
  1605.     public $type = 'string';
  1606.     public $encoding = false;
  1607.     public $hints = array(
  1608.         'string'
  1609.     );
  1610.     public function getType()
  1611.     {
  1612.         if ($this->encoding === false)
  1613.         {
  1614.             return 'binary ' . $this->type;
  1615.         }
  1616.         elseif ($this->encoding === 'ASCII')
  1617.         {
  1618.             return $this->type;
  1619.         }
  1620.         else
  1621.         {
  1622.             return $this->encoding . ' ' . $this->type;
  1623.         }
  1624.     }
  1625.     public function getValueShort()
  1626.     {
  1627.         if ($rep = $this->value)
  1628.         {
  1629.             return '"' . $rep->contents . '"';
  1630.         }
  1631.     }
  1632.     public function transplant(Kint_Object $new)
  1633.     {
  1634.         $new = parent::transplant($new);
  1635.         $new->encoding = $this->encoding;
  1636.         return $new;
  1637.     }
  1638.     public static function strlen($string, $encoding = false)
  1639.     {
  1640.         if (extension_loaded('mbstring'))
  1641.         {
  1642.             if ($encoding === false)
  1643.             {
  1644.                 $encoding = self::detectEncoding($string);
  1645.             }
  1646.             if ($encoding && $encoding !== 'ASCII')
  1647.             {
  1648.                 return mb_strlen($string, $encoding);
  1649.             }
  1650.         }
  1651.         return strlen($string);
  1652.     }
  1653.     public static function substr($string, $start, $length = null, $encoding = false)
  1654.     {
  1655.         if (extension_loaded('mbstring'))
  1656.         {
  1657.             if ($encoding === false)
  1658.             {
  1659.                 $encoding = self::detectEncoding($string);
  1660.             }
  1661.             if ($encoding && $encoding !== 'ASCII')
  1662.             {
  1663.                 return mb_substr($string, $start, $length, $encoding);
  1664.             }
  1665.         }
  1666.         return substr($string, $start, isset($length) ? $length : PHP_INT_MAX);
  1667.     }
  1668.     public static function detectEncoding($string)
  1669.     {
  1670.         if (extension_loaded('mbstring'))
  1671.         {
  1672.             if ($ret = mb_detect_encoding($string, array_diff(self::$char_encodings, array(
  1673.                 'Windows-1252'
  1674.             )) , true))
  1675.             {
  1676.                 return $ret;
  1677.             }
  1678.             elseif (!in_array('Windows-1252', self::$char_encodings) || preg_match('/[\x00-\x08\x0B\x0C\x0E-\x1F\x81\x8D\x8F\x90\x9D]/', $string))
  1679.             {
  1680.                 return false;
  1681.             }
  1682.             else
  1683.             {
  1684.                 return 'Windows-1252';
  1685.             }
  1686.         }
  1687.         if (!extension_loaded('iconv'))
  1688.         {
  1689.             return 'UTF-8';
  1690.         }
  1691.         $md5 = md5($string);
  1692.         foreach (self::$char_encodings as $encoding)
  1693.         {
  1694.             if (md5(@iconv($encoding, $encoding, $string)) === $md5)
  1695.             {
  1696.                 return $encoding;
  1697.             }
  1698.         }
  1699.         return false;
  1700.     }
  1701.     public static function escape($string, $encoding = false)
  1702.     {
  1703.         static $show_dep = true;
  1704.         if ($show_dep)
  1705.         {
  1706.             trigger_error('Kint_Object_Blob::escape() is deprecated and will be removed in Kint 3.0. Use renderer-specific escape methods instead.', KINT_PHP53 ? E_USER_DEPRECATED : E_USER_NOTICE);
  1707.             $show_dep = false;
  1708.         }
  1709.         if (empty($string))
  1710.         {
  1711.             return $string;
  1712.         }
  1713.         if (Kint::$enabled_mode === Kint::MODE_TEXT)
  1714.         {
  1715.             return $string;
  1716.         }
  1717.         if (Kint::$enabled_mode === Kint::MODE_CLI)
  1718.         {
  1719.             return str_replace("\x1b", '\\x1b', $string);
  1720.         }
  1721.         if ($encoding === false)
  1722.         {
  1723.             $encoding = self::detectEncoding($string);
  1724.         }
  1725.         $original_encoding = $encoding;
  1726.         if ($encoding === false || $encoding === 'ASCII')
  1727.         {
  1728.             $encoding = 'UTF-8';
  1729.         }
  1730.         $string = htmlspecialchars($string, ENT_NOQUOTES, $encoding);
  1731.         if ($original_encoding !== 'ASCII' && function_exists('mb_encode_numericentity'))
  1732.         {
  1733.             $string = mb_encode_numericentity($string, array(
  1734.                 0x80,
  1735.                 0xffff,
  1736.                 0,
  1737.                 0xffff
  1738.             ) , $encoding);
  1739.         }
  1740.         return $string;
  1741.     }
  1742. }
  1743. class Kint_Object_Closure extends Kint_Object_Instance
  1744. {
  1745.     public $parameters = array();
  1746.     public $hints = array(
  1747.         'object',
  1748.         'callable',
  1749.         'closure'
  1750.     );
  1751.     private $paramcache = null;
  1752.     public function getAccessPath()
  1753.     {
  1754.         if ($this->access_path !== null)
  1755.         {
  1756.             return parent::getAccessPath() . '(' . $this->getParams() . ')';
  1757.         }
  1758.     }
  1759.     public function getSize()
  1760.     {
  1761.     }
  1762.     public function getParams()
  1763.     {
  1764.         if ($this->paramcache !== null)
  1765.         {
  1766.             return $this->paramcache;
  1767.         }
  1768.         $out = array();
  1769.         foreach ($this->parameters as $p)
  1770.         {
  1771.             $type = $p->getType();
  1772.             $ref = $p->reference ? '&' : '';
  1773.             if ($type)
  1774.             {
  1775.                 $out[] = $type . ' ' . $ref . $p->getName();
  1776.             }
  1777.             else
  1778.             {
  1779.                 $out[] = $ref . $p->getName();
  1780.             }
  1781.         }
  1782.         return $this->paramcache = implode(', ', $out);
  1783.     }
  1784. }
  1785. class Kint_Object_Color extends Kint_Object_Blob
  1786. {
  1787.     public static $color_map = array(
  1788.         'aliceblue' => 'f0f8ff',
  1789.         'antiquewhite' => 'faebd7',
  1790.         'aqua' => '00ffff',
  1791.         'aquamarine' => '7fffd4',
  1792.         'azure' => 'f0ffff',
  1793.         'beige' => 'f5f5dc',
  1794.         'bisque' => 'ffe4c4',
  1795.         'black' => '000000',
  1796.         'blanchedalmond' => 'ffebcd',
  1797.         'blue' => '0000ff',
  1798.         'blueviolet' => '8a2be2',
  1799.         'brown' => 'a52a2a',
  1800.         'burlywood' => 'deb887',
  1801.         'cadetblue' => '5f9ea0',
  1802.         'chartreuse' => '7fff00',
  1803.         'chocolate' => 'd2691e',
  1804.         'coral' => 'ff7f50',
  1805.         'cornflowerblue' => '6495ed',
  1806.         'cornsilk' => 'fff8dc',
  1807.         'crimson' => 'dc143c',
  1808.         'cyan' => '00ffff',
  1809.         'darkblue' => '00008b',
  1810.         'darkcyan' => '008b8b',
  1811.         'darkgoldenrod' => 'b8860b',
  1812.         'darkgray' => 'a9a9a9',
  1813.         'darkgreen' => '006400',
  1814.         'darkgrey' => 'a9a9a9',
  1815.         'darkkhaki' => 'bdb76b',
  1816.         'darkmagenta' => '8b008b',
  1817.         'darkolivegreen' => '556b2f',
  1818.         'darkorange' => 'ff8c00',
  1819.         'darkorchid' => '9932cc',
  1820.         'darkred' => '8b0000',
  1821.         'darksalmon' => 'e9967a',
  1822.         'darkseagreen' => '8fbc8f',
  1823.         'darkslateblue' => '483d8b',
  1824.         'darkslategray' => '2f4f4f',
  1825.         'darkslategrey' => '2f4f4f',
  1826.         'darkturquoise' => '00ced1',
  1827.         'darkviolet' => '9400d3',
  1828.         'deeppink' => 'ff1493',
  1829.         'deepskyblue' => '00bfff',
  1830.         'dimgray' => '696969',
  1831.         'dimgrey' => '696969',
  1832.         'dodgerblue' => '1e90ff',
  1833.         'firebrick' => 'b22222',
  1834.         'floralwhite' => 'fffaf0',
  1835.         'forestgreen' => '228b22',
  1836.         'fuchsia' => 'ff00ff',
  1837.         'gainsboro' => 'dcdcdc',
  1838.         'ghostwhite' => 'f8f8ff',
  1839.         'gold' => 'ffd700',
  1840.         'goldenrod' => 'daa520',
  1841.         'gray' => '808080',
  1842.         'green' => '008000',
  1843.         'greenyellow' => 'adff2f',
  1844.         'grey' => '808080',
  1845.         'honeydew' => 'f0fff0',
  1846.         'hotpink' => 'ff69b4',
  1847.         'indianred' => 'cd5c5c',
  1848.         'indigo' => '4b0082',
  1849.         'ivory' => 'fffff0',
  1850.         'khaki' => 'f0e68c',
  1851.         'lavender' => 'e6e6fa',
  1852.         'lavenderblush' => 'fff0f5',
  1853.         'lawngreen' => '7cfc00',
  1854.         'lemonchiffon' => 'fffacd',
  1855.         'lightblue' => 'add8e6',
  1856.         'lightcoral' => 'f08080',
  1857.         'lightcyan' => 'e0ffff',
  1858.         'lightgoldenrodyellow' => 'fafad2',
  1859.         'lightgray' => 'd3d3d3',
  1860.         'lightgreen' => '90ee90',
  1861.         'lightgrey' => 'd3d3d3',
  1862.         'lightpink' => 'ffb6c1',
  1863.         'lightsalmon' => 'ffa07a',
  1864.         'lightseagreen' => '20b2aa',
  1865.         'lightskyblue' => '87cefa',
  1866.         'lightslategray' => '778899',
  1867.         'lightslategrey' => '778899',
  1868.         'lightsteelblue' => 'b0c4de',
  1869.         'lightyellow' => 'ffffe0',
  1870.         'lime' => '00ff00',
  1871.         'limegreen' => '32cd32',
  1872.         'linen' => 'faf0e6',
  1873.         'magenta' => 'ff00ff',
  1874.         'maroon' => '800000',
  1875.         'mediumaquamarine' => '66cdaa',
  1876.         'mediumblue' => '0000cd',
  1877.         'mediumorchid' => 'ba55d3',
  1878.         'mediumpurple' => '9370db',
  1879.         'mediumseagreen' => '3cb371',
  1880.         'mediumslateblue' => '7b68ee',
  1881.         'mediumspringgreen' => '00fa9a',
  1882.         'mediumturquoise' => '48d1cc',
  1883.         'mediumvioletred' => 'c71585',
  1884.         'midnightblue' => '191970',
  1885.         'mintcream' => 'f5fffa',
  1886.         'mistyrose' => 'ffe4e1',
  1887.         'moccasin' => 'ffe4b5',
  1888.         'navajowhite' => 'ffdead',
  1889.         'navy' => '000080',
  1890.         'oldlace' => 'fdf5e6',
  1891.         'olive' => '808000',
  1892.         'olivedrab' => '6b8e23',
  1893.         'orange' => 'ffa500',
  1894.         'orangered' => 'ff4500',
  1895.         'orchid' => 'da70d6',
  1896.         'palegoldenrod' => 'eee8aa',
  1897.         'palegreen' => '98fb98',
  1898.         'paleturquoise' => 'afeeee',
  1899.         'palevioletred' => 'db7093',
  1900.         'papayawhip' => 'ffefd5',
  1901.         'peachpuff' => 'ffdab9',
  1902.         'peru' => 'cd853f',
  1903.         'pink' => 'ffc0cb',
  1904.         'plum' => 'dda0dd',
  1905.         'powderblue' => 'b0e0e6',
  1906.         'purple' => '800080',
  1907.         'rebeccapurple' => '663399',
  1908.         'red' => 'ff0000',
  1909.         'rosybrown' => 'bc8f8f',
  1910.         'royalblue' => '4169e1',
  1911.         'saddlebrown' => '8b4513',
  1912.         'salmon' => 'fa8072',
  1913.         'sandybrown' => 'f4a460',
  1914.         'seagreen' => '2e8b57',
  1915.         'seashell' => 'fff5ee',
  1916.         'sienna' => 'a0522d',
  1917.         'silver' => 'c0c0c0',
  1918.         'skyblue' => '87ceeb',
  1919.         'slateblue' => '6a5acd',
  1920.         'slategray' => '708090',
  1921.         'slategrey' => '708090',
  1922.         'snow' => 'fffafa',
  1923.         'springgreen' => '00ff7f',
  1924.         'steelblue' => '4682b4',
  1925.         'tan' => 'd2b48c',
  1926.         'teal' => '008080',
  1927.         'thistle' => 'd8bfd8',
  1928.         'tomato' => 'ff6347',
  1929.         'turquoise' => '40e0d0',
  1930.         'violet' => 'ee82ee',
  1931.         'wheat' => 'f5deb3',
  1932.         'white' => 'ffffff',
  1933.         'whitesmoke' => 'f5f5f5',
  1934.         'yellow' => 'ffff00',
  1935.         'yellowgreen' => '9acd32',
  1936.     );
  1937.     public $hints = array(
  1938.         'color'
  1939.     );
  1940.     public $color = null;
  1941.     public function __construct($color)
  1942.     {
  1943.         $this->color = $color;
  1944.     }
  1945.     public static function hslToRgb($hue, $saturation, $lightness)
  1946.     {
  1947.         $hue /= 360;
  1948.         $saturation /= 100;
  1949.         $lightness /= 100;
  1950.         $m2 = ($lightness <= 0.5) ? $lightness * ($saturation + 1) : $lightness + $saturation - $lightness * $saturation;
  1951.         $m1 = $lightness * 2 - $m2;
  1952.         $out = array(
  1953.             round(self::hueToRgb($m1, $m2, $hue + 1 / 3) * 255) ,
  1954.             round(self::hueToRgb($m1, $m2, $hue) * 255) ,
  1955.             round(self::hueToRgb($m1, $m2, $hue - 1 / 3) * 255) ,
  1956.         );
  1957.         if (max($out) > 255)
  1958.         {
  1959.             return;
  1960.         }
  1961.         else
  1962.         {
  1963.             return $out;
  1964.         }
  1965.     }
  1966.     private static function hueToRgb($m1, $m2, $hue)
  1967.     {
  1968.         $hue = ($hue < 0) ? $hue + 1 : (($hue > 1) ? $hue - 1 : $hue);
  1969.         if ($hue * 6 < 1)
  1970.         {
  1971.             return $m1 + ($m2 - $m1) * $hue * 6;
  1972.         }
  1973.         if ($hue * 2 < 1)
  1974.         {
  1975.             return $m2;
  1976.         }
  1977.         if ($hue * 3 < 2)
  1978.         {
  1979.             return $m1 + ($m2 - $m1) * (0.66666 - $hue) * 6;
  1980.         }
  1981.         return $m1;
  1982.     }
  1983.     public static function rgbToHsl($red, $green, $blue)
  1984.     {
  1985.         $clrMin = min($red, $green, $blue);
  1986.         $clrMax = max($red, $green, $blue);
  1987.         $deltaMax = $clrMax - $clrMin;
  1988.         $L = ($clrMax + $clrMin) / 510;
  1989.         if (0 == $deltaMax)
  1990.         {
  1991.             $H = 0;
  1992.             $S = 0;
  1993.         }
  1994.         else
  1995.         {
  1996.             if (0.5 > $L)
  1997.             {
  1998.                 $S = $deltaMax / ($clrMax + $clrMin);
  1999.             }
  2000.             else
  2001.             {
  2002.                 $S = $deltaMax / (510 - $clrMax - $clrMin);
  2003.             }
  2004.             if ($clrMax == $red)
  2005.             {
  2006.                 $H = ($green - $blue) / (6.0 * $deltaMax);
  2007.             }
  2008.             elseif ($clrMax == $green)
  2009.             {
  2010.                 $H = 1 / 3 + ($blue - $red) / (6.0 * $deltaMax);
  2011.             }
  2012.             else
  2013.             {
  2014.                 $H = 2 / 3 + ($red - $green) / (6.0 * $deltaMax);
  2015.             }
  2016.             if (0 > $H)
  2017.             {
  2018.                 $H += 1;
  2019.             }
  2020.             if (1 < $H)
  2021.             {
  2022.                 $H -= 1;
  2023.             }
  2024.         }
  2025.         return array(
  2026.             (round($H * 360) % 360 + 360) % 360,
  2027.             round($S * 100) ,
  2028.             round($L * 100) ,
  2029.         );
  2030.     }
  2031. }
  2032. class Kint_Object_DateTime extends Kint_Object_Instance
  2033. {
  2034.     public $dt;
  2035.     public $hints = array(
  2036.         'object',
  2037.         'datetime'
  2038.     );
  2039.     public function __construct(DateTime $dt)
  2040.     {
  2041.         $this->dt = clone $dt;
  2042.     }
  2043.     public function getValueShort()
  2044.     {
  2045.         $stamp = $this
  2046.             ->dt
  2047.             ->format('Y-m-d H:i:s');
  2048.         if (KINT_PHP522 && intval($micro = $this
  2049.             ->dt
  2050.             ->format('u')))
  2051.         {
  2052.             $stamp .= '.' . $micro;
  2053.         }
  2054.         $stamp .= $this
  2055.             ->dt
  2056.             ->format('P T');
  2057.         return $stamp;
  2058.     }
  2059. }
  2060. class Kint_Object_Instance extends Kint_Object
  2061. {
  2062.     public $type = 'object';
  2063.     public $classname;
  2064.     public $hash;
  2065.     public $filename;
  2066.     public $startline;
  2067.     public $hints = array(
  2068.         'object'
  2069.     );
  2070.     public static function sortByHierarchy($a, $b)
  2071.     {
  2072.         if (is_string($a) && is_string($b))
  2073.         {
  2074.             $aclass = $a;
  2075.             $bclass = $b;
  2076.         }
  2077.         elseif (!($a instanceof Kint_Object) || !($b instanceof Kint_Object))
  2078.         {
  2079.             return 0;
  2080.         }
  2081.         elseif ($a->type === 'object' && $b->type === 'object')
  2082.         {
  2083.             $aclass = $a->classname;
  2084.             $bclass = $b->classname;
  2085.         }
  2086.         if (is_subclass_of($aclass, $bclass))
  2087.         {
  2088.             return -1;
  2089.         }
  2090.         if (is_subclass_of($bclass, $aclass))
  2091.         {
  2092.             return 1;
  2093.         }
  2094.         return 0;
  2095.     }
  2096.     public function transplant(Kint_Object $new)
  2097.     {
  2098.         $new = parent::transplant($new);
  2099.         $new->classname = $this->classname;
  2100.         $new->hash = $this->hash;
  2101.         $new->filename = $this->filename;
  2102.         $new->startline = $this->startline;
  2103.         return $new;
  2104.     }
  2105.     public function getType()
  2106.     {
  2107.         return $this->classname;
  2108.     }
  2109. }
  2110. class Kint_Object_Method extends Kint_Object
  2111. {
  2112.     public $type = 'method';
  2113.     public $filename;
  2114.     public $startline;
  2115.     public $endline;
  2116.     public $parameters = array();
  2117.     public $abstract;
  2118.     public $final;
  2119.     public $internal;
  2120.     public $returntype = null;
  2121.     public $hints = array(
  2122.         'callable',
  2123.         'method'
  2124.     );
  2125.     public $showparams = true;
  2126.     private $paramcache = null;
  2127.     public function __construct($method)
  2128.     {
  2129.         if (!($method instanceof ReflectionMethod) && !($method instanceof ReflectionFunction))
  2130.         {
  2131.             throw new InvalidArgumentException('Argument must be an instance of ReflectionFunctionAbstract');
  2132.         }
  2133.         $this->name = $method->getName();
  2134.         $this->filename = $method->getFilename();
  2135.         $this->startline = $method->getStartLine();
  2136.         $this->endline = $method->getEndLine();
  2137.         $this->internal = $method->isInternal();
  2138.         $this->docstring = $method->getDocComment();
  2139.         foreach ($method->getParameters() as $param)
  2140.         {
  2141.             $this->parameters[] = new Kint_Object_Parameter($param);
  2142.         }
  2143.         if (KINT_PHP70)
  2144.         {
  2145.             $this->returntype = $method->getReturnType();
  2146.             if ($this->returntype)
  2147.             {
  2148.                 $this->returntype = (string)$this->returntype;
  2149.             }
  2150.         }
  2151.         if (!$this->returntype && $this->docstring)
  2152.         {
  2153.             if (preg_match('/@return\s+(.*)\r?\n/m', $this->docstring, $matches))
  2154.             {
  2155.                 if (!empty($matches[1]))
  2156.                 {
  2157.                     $this->returntype = $matches[1];
  2158.                 }
  2159.             }
  2160.         }
  2161.         if ($method instanceof ReflectionMethod)
  2162.         {
  2163.             $this->static = $method->isStatic();
  2164.             $this->operator = $this->static ? Kint_Object::OPERATOR_STATIC : Kint_Object::OPERATOR_OBJECT;
  2165.             $this->abstract = $method->isAbstract();
  2166.             $this->final = $method->isFinal();
  2167.             $this->owner_class = $method->getDeclaringClass()->name;
  2168.             $this->access = Kint_Object::ACCESS_PUBLIC;
  2169.             if ($method->isProtected())
  2170.             {
  2171.                 $this->access = Kint_Object::ACCESS_PROTECTED;
  2172.             }
  2173.             elseif ($method->isPrivate())
  2174.             {
  2175.                 $this->access = Kint_Object::ACCESS_PRIVATE;
  2176.             }
  2177.         }
  2178.         $docstring = new Kint_Object_Representation_Docstring($this->docstring, $this->filename, $this->startline);
  2179.         $docstring->implicit_label = true;
  2180.         $this->addRepresentation($docstring);
  2181.     }
  2182.     public function setAccessPathFrom(Kint_Object_Instance $parent)
  2183.     {
  2184.         static $magic = array(
  2185.             '__call' => true,
  2186.             '__callstatic' => true,
  2187.             '__clone' => true,
  2188.             '__construct' => true,
  2189.             '__debuginfo' => true,
  2190.             '__destruct' => true,
  2191.             '__get' => true,
  2192.             '__invoke' => true,
  2193.             '__isset' => true,
  2194.             '__set' => true,
  2195.             '__set_state' => true,
  2196.             '__sleep' => true,
  2197.             '__tostring' => true,
  2198.             '__unset' => true,
  2199.             '__wakeup' => true,
  2200.         );
  2201.         $name = strtolower($this->name);
  2202.         if ($name === '__construct')
  2203.         {
  2204.             if (KINT_PHP53)
  2205.             {
  2206.                 $this->access_path = 'new \\' . $parent->getType();
  2207.             }
  2208.             else
  2209.             {
  2210.                 $this->access_path = 'new ' . $parent->getType();
  2211.             }
  2212.         }
  2213.         elseif ($name === '__invoke')
  2214.         {
  2215.             $this->access_path = $parent->access_path;
  2216.         }
  2217.         elseif ($name === '__clone')
  2218.         {
  2219.             $this->access_path = 'clone ' . $parent->access_path;
  2220.             $this->showparams = false;
  2221.         }
  2222.         elseif ($name === '__tostring')
  2223.         {
  2224.             $this->access_path = '(string) ' . $parent->access_path;
  2225.             $this->showparams = false;
  2226.         }
  2227.         elseif (isset($magic[$name]))
  2228.         {
  2229.             $this->access_path = null;
  2230.         }
  2231.         elseif ($this->static)
  2232.         {
  2233.             if (KINT_PHP53)
  2234.             {
  2235.                 $this->access_path = '\\' . $this->owner_class . '::' . $this->name;
  2236.             }
  2237.             else
  2238.             {
  2239.                 $this->access_path = $this->owner_class . '::' . $this->name;
  2240.             }
  2241.         }
  2242.         else
  2243.         {
  2244.             $this->access_path = $parent->access_path . '->' . $this->name;
  2245.         }
  2246.     }
  2247.     public function getValueShort()
  2248.     {
  2249.         if (!$this->value || !($this->value instanceof Kint_Object_Representation_Docstring))
  2250.         {
  2251.             return parent::getValueShort();
  2252.         }
  2253.         $ds = explode("\n", $this
  2254.             ->value
  2255.             ->docstringWithoutComments());
  2256.         $out = '';
  2257.         foreach ($ds as $line)
  2258.         {
  2259.             if (strlen(trim($line)) === 0 || $line[0] === '@')
  2260.             {
  2261.                 break;
  2262.             }
  2263.             $out .= $line . ' ';
  2264.         }
  2265.         if (strlen($out))
  2266.         {
  2267.             return rtrim($out);
  2268.         }
  2269.     }
  2270.     public function getModifiers()
  2271.     {
  2272.         $mods = array(
  2273.             $this->abstract ? 'abstract' : null,
  2274.             $this->final ? 'final' : null,
  2275.             $this->getAccess() ,
  2276.             $this->static ? 'static' : null,
  2277.         );
  2278.         $out = '';
  2279.         foreach ($mods as $word)
  2280.         {
  2281.             if ($word !== null)
  2282.             {
  2283.                 $out .= $word . ' ';
  2284.             }
  2285.         }
  2286.         if (strlen($out))
  2287.         {
  2288.             return rtrim($out);
  2289.         }
  2290.     }
  2291.     public function getAccessPath()
  2292.     {
  2293.         if ($this->access_path !== null)
  2294.         {
  2295.             if ($this->showparams)
  2296.             {
  2297.                 return parent::getAccessPath() . '(' . $this->getParams() . ')';
  2298.             }
  2299.             else
  2300.             {
  2301.                 return parent::getAccessPath();
  2302.             }
  2303.         }
  2304.     }
  2305.     public function getParams()
  2306.     {
  2307.         if ($this->paramcache !== null)
  2308.         {
  2309.             return $this->paramcache;
  2310.         }
  2311.         $out = array();
  2312.         foreach ($this->parameters as $p)
  2313.         {
  2314.             $type = $p->getType();
  2315.             if ($type)
  2316.             {
  2317.                 $type .= ' ';
  2318.             }
  2319.             $default = $p->getDefault();
  2320.             if ($default)
  2321.             {
  2322.                 $default = ' = ' . $default;
  2323.             }
  2324.             $ref = $p->reference ? '&' : '';
  2325.             $out[] = $type . $ref . $p->getName() . $default;
  2326.         }
  2327.         return $this->paramcache = implode(', ', $out);
  2328.     }
  2329.     public function getPhpDocUrl()
  2330.     {
  2331.         if (!$this->internal)
  2332.         {
  2333.             return null;
  2334.         }
  2335.         if ($this->owner_class)
  2336.         {
  2337.             $class = strtolower($this->owner_class);
  2338.         }
  2339.         else
  2340.         {
  2341.             $class = 'function';
  2342.         }
  2343.         $funcname = str_replace('_', '-', strtolower($this->name));
  2344.         if (strpos($funcname, '--') === 0 && strpos($funcname, '-', 2) !== 0)
  2345.         {
  2346.             $funcname = substr($funcname, 2);
  2347.         }
  2348.         return 'https://secure.php.net/' . $class . '.' . $funcname;
  2349.     }
  2350. }
  2351. class Kint_Object_Nothing extends Kint_Object
  2352. {
  2353.     public $hints = array(
  2354.         'nothing'
  2355.     );
  2356. }
  2357. class Kint_Object_Parameter extends Kint_Object
  2358. {
  2359.     public $type_hint = null;
  2360.     public $default = null;
  2361.     public $position = null;
  2362.     public $hints = array(
  2363.         'parameter'
  2364.     );
  2365.     public function getType()
  2366.     {
  2367.         return $this->type_hint;
  2368.     }
  2369.     public function getName()
  2370.     {
  2371.         return '$' . $this->name;
  2372.     }
  2373.     public function __construct(ReflectionParameter $param)
  2374.     {
  2375.         if (method_exists('ReflectionParameter', 'getType'))
  2376.         {
  2377.             if ($type = $param->getType())
  2378.             {
  2379.                 $this->type_hint = (string)$type;
  2380.             }
  2381.         }
  2382.         else
  2383.         {
  2384.             if ($param->isArray())
  2385.             {
  2386.                 $this->type_hint = 'array';
  2387.             }
  2388.             else
  2389.             {
  2390.                 try
  2391.                 {
  2392.                     if ($this->type_hint = $param->getClass())
  2393.                     {
  2394.                         $this->type_hint = $this
  2395.                             ->type_hint->name;
  2396.                     }
  2397.                 }
  2398.                 catch(ReflectionException $e)
  2399.                 {
  2400.                     preg_match('/\[\s\<\w+?>\s([\w]+)/s', $param->__toString() , $matches);
  2401.                     $this->type_hint = isset($matches[1]) ? $matches[1] : '';
  2402.                 }
  2403.             }
  2404.         }
  2405.         $this->reference = $param->isPassedByReference();
  2406.         $this->name = $param->getName();
  2407.         if (KINT_PHP523)
  2408.         {
  2409.             $this->position = $param->getPosition();
  2410.         }
  2411.         if ($param->isDefaultValueAvailable())
  2412.         {
  2413.             $default = $param->getDefaultValue();
  2414.             switch (gettype($default))
  2415.             {
  2416.                 case 'NULL':
  2417.                     $this->default = 'null';
  2418.                 break;
  2419.                 case 'boolean':
  2420.                     $this->default = $default ? 'true' : 'false';
  2421.                 break;
  2422.                 case 'array':
  2423.                     $this->default = count($default) ? 'array(...)' : 'array()';
  2424.                 break;
  2425.                 default:
  2426.                     $this->default = var_export($default, true);
  2427.                 break;
  2428.             }
  2429.         }
  2430.     }
  2431.     public function getDefault()
  2432.     {
  2433.         return $this->default;
  2434.     }
  2435. }
  2436. class Kint_Object_Representation
  2437. {
  2438.     public $name;
  2439.     public $label;
  2440.     public $implicit_label = false;
  2441.     public $hints = array();
  2442.     public $contents = array();
  2443.     public function __construct($label, $name = null)
  2444.     {
  2445.         $this->label = $label;
  2446.         if ($name === null)
  2447.         {
  2448.             $name = preg_replace('/[^a-z0-9]+/', '_', strtolower($label));
  2449.         }
  2450.         $this->name = $name;
  2451.     }
  2452.     public function getLabel()
  2453.     {
  2454.         if (is_array($this->contents) && count($this->contents) > 1)
  2455.         {
  2456.             return $this->label . ' (' . count($this->contents) . ')';
  2457.         }
  2458.         else
  2459.         {
  2460.             return $this->label;
  2461.         }
  2462.     }
  2463.     public function labelIsImplicit()
  2464.     {
  2465.         return $this->implicit_label;
  2466.     }
  2467. }
  2468. class Kint_Object_Resource extends Kint_Object
  2469. {
  2470.     public $resource_type = null;
  2471.     public function getType()
  2472.     {
  2473.         if ($this->resource_type)
  2474.         {
  2475.             return $this->resource_type . ' resource';
  2476.         }
  2477.         else
  2478.         {
  2479.             return 'resource';
  2480.         }
  2481.     }
  2482.     public function transplant(Kint_Object $new)
  2483.     {
  2484.         $new = parent::transplant($new);
  2485.         $new->resource_type = $this->resource_type;
  2486.         return $new;
  2487.     }
  2488. }
  2489. class Kint_Object_Stream extends Kint_Object_Resource
  2490. {
  2491.     public $stream_meta = null;
  2492.     public function __construct(array $meta = null)
  2493.     {
  2494.         parent::__construct();
  2495.         $this->stream_meta = $meta;
  2496.     }
  2497.     public function getValueShort()
  2498.     {
  2499.         if (empty($this->stream_meta['uri']))
  2500.         {
  2501.             return;
  2502.         }
  2503.         $uri = $this->stream_meta['uri'];
  2504.         if (KINT_PHP524 && stream_is_local($uri))
  2505.         {
  2506.             return Kint::shortenPath($uri);
  2507.         }
  2508.         else
  2509.         {
  2510.             return $uri;
  2511.         }
  2512.     }
  2513. }
  2514. class Kint_Object_Throwable extends Kint_Object_Instance
  2515. {
  2516.     public $message;
  2517.     public $hints = array(
  2518.         'object',
  2519.         'throwable'
  2520.     );
  2521.     public function __construct($throw)
  2522.     {
  2523.         if (!$throw instanceof Exception && (!KINT_PHP70 || !$throw instanceof Throwable))
  2524.         {
  2525.             throw new InvalidArgumentException('Kint_Object_Throwable must be constructed with an Exception or a Throwable');
  2526.         }
  2527.         $this->message = $throw->getMessage();
  2528.     }
  2529.     public function getValueShort()
  2530.     {
  2531.         if (strlen($this->message))
  2532.         {
  2533.             return '"' . $this->message . '"';
  2534.         }
  2535.     }
  2536. }
  2537. class Kint_Object_Trace extends Kint_Object
  2538. {
  2539.     public $hints = array(
  2540.         'trace'
  2541.     );
  2542.     public function getType()
  2543.     {
  2544.         return 'Debug Backtrace';
  2545.     }
  2546.     public function getSize()
  2547.     {
  2548.         if (!$this->size)
  2549.         {
  2550.             return 'empty';
  2551.         }
  2552.         return parent::getSize();
  2553.     }
  2554. }
  2555. class Kint_Object_TraceFrame extends Kint_Object
  2556. {
  2557.     public $trace;
  2558.     public $hints = array(
  2559.         'trace_frame'
  2560.     );
  2561.     public function assignFrame(array & $frame)
  2562.     {
  2563.         $this->trace = array(
  2564.             'function' => isset($frame['function']) ? $frame['function'] : null,
  2565.             'line' => isset($frame['line']) ? $frame['line'] : null,
  2566.             'file' => isset($frame['file']) ? $frame['file'] : null,
  2567.             'class' => isset($frame['class']) ? $frame['class'] : null,
  2568.             'type' => isset($frame['type']) ? $frame['type'] : null,
  2569.             'object' => null,
  2570.             'args' => null,
  2571.         );
  2572.         if ($this->trace['class'] && method_exists($this->trace['class'], $this->trace['function']))
  2573.         {
  2574.             $func = new ReflectionMethod($this->trace['class'], $this->trace['function']);
  2575.             $this->trace['function'] = new Kint_Object_Method($func);
  2576.         }
  2577.         elseif (!$this->trace['class'] && function_exists($this->trace['function']))
  2578.         {
  2579.             $func = new ReflectionFunction($this->trace['function']);
  2580.             $this->trace['function'] = new Kint_Object_Method($func);
  2581.         }
  2582.         foreach ($this
  2583.             ->value->contents as $frame_prop)
  2584.         {
  2585.             if ($frame_prop->name === 'object')
  2586.             {
  2587.                 $this->trace['object'] = $frame_prop;
  2588.                 $this->trace['object']->name = null;
  2589.                 $this->trace['object']->operator = Kint_Object::OPERATOR_NONE;
  2590.             }
  2591.             if ($frame_prop->name === 'args')
  2592.             {
  2593.                 $this->trace['args'] = $frame_prop
  2594.                     ->value->contents;
  2595.                 if (is_object($this->trace['function']))
  2596.                 {
  2597.                     foreach (array_values($this->trace['function']
  2598.                         ->parameters) as $param)
  2599.                     {
  2600.                         if (isset($this->trace['args'][$param
  2601.                             ->position]))
  2602.                         {
  2603.                             $this->trace['args'][$param
  2604.                                 ->position]->name = $param->getName();
  2605.                         }
  2606.                     }
  2607.                 }
  2608.             }
  2609.         }
  2610.         $this->clearRepresentations();
  2611.         if (isset($this->trace['file'], $this->trace['line']) && is_readable($this->trace['file']))
  2612.         {
  2613.             $this->addRepresentation(new Kint_Object_Representation_Source($this->trace['file'], $this->trace['line']));
  2614.         }
  2615.         if ($this->trace['args'])
  2616.         {
  2617.             $args = new Kint_Object_Representation('Arguments');
  2618.             $args->contents = $this->trace['args'];
  2619.             $this->addRepresentation($args);
  2620.         }
  2621.         if ($this->trace['object'])
  2622.         {
  2623.             $callee = new Kint_Object_Representation('object');
  2624.             $callee->label = 'Callee object [' . $this->trace['object']->classname . ']';
  2625.             $callee->contents[] = $this->trace['object'];
  2626.             $this->addRepresentation($callee);
  2627.         }
  2628.     }
  2629. }
  2630. class Kint_Object_Representation_Color extends Kint_Object_Representation
  2631. {
  2632.     public $r = 0;
  2633.     public $g = 0;
  2634.     public $b = 0;
  2635.     public $a = 1;
  2636.     public $variant = null;
  2637.     public $implicit_label = true;
  2638.     public $hints = array(
  2639.         'color'
  2640.     );
  2641.     const COLOR_NAME = 1;
  2642.     const COLOR_HEX_3 = 2;
  2643.     const COLOR_HEX_6 = 3;
  2644.     const COLOR_RGB = 4;
  2645.     const COLOR_RGBA = 5;
  2646.     const COLOR_HSL = 6;
  2647.     const COLOR_HSLA = 7;
  2648.     const COLOR_HEX_4 = 8;
  2649.     const COLOR_HEX_8 = 9;
  2650.     public function getColor($variant = null)
  2651.     {
  2652.         switch ($variant)
  2653.         {
  2654.             case self::COLOR_NAME:
  2655.                 $hex = sprintf('%02x%02x%02x', $this->r, $this->g, $this->b);
  2656.                 return array_search($hex, Kint_Object_Color::$color_map);
  2657.             case self::COLOR_HEX_3:
  2658.                 if ($this->r % 0x11 === 0 && $this->g % 0x11 === 0 && $this->b % 0x11 === 0)
  2659.                 {
  2660.                     return sprintf('#%1X%1X%1X', round($this->r / 0x11) , round($this->g / 0x11) , round($this->b / 0x11));
  2661.                 }
  2662.                 else
  2663.                 {
  2664.                     return false;
  2665.                 }
  2666.             case self::COLOR_HEX_6:
  2667.                 return sprintf('#%02X%02X%02X', $this->r, $this->g, $this->b);
  2668.             case self::COLOR_RGB:
  2669.                 return sprintf('rgb(%d, %d, %d)', $this->r, $this->g, $this->b);
  2670.             case self::COLOR_RGBA:
  2671.                 return sprintf('rgba(%d, %d, %d, %s)', $this->r, $this->g, $this->b, round($this->a, 4));
  2672.             case self::COLOR_HSL:
  2673.                 $val = Kint_Object_Color::rgbToHsl($this->r, $this->g, $this->b);
  2674.                 return vsprintf('hsl(%d, %d%%, %d%%)', $val);
  2675.             case self::COLOR_HSLA:
  2676.                 $val = Kint_Object_Color::rgbToHsl($this->r, $this->g, $this->b);
  2677.                 return sprintf('hsla(%d, %d%%, %d%%, %s)', $val[0], $val[1], $val[2], round($this->a, 4));
  2678.             case self::COLOR_HEX_4:
  2679.                 if ($this->r % 0x11 === 0 && $this->g % 0x11 === 0 && $this->b % 0x11 === 0 && ($this->a * 255) % 0x11 === 0)
  2680.                 {
  2681.                     return sprintf('#%1X%1X%1X%1X', round($this->r / 0x11) , round($this->g / 0x11) , round($this->b / 0x11) , round($this->a * 0xF));
  2682.                 }
  2683.                 else
  2684.                 {
  2685.                     return false;
  2686.                 }
  2687.             case self::COLOR_HEX_8:
  2688.                 return sprintf('#%02X%02X%02X%02X', $this->r, $this->g, $this->b, round($this->a * 0xFF));
  2689.             case null:
  2690.                 return $this->contents;
  2691.         }
  2692.         return false;
  2693.     }
  2694.     public function __construct($value)
  2695.     {
  2696.         parent::__construct('Color');
  2697.         $this->contents = $value;
  2698.         $this->setValues($value);
  2699.     }
  2700.     public function hasAlpha($variant = null)
  2701.     {
  2702.         if ($variant === null)
  2703.         {
  2704.             $variant = $this->variant;
  2705.         }
  2706.         switch ($variant)
  2707.         {
  2708.             case self::COLOR_NAME:
  2709.                 return $this->a !== 1;
  2710.             case self::COLOR_RGBA:
  2711.             case self::COLOR_HSLA:
  2712.             case self::COLOR_HEX_4:
  2713.             case self::COLOR_HEX_8:
  2714.                 return true;
  2715.             default:
  2716.                 return false;
  2717.         }
  2718.     }
  2719.     protected function setValues($value)
  2720.     {
  2721.         $value = strtolower(trim($value));
  2722.         if (isset(Kint_Object_Color::$color_map[$value]))
  2723.         {
  2724.             $variant = self::COLOR_NAME;
  2725.         }
  2726.         elseif (substr($value, 0, 1) === '#')
  2727.         {
  2728.             $value = substr($value, 1);
  2729.             if (dechex(hexdec($value)) !== $value)
  2730.             {
  2731.                 return;
  2732.             }
  2733.             switch (strlen($value))
  2734.             {
  2735.                 case 3:
  2736.                     $variant = self::COLOR_HEX_3;
  2737.                 break;
  2738.                 case 6:
  2739.                     $variant = self::COLOR_HEX_6;
  2740.                 break;
  2741.                 case 4:
  2742.                     $variant = self::COLOR_HEX_4;
  2743.                 break;
  2744.                 case 8:
  2745.                     $variant = self::COLOR_HEX_8;
  2746.                 break;
  2747.             }
  2748.         }
  2749.         else
  2750.         {
  2751.             if (!preg_match('/^((?:rgb|hsl)a?)\s*\(([0-9\.%,\s]+)\)$/i', $value, $match))
  2752.             {
  2753.                 return;
  2754.             }
  2755.             switch ($match[1])
  2756.             {
  2757.                 case 'rgb':
  2758.                     $variant = self::COLOR_RGB;
  2759.                 break;
  2760.                 case 'rgba':
  2761.                     $variant = self::COLOR_RGBA;
  2762.                 break;
  2763.                 case 'hsl':
  2764.                     $variant = self::COLOR_HSL;
  2765.                 break;
  2766.                 case 'hsla':
  2767.                     $variant = self::COLOR_HSLA;
  2768.                 break;
  2769.             }
  2770.             $value = explode(',', $match[2]);
  2771.             if ($this->hasAlpha($variant))
  2772.             {
  2773.                 if (count($value) !== 4)
  2774.                 {
  2775.                     return;
  2776.                 }
  2777.             }
  2778.             elseif (count($value) !== 3)
  2779.             {
  2780.                 return;
  2781.             }
  2782.             foreach ($value as $i => & $color)
  2783.             {
  2784.                 $color = trim($color);
  2785.                 if (strpos($color, '%') !== false)
  2786.                 {
  2787.                     $color = str_replace('%', '', $color);
  2788.                     if ($i === 3)
  2789.                     {
  2790.                         $color = $color / 100;
  2791.                     }
  2792.                     elseif (in_array($variant, array(
  2793.                         self::COLOR_RGB,
  2794.                         self::COLOR_RGBA
  2795.                     )))
  2796.                     {
  2797.                         $color = round($color / 100 * 255);
  2798.                     }
  2799.                     elseif ($i === 0 && in_array($variant, array(
  2800.                         self::COLOR_HSL,
  2801.                         self::COLOR_HSLA
  2802.                     )))
  2803.                     {
  2804.                         $color = $color / 100 * 360;
  2805.                     }
  2806.                 }
  2807.                 if ($i === 0 && in_array($variant, array(
  2808.                     self::COLOR_HSL,
  2809.                     self::COLOR_HSLA
  2810.                 )))
  2811.                 {
  2812.                     $color = ($color % 360 + 360) % 360;
  2813.                 }
  2814.             }
  2815.         }
  2816.         switch ($variant)
  2817.         {
  2818.             case self::COLOR_HEX_4:
  2819.                 $this->a = hexdec($value[3]) / 0xF;
  2820.             case self::COLOR_HEX_3:
  2821.                 $this->r = hexdec($value[0]) * 0x11;
  2822.                 $this->g = hexdec($value[1]) * 0x11;
  2823.                 $this->b = hexdec($value[2]) * 0x11;
  2824.             break;
  2825.             case self::COLOR_NAME:
  2826.                 $value = Kint_Object_Color::$color_map[$value] . 'FF';
  2827.             case self::COLOR_HEX_8:
  2828.                 $this->a = hexdec(substr($value, 6, 2)) / 0xFF;
  2829.             case self::COLOR_HEX_6:
  2830.                 $value = str_split($value, 2);
  2831.                 $this->r = hexdec($value[0]);
  2832.                 $this->g = hexdec($value[1]);
  2833.                 $this->b = hexdec($value[2]);
  2834.             break;
  2835.             case self::COLOR_RGBA:
  2836.                 $this->a = $value[3];
  2837.             case self::COLOR_RGB:
  2838.                 list($this->r, $this->g, $this->b) = $value;
  2839.             break;
  2840.             case self::COLOR_HSLA:
  2841.                 $this->a = $value[3];
  2842.             case self::COLOR_HSL:
  2843.                 $value = Kint_Object_Color::hslToRgb($value[0], $value[1], $value[2]);
  2844.                 list($this->r, $this->g, $this->b) = $value;
  2845.             break;
  2846.         }
  2847.         if ($this->r > 0xFF || $this->g > 0xFF || $this->b > 0xFF || $this->a > 1)
  2848.         {
  2849.             $this->variant = null;
  2850.         }
  2851.         else
  2852.         {
  2853.             $this->variant = $variant;
  2854.         }
  2855.     }
  2856. }
  2857. class Kint_Object_Representation_Docstring extends Kint_Object_Representation
  2858. {
  2859.     public $file = null;
  2860.     public $line = null;
  2861.     public $class = null;
  2862.     public $hints = array(
  2863.         'docstring'
  2864.     );
  2865.     public function __construct($docstring, $file, $line, $class = null)
  2866.     {
  2867.         parent::__construct('Docstring');
  2868.         $this->file = $file;
  2869.         $this->line = $line;
  2870.         $this->class = $class;
  2871.         $this->contents = $docstring;
  2872.     }
  2873.     public function docstringWithoutComments()
  2874.     {
  2875.         if (!$this->contents)
  2876.         {
  2877.             return null;
  2878.         }
  2879.         $string = substr($this->contents, 3, -2);
  2880.         $string = preg_replace('/^\s*\*\s*?(\S|$)/m', '\1', $string);
  2881.         return trim($string);
  2882.     }
  2883. }
  2884. class Kint_Object_Representation_Microtime extends Kint_Object_Representation
  2885. {
  2886.     public $group = null;
  2887.     public $lap = null;
  2888.     public $total = null;
  2889.     public $avg = null;
  2890.     public $i = 0;
  2891.     public $mem = 0;
  2892.     public $mem_real = 0;
  2893.     public $mem_peak = null;
  2894.     public $mem_peak_real = null;
  2895.     public $hints = array(
  2896.         'microtime'
  2897.     );
  2898.     public function __construct($group, $lap = null, $total = null, $i = 0)
  2899.     {
  2900.         parent::__construct('Microtime');
  2901.         $this->group = $group;
  2902.         $this->lap = $lap;
  2903.         $this->total = $total;
  2904.         $this->i = $i;
  2905.         if ($i)
  2906.         {
  2907.             $this->avg = $total / $i;
  2908.         }
  2909.         $this->mem = memory_get_usage();
  2910.         $this->mem_real = memory_get_usage(true);
  2911.         if (KINT_PHP52)
  2912.         {
  2913.             $this->mem_peak = memory_get_peak_usage();
  2914.             $this->mem_peak_real = memory_get_peak_usage(true);
  2915.         }
  2916.     }
  2917. }
  2918. class Kint_Object_Representation_Source extends Kint_Object_Representation
  2919. {
  2920.     public $name = 'source';
  2921.     public $label = 'Source';
  2922.     public $hints = array(
  2923.         'source'
  2924.     );
  2925.     public $source = array();
  2926.     public $filename = null;
  2927.     public $line = 0;
  2928.     public function __construct($filename, $line, $padding = 7)
  2929.     {
  2930.         $this->filename = $filename;
  2931.         $this->line = $line;
  2932.         $start_line = max($line - $padding, 1);
  2933.         $length = $line + $padding + 1 - $start_line;
  2934.         $this->source = self::getSource($filename, $start_line, $length);
  2935.         if ($this->source !== false)
  2936.         {
  2937.             $this->contents = implode("\n", $this->source);
  2938.         }
  2939.     }
  2940.     public static function getSource($filename, $start_line = 1, $length = null)
  2941.     {
  2942.         if (!$filename or !is_readable($filename))
  2943.         {
  2944.             return false;
  2945.         }
  2946.         $source = preg_split("/\r\n|\n|\r/", file_get_contents($filename));
  2947.         $source = array_combine(range(1, count($source)) , $source);
  2948.         $source = array_slice($source, $start_line - 1, $length, true);
  2949.         return $source;
  2950.     }
  2951. }
  2952. class Kint_Object_Representation_SplFileInfo extends Kint_Object_Representation
  2953. {
  2954.     public $perms = null;
  2955.     public $flags = null;
  2956.     public $path = null;
  2957.     public $realpath = null;
  2958.     public $linktarget = null;
  2959.     public $size = null;
  2960.     public $is_dir = false;
  2961.     public $is_file = false;
  2962.     public $is_link = false;
  2963.     public $owner = null;
  2964.     public $group = null;
  2965.     public $ctime = null;
  2966.     public $mtime = null;
  2967.     public $typename = 'Unknown file';
  2968.     public $typeflag = '-';
  2969.     public $hints = array(
  2970.         'fspath'
  2971.     );
  2972.     public function __construct(SplFileInfo $fileInfo)
  2973.     {
  2974.         if (!file_exists($fileInfo->getPathname()))
  2975.         {
  2976.             return;
  2977.         }
  2978.         $this->perms = $fileInfo->getPerms();
  2979.         $this->size = $fileInfo->getSize();
  2980.         $this->is_dir = $fileInfo->isDir();
  2981.         $this->is_file = $fileInfo->isFile();
  2982.         $this->is_link = $fileInfo->isLink();
  2983.         $this->owner = $fileInfo->getOwner();
  2984.         $this->group = $fileInfo->getGroup();
  2985.         $this->ctime = $fileInfo->getCTime();
  2986.         $this->mtime = $fileInfo->getMTime();
  2987.         if (($this->perms & 0xC000) === 0xC000)
  2988.         {
  2989.             $this->typename = 'File socket';
  2990.             $this->typeflag = 's';
  2991.         }
  2992.         elseif ($this->is_file)
  2993.         {
  2994.             if ($this->is_link)
  2995.             {
  2996.                 $this->typename = 'File symlink';
  2997.                 $this->typeflag = 'l';
  2998.             }
  2999.             else
  3000.             {
  3001.                 $this->typename = 'File';
  3002.                 $this->typeflag = '-';
  3003.             }
  3004.         }
  3005.         elseif (($this->perms & 0x6000) === 0x6000)
  3006.         {
  3007.             $this->typename = 'Block special file';
  3008.             $this->typeflag = 'b';
  3009.         }
  3010.         elseif ($this->is_dir)
  3011.         {
  3012.             if ($this->is_link)
  3013.             {
  3014.                 $this->typename = 'Directory symlink';
  3015.                 $this->typeflag = 'l';
  3016.             }
  3017.             else
  3018.             {
  3019.                 $this->typename = 'Directory';
  3020.                 $this->typeflag = 'd';
  3021.             }
  3022.         }
  3023.         elseif (($this->perms & 0x2000) === 0x2000)
  3024.         {
  3025.             $this->typename = 'Character special file';
  3026.             $this->typeflag = 'c';
  3027.         }
  3028.         elseif (($this->perms & 0x1000) === 0x1000)
  3029.         {
  3030.             $this->typename = 'FIFO pipe file';
  3031.             $this->typeflag = 'p';
  3032.         }
  3033.         parent::__construct('SplFileInfo');
  3034.         $this->path = $fileInfo->getPathname();
  3035.         $this->realpath = realpath($this->path);
  3036.         if ($this->is_link && method_exists($fileInfo, 'getLinktarget'))
  3037.         {
  3038.             $this->linktarget = $fileInfo->getLinktarget();
  3039.         }
  3040.         $this->flags = array(
  3041.             $this->typeflag
  3042.         );
  3043.         $this->flags[] = (($this->perms & 0400) ? 'r' : '-');
  3044.         $this->flags[] = (($this->perms & 0200) ? 'w' : '-');
  3045.         $this->flags[] = (($this->perms & 0100) ? (($this->perms & 04000) ? 's' : 'x') : (($this->perms & 04000) ? 'S' : '-'));
  3046.         $this->flags[] = (($this->perms & 0040) ? 'r' : '-');
  3047.         $this->flags[] = (($this->perms & 0020) ? 'w' : '-');
  3048.         $this->flags[] = (($this->perms & 0010) ? (($this->perms & 02000) ? 's' : 'x') : (($this->perms & 02000) ? 'S' : '-'));
  3049.         $this->flags[] = (($this->perms & 0004) ? 'r' : '-');
  3050.         $this->flags[] = (($this->perms & 0002) ? 'w' : '-');
  3051.         $this->flags[] = (($this->perms & 0001) ? (($this->perms & 01000) ? 't' : 'x') : (($this->perms & 01000) ? 'T' : '-'));
  3052.         $this->contents = implode($this->flags) . ' ' . $this->owner . ' ' . $this->group . ' ' . $this->getSize() . ' ' . $this->getMTime() . ' ';
  3053.         if ($this->is_link && $this->linktarget)
  3054.         {
  3055.             $this->contents .= $this->path . ' -> ' . $this->linktarget;
  3056.         }
  3057.         elseif (strlen($this->realpath) < strlen($this->path))
  3058.         {
  3059.             $this->contents .= $this->realpath;
  3060.         }
  3061.         else
  3062.         {
  3063.             $this->contents .= $this->path;
  3064.         }
  3065.     }
  3066.     public function getLabel()
  3067.     {
  3068.         return $this->typename . ' (' . $this->getSize() . ')';
  3069.     }
  3070.     public function getSize()
  3071.     {
  3072.         static $unit = array(
  3073.             'B',
  3074.             'KB',
  3075.             'MB',
  3076.             'GB',
  3077.             'TB'
  3078.         );
  3079.         $size = $this->size;
  3080.         if ($this->size)
  3081.         {
  3082.             $i = floor(log($this->size, 1024));
  3083.             $size = round($this->size / pow(1024, $i) , 2) . $unit[$i];
  3084.         }
  3085.         return $size;
  3086.     }
  3087.     public function getMTime()
  3088.     {
  3089.         $year = date('Y', $this->mtime);
  3090.         if ($year !== date('Y'))
  3091.         {
  3092.             return date('M d Y', $this->mtime);
  3093.         }
  3094.         else
  3095.         {
  3096.             return date('M d H:i', $this->mtime);
  3097.         }
  3098.     }
  3099. }
  3100. class Kint_Parser_Base64 extends Kint_Parser_Plugin
  3101. {
  3102.     public static $min_length_hard = 16;
  3103.     public static $min_length_soft = 50;
  3104.     public function getTypes()
  3105.     {
  3106.         return array(
  3107.             'string'
  3108.         );
  3109.     }
  3110.     public function getTriggers()
  3111.     {
  3112.         return Kint_Parser::TRIGGER_SUCCESS;
  3113.     }
  3114.     public function parse(&$var, Kint_Object & $o, $trigger)
  3115.     {
  3116.         if (strlen($var) < self::$min_length_hard || !preg_match('%^(?:[A-Za-z0-9+/=]{4})+$%', $var))
  3117.         {
  3118.             return;
  3119.         }
  3120.         $data = base64_decode($var);
  3121.         if ($data === false)
  3122.         {
  3123.             return;
  3124.         }
  3125.         $base_obj = new Kint_Object();
  3126.         $base_obj->depth = $o->depth + 1;
  3127.         $base_obj->name = 'base64_decode(' . $o->name . ')';
  3128.         if ($o->access_path)
  3129.         {
  3130.             $base_obj->access_path = 'base64_decode(' . $o->access_path . ')';
  3131.         }
  3132.         $r = new Kint_Object_Representation('Base64');
  3133.         $r->contents = $this
  3134.             ->parser
  3135.             ->parse($data, $base_obj);
  3136.         if (strlen($var) > self::$min_length_soft)
  3137.         {
  3138.             $o->addRepresentation($r, 0);
  3139.         }
  3140.         else
  3141.         {
  3142.             $o->addRepresentation($r);
  3143.         }
  3144.     }
  3145. }
  3146. class Kint_Parser_Binary extends Kint_Parser_Plugin
  3147. {
  3148.     public function getTypes()
  3149.     {
  3150.         return array(
  3151.             'string'
  3152.         );
  3153.     }
  3154.     public function getTriggers()
  3155.     {
  3156.         return Kint_Parser::TRIGGER_SUCCESS;
  3157.     }
  3158.     public function parse(&$var, Kint_Object & $o, $trigger)
  3159.     {
  3160.         if (!$o instanceof Kint_Object_Blob || !in_array($o->encoding, array(
  3161.             'ASCII',
  3162.             'UTF-8'
  3163.         )))
  3164.         {
  3165.             $o
  3166.                 ->value
  3167.                 ->hints[] = 'binary';
  3168.         }
  3169.     }
  3170. }
  3171. class Kint_Parser_Blacklist extends Kint_Parser_Plugin
  3172. {
  3173.     public static $blacklist = array();
  3174.     public static $shallow_blacklist = array();
  3175.     public function getTypes()
  3176.     {
  3177.         return array(
  3178.             'object'
  3179.         );
  3180.     }
  3181.     public function getTriggers()
  3182.     {
  3183.         return Kint_Parser::TRIGGER_BEGIN;
  3184.     }
  3185.     public function parse(&$var, Kint_Object & $o, $trigger)
  3186.     {
  3187.         foreach (self::$blacklist as $class)
  3188.         {
  3189.             if ($var instanceof $class)
  3190.             {
  3191.                 return $this->blacklist($var, $o);
  3192.             }
  3193.         }
  3194.         if ($o->depth <= 0)
  3195.         {
  3196.             return;
  3197.         }
  3198.         foreach (self::$shallow_blacklist as $class)
  3199.         {
  3200.             if ($var instanceof $class)
  3201.             {
  3202.                 return $this->blacklist($var, $o);
  3203.             }
  3204.         }
  3205.     }
  3206.     protected function blacklist(&$var, &$o)
  3207.     {
  3208.         if (function_exists('spl_object_hash'))
  3209.         {
  3210.             $hash = spl_object_hash($var);
  3211.         }
  3212.         else
  3213.         {
  3214.             ob_start();
  3215.             var_dump($var);
  3216.             preg_match('/#(\d+)/', ob_get_clean() , $match);
  3217.             $hash = $match[1];
  3218.         }
  3219.         $object = $o->transplant(new Kint_Object_Instance());
  3220.         $object->classname = get_class($var);
  3221.         $object->hash = $hash;
  3222.         $object->clearRepresentations();
  3223.         $object->value = null;
  3224.         $object->size = null;
  3225.         $object->hints[] = 'blacklist';
  3226.         $o = $object;
  3227.         $this
  3228.             ->parser
  3229.             ->haltParse();
  3230.         return;
  3231.     }
  3232. }
  3233. class Kint_Parser_ClassMethods extends Kint_Parser_Plugin
  3234. {
  3235.     private static $cache = array();
  3236.     public function getTypes()
  3237.     {
  3238.         return array(
  3239.             'object'
  3240.         );
  3241.     }
  3242.     public function getTriggers()
  3243.     {
  3244.         return Kint_Parser::TRIGGER_SUCCESS;
  3245.     }
  3246.     public function parse(&$var, Kint_Object & $o, $trigger)
  3247.     {
  3248.         $class = get_class($var);
  3249.         if (!isset(self::$cache[$class]))
  3250.         {
  3251.             $methods = array();
  3252.             $reflection = new ReflectionClass($class);
  3253.             foreach ($reflection->getMethods() as $method)
  3254.             {
  3255.                 $methods[] = new Kint_Object_Method($method);
  3256.             }
  3257.             usort($methods, array(
  3258.                 'Kint_Parser_ClassMethods',
  3259.                 'sort'
  3260.             ));
  3261.             self::$cache[$class] = $methods;
  3262.         }
  3263.         if (!empty(self::$cache[$class]))
  3264.         {
  3265.             $rep = new Kint_Object_Representation('Available methods', 'methods');
  3266.             foreach (self::$cache[$class] as $m)
  3267.             {
  3268.                 $method = clone $m;
  3269.                 $method->depth = $o->depth + 1;
  3270.                 if (!$this
  3271.                     ->parser
  3272.                     ->childHasPath($o, $method))
  3273.                 {
  3274.                     $method->access_path = null;
  3275.                 }
  3276.                 else
  3277.                 {
  3278.                     $method->setAccessPathFrom($o);
  3279.                 }
  3280.                 if ($method->owner_class !== $class)
  3281.                 {
  3282.                     $ds = clone $method->getRepresentation('docstring');
  3283.                     $ds->class = $method->owner_class;
  3284.                     $method->replaceRepresentation($ds);
  3285.                 }
  3286.                 $rep->contents[] = $method;
  3287.             }
  3288.             $o->addRepresentation($rep);
  3289.         }
  3290.     }
  3291.     private static function sort(Kint_Object_Method $a, Kint_Object_Method $b)
  3292.     {
  3293.         $sort = ((int)$a->static) - ((int)$b->static);
  3294.         if ($sort)
  3295.         {
  3296.             return $sort;
  3297.         }
  3298.         $sort = Kint_Object::sortByAccess($a, $b);
  3299.         if ($sort)
  3300.         {
  3301.             return $sort;
  3302.         }
  3303.         $sort = Kint_Object_Instance::sortByHierarchy($a->owner_class, $b->owner_class);
  3304.         if ($sort)
  3305.         {
  3306.             return $sort;
  3307.         }
  3308.         return $a->startline - $b->startline;
  3309.     }
  3310. }
  3311. class Kint_Parser_ClassStatics extends Kint_Parser_Plugin
  3312. {
  3313.     private static $cache = array();
  3314.     public function getTypes()
  3315.     {
  3316.         return array(
  3317.             'object'
  3318.         );
  3319.     }
  3320.     public function getTriggers()
  3321.     {
  3322.         return Kint_Parser::TRIGGER_SUCCESS;
  3323.     }
  3324.     public function parse(&$var, Kint_Object & $o, $trigger)
  3325.     {
  3326.         $class = get_class($var);
  3327.         $reflection = new ReflectionClass($class);
  3328.         if (!isset(self::$cache[$class]))
  3329.         {
  3330.             $consts = array();
  3331.             foreach ($reflection->getConstants() as $name => $val)
  3332.             {
  3333.                 $const = Kint_Object::blank($name);
  3334.                 $const->const = true;
  3335.                 $const->depth = $o->depth + 1;
  3336.                 $const->owner_class = $class;
  3337.                 if (KINT_PHP53)
  3338.                 {
  3339.                     $const->access_path = '\\' . $class . '::' . $const->name;
  3340.                 }
  3341.                 else
  3342.                 {
  3343.                     $const->access_path = $class . '::' . $const->name;
  3344.                 }
  3345.                 $const->operator = Kint_Object::OPERATOR_STATIC;
  3346.                 $const = $this
  3347.                     ->parser
  3348.                     ->parse($val, $const);
  3349.                 $consts[] = $const;
  3350.             }
  3351.             self::$cache[$class] = $consts;
  3352.         }
  3353.         $statics = new Kint_Object_Representation('Static class properties', 'statics');
  3354.         $statics->contents = self::$cache[$class];
  3355.         if (!KINT_PHP53)
  3356.         {
  3357.             $static_map = $reflection->getStaticProperties();
  3358.         }
  3359.         foreach ($reflection->getProperties(ReflectionProperty::IS_STATIC) as $static)
  3360.         {
  3361.             $prop = new Kint_Object();
  3362.             $prop->name = '$' . $static->getName();
  3363.             $prop->depth = $o->depth + 1;
  3364.             $prop->static = true;
  3365.             $prop->operator = Kint_Object::OPERATOR_STATIC;
  3366.             if (KINT_PHP53)
  3367.             {
  3368.                 $prop->owner_class = $static->getDeclaringClass()->name;
  3369.             }
  3370.             else
  3371.             {
  3372.                 $prop->owner_class = $class;
  3373.             }
  3374.             $prop->access = Kint_Object::ACCESS_PUBLIC;
  3375.             if ($static->isProtected())
  3376.             {
  3377.                 $prop->access = Kint_Object::ACCESS_PROTECTED;
  3378.             }
  3379.             elseif ($static->isPrivate())
  3380.             {
  3381.                 $prop->access = Kint_Object::ACCESS_PRIVATE;
  3382.             }
  3383.             if ($this
  3384.                 ->parser
  3385.                 ->childHasPath($o, $prop))
  3386.             {
  3387.                 if (KINT_PHP53)
  3388.                 {
  3389.                     $prop->access_path = '\\' . $prop->owner_class . '::' . $prop->name;
  3390.                 }
  3391.                 else
  3392.                 {
  3393.                     $prop->access_path = $prop->owner_class . '::' . $prop->name;
  3394.                 }
  3395.             }
  3396.             if (KINT_PHP53)
  3397.             {
  3398.                 $static->setAccessible(true);
  3399.                 $val = $static->getValue();
  3400.             }
  3401.             else
  3402.             {
  3403.                 switch ($prop->access)
  3404.                 {
  3405.                     case Kint_Object::ACCESS_PUBLIC:
  3406.                         $val = $static_map[$static->getName() ];
  3407.                     break;
  3408.                     case Kint_Object::ACCESS_PROTECTED:
  3409.                         $val = $static_map["\0*\0" . $static->getName() ];
  3410.                     break;
  3411.                     case Kint_Object::ACCESS_PRIVATE:
  3412.                         $val = $static_map["\0" . $class . "\0" . $static->getName() ];
  3413.                     break;
  3414.                 }
  3415.             }
  3416.             $statics->contents[] = $this
  3417.                 ->parser
  3418.                 ->parse($val, $prop);
  3419.         }
  3420.         if (empty($statics->contents))
  3421.         {
  3422.             return;
  3423.         }
  3424.         usort($statics->contents, array(
  3425.             'Kint_Parser_ClassStatics',
  3426.             'sort'
  3427.         ));
  3428.         $o->addRepresentation($statics);
  3429.     }
  3430.     private static function sort(Kint_Object $a, Kint_Object $b)
  3431.     {
  3432.         $sort = ((int)$a->const) - ((int)$b->const);
  3433.         if ($sort)
  3434.         {
  3435.             return $sort;
  3436.         }
  3437.         $sort = Kint_Object::sortByAccess($a, $b);
  3438.         if ($sort)
  3439.         {
  3440.             return $sort;
  3441.         }
  3442.         return Kint_Object_Instance::sortByHierarchy($a->owner_class, $b->owner_class);
  3443.     }
  3444. }
  3445. class Kint_Parser_Closure extends Kint_Parser_Plugin
  3446. {
  3447.     public function getTypes()
  3448.     {
  3449.         if (KINT_PHP53)
  3450.         {
  3451.             return array(
  3452.                 'object'
  3453.             );
  3454.         }
  3455.         else
  3456.         {
  3457.             return array();
  3458.         }
  3459.     }
  3460.     public function getTriggers()
  3461.     {
  3462.         if (KINT_PHP53)
  3463.         {
  3464.             return Kint_Parser::TRIGGER_SUCCESS;
  3465.         }
  3466.         else
  3467.         {
  3468.             return Kint_Parser::TRIGGER_NONE;
  3469.         }
  3470.     }
  3471.     public function parse(&$var, Kint_Object & $o, $trigger)
  3472.     {
  3473.         if (!$var instanceof Closure)
  3474.         {
  3475.             return;
  3476.         }
  3477.         $o = $o->transplant(new Kint_Object_Closure());
  3478.         $o->removeRepresentation('properties');
  3479.         $closure = new ReflectionFunction($var);
  3480.         $o->filename = $closure->getFileName();
  3481.         $o->startline = $closure->getStartLine();
  3482.         foreach ($closure->getParameters() as $param)
  3483.         {
  3484.             $o->parameters[] = new Kint_Object_Parameter($param);
  3485.         }
  3486.         $p = new Kint_Object_Representation('Parameters');
  3487.         $p->contents = & $o->parameters;
  3488.         $o->addRepresentation($p, 0);
  3489.         $statics = array();
  3490.         if (method_exists($closure, 'getClosureThis') && $v = $closure->getClosureThis())
  3491.         {
  3492.             $statics = array(
  3493.                 'this' => $v
  3494.             );
  3495.         }
  3496.         if (count($statics = $statics + $closure->getStaticVariables()))
  3497.         {
  3498.             $statics_parsed = array();
  3499.             foreach ($statics as $name => & $static)
  3500.             {
  3501.                 $obj = Kint_Object::blank('$' . $name);
  3502.                 $obj->depth = $o->depth + 1;
  3503.                 $statics_parsed[$name] = $this
  3504.                     ->parser
  3505.                     ->parse($static, $obj);
  3506.                 if ($statics_parsed[$name]->value === null)
  3507.                 {
  3508.                     $statics_parsed[$name]->access_path = null;
  3509.                 }
  3510.             }
  3511.             $r = new Kint_Object_Representation('Uses');
  3512.             $r->contents = $statics_parsed;
  3513.             $o->addRepresentation($r, 0);
  3514.         }
  3515.     }
  3516. }
  3517. class Kint_Parser_Color extends Kint_Parser_Plugin
  3518. {
  3519.     public function getTypes()
  3520.     {
  3521.         return array(
  3522.             'string'
  3523.         );
  3524.     }
  3525.     public function getTriggers()
  3526.     {
  3527.         return Kint_Parser::TRIGGER_SUCCESS;
  3528.     }
  3529.     public function parse(&$var, Kint_Object & $o, $trigger)
  3530.     {
  3531.         if (strlen($var) > 32)
  3532.         {
  3533.             return;
  3534.         }
  3535.         $trimmed = strtolower(trim($var));
  3536.         if (!isset(Kint_Object_Color::$color_map[$trimmed]) && !preg_match('/^(?:(?:rgb|hsl)[^\)]{6,}\)|#[0-9a-fA-F]{3,8})$/', $trimmed))
  3537.         {
  3538.             return;
  3539.         }
  3540.         $rep = new Kint_Object_Representation_Color($var);
  3541.         if ($rep->variant)
  3542.         {
  3543.             $o = $o->transplant(new Kint_Object_Color($rep));
  3544.             $o->removeRepresentation($o
  3545.                 ->value
  3546.                 ->name);
  3547.             $o->addRepresentation($rep, 0);
  3548.         }
  3549.     }
  3550. }
  3551. class Kint_Parser_DOMIterator extends Kint_Parser_Plugin
  3552. {
  3553.     public function getTypes()
  3554.     {
  3555.         return array(
  3556.             'object'
  3557.         );
  3558.     }
  3559.     public function getTriggers()
  3560.     {
  3561.         return Kint_Parser::TRIGGER_COMPLETE & ~Kint_Parser::TRIGGER_RECURSION;
  3562.     }
  3563.     public function parse(&$var, Kint_Object & $o, $trigger)
  3564.     {
  3565.         if (!($var instanceof DOMNamedNodeMap || $var instanceof DOMNodeList))
  3566.         {
  3567.             return;
  3568.         }
  3569.         $o->size = $var->length;
  3570.         if ($o->size === 0)
  3571.         {
  3572.             $o->replaceRepresentation(new Kint_Object_Representation('Iterator'));
  3573.             $o->size = null;
  3574.             return;
  3575.         }
  3576.         if ($this
  3577.             ->parser->max_depth && $o->depth + 1 >= $this
  3578.             ->parser
  3579.             ->max_depth)
  3580.         {
  3581.             $b = new Kint_Object();
  3582.             $b->name = $o->classname . ' Iterator Contents';
  3583.             $b->access_path = 'iterator_to_array(' . $o->access_path . ')';
  3584.             $b->depth = $o->depth + 1;
  3585.             $b->hints[] = 'depth_limit';
  3586.             $r = new Kint_Object_Representation('Iterator');
  3587.             $r->contents = array(
  3588.                 $b
  3589.             );
  3590.             $o->replaceRepresentation($r, 0);
  3591.             return;
  3592.         }
  3593.         if (!$var instanceof Traversable)
  3594.         {
  3595.             $data = array();
  3596.             foreach ($var as $item)
  3597.             {
  3598.                 $data[] = $item;
  3599.             }
  3600.         }
  3601.         else
  3602.         {
  3603.             $data = iterator_to_array($var);
  3604.         }
  3605.         $r = new Kint_Object_Representation('Iterator');
  3606.         $o->replaceRepresentation($r, 0);
  3607.         foreach ($data as $key => $item)
  3608.         {
  3609.             $base_obj = new Kint_Object();
  3610.             $base_obj->depth = $o->depth + 1;
  3611.             $base_obj->name = $item->nodeName;
  3612.             if ($o->access_path)
  3613.             {
  3614.                 if ($var instanceof DOMNamedNodeMap)
  3615.                 {
  3616.                     $base_obj->access_path = $o->access_path . '->getNamedItem(' . var_export($key, true) . ')';
  3617.                 }
  3618.                 elseif ($var instanceof DOMNodeList)
  3619.                 {
  3620.                     $base_obj->access_path = $o->access_path . '->item(' . var_export($key, true) . ')';
  3621.                 }
  3622.                 else
  3623.                 {
  3624.                     $base_obj->access_path = 'iterator_to_array(' . $o->access_path . ')';
  3625.                 }
  3626.             }
  3627.             $r->contents[] = $this
  3628.                 ->parser
  3629.                 ->parse($item, $base_obj);
  3630.         }
  3631.     }
  3632. }
  3633. class Kint_Parser_DOMNode extends Kint_Parser_Plugin
  3634. {
  3635.     public static $blacklist = array(
  3636.         'parentNode' => 'DOMNode',
  3637.         'firstChild' => 'DOMNode',
  3638.         'lastChild' => 'DOMNode',
  3639.         'previousSibling' => 'DOMNode',
  3640.         'nextSibling' => 'DOMNode',
  3641.         'ownerDocument' => 'DOMDocument',
  3642.     );
  3643.     public static $verbose = false;
  3644.     public function getTypes()
  3645.     {
  3646.         return array(
  3647.             'object'
  3648.         );
  3649.     }
  3650.     public function getTriggers()
  3651.     {
  3652.         return Kint_Parser::TRIGGER_SUCCESS;
  3653.     }
  3654.     public function parse(&$var, Kint_Object & $o, $trigger)
  3655.     {
  3656.         if (!$var instanceof DOMNode)
  3657.         {
  3658.             return;
  3659.         }
  3660.         $known_properties = array(
  3661.             'nodeValue',
  3662.             'childNodes',
  3663.             'attributes',
  3664.         );
  3665.         if (self::$verbose)
  3666.         {
  3667.             $known_properties = array(
  3668.                 'nodeName',
  3669.                 'nodeValue',
  3670.                 'nodeType',
  3671.                 'parentNode',
  3672.                 'childNodes',
  3673.                 'firstChild',
  3674.                 'lastChild',
  3675.                 'previousSibling',
  3676.                 'nextSibling',
  3677.                 'attributes',
  3678.                 'ownerDocument',
  3679.                 'namespaceURI',
  3680.                 'prefix',
  3681.                 'localName',
  3682.                 'baseURI',
  3683.                 'textContent',
  3684.             );
  3685.         }
  3686.         $childNodes = array();
  3687.         $attributes = array();
  3688.         $rep = $o->value;
  3689.         foreach ($known_properties as $prop)
  3690.         {
  3691.             $prop_obj = $this->parseProperty($o, $prop, $var);
  3692.             $rep->contents[] = $prop_obj;
  3693.             if ($prop === 'childNodes')
  3694.             {
  3695.                 $childNodes = $prop_obj->getRepresentation('iterator');
  3696.             }
  3697.             elseif ($prop === 'attributes')
  3698.             {
  3699.                 $attributes = $prop_obj->getRepresentation('iterator');
  3700.             }
  3701.         }
  3702.         if (!self::$verbose)
  3703.         {
  3704.             $o->removeRepresentation('methods');
  3705.             $o->removeRepresentation('properties');
  3706.         }
  3707.         if (in_array($o->classname, array(
  3708.             'DOMAttr',
  3709.             'DOMText',
  3710.             'DOMComment'
  3711.         )))
  3712.         {
  3713.             return;
  3714.         }
  3715.         if ($attributes)
  3716.         {
  3717.             $a = new Kint_Object_Representation('Attributes');
  3718.             foreach ($attributes->contents as $attribute)
  3719.             {
  3720.                 $a->contents[] = self::textualNodeToString($attribute);
  3721.             }
  3722.             $o->addRepresentation($a, 0);
  3723.         }
  3724.         if ($childNodes)
  3725.         {
  3726.             $c = new Kint_Object_Representation('Children');
  3727.             if (count($childNodes->contents) === 1 && ($node = reset($childNodes->contents)) && in_array('depth_limit', $node->hints))
  3728.             {
  3729.                 $node = $node->transplant(new Kint_Object_Instance());
  3730.                 $node->name = 'childNodes';
  3731.                 $node->classname = 'DOMNodeList';
  3732.                 $c->contents = array(
  3733.                     $node
  3734.                 );
  3735.             }
  3736.             else
  3737.             {
  3738.                 foreach ($childNodes->contents as $index => $node)
  3739.                 {
  3740.                     if ($node->classname === 'DOMText' || $node->classname === 'DOMComment')
  3741.                     {
  3742.                         $node = self::textualNodeToString($node);
  3743.                         if (ctype_space($node
  3744.                             ->value
  3745.                             ->contents) || $node
  3746.                             ->value->contents === '')
  3747.                         {
  3748.                             continue;
  3749.                         }
  3750.                     }
  3751.                     $c->contents[] = $node;
  3752.                 }
  3753.             }
  3754.             $o->addRepresentation($c, 0);
  3755.         }
  3756.         if (isset($c) && count($c->contents))
  3757.         {
  3758.             $o->size = count($c->contents);
  3759.         }
  3760.         if (!$o->size)
  3761.         {
  3762.             $o->size = null;
  3763.         }
  3764.     }
  3765.     protected function parseProperty(Kint_Object $o, $prop, &$var)
  3766.     {
  3767.         $base_obj = new Kint_Object();
  3768.         $base_obj->depth = $o->depth + 1;
  3769.         $base_obj->owner_class = $o->classname;
  3770.         $base_obj->name = $prop;
  3771.         $base_obj->operator = Kint_Object::OPERATOR_OBJECT;
  3772.         $base_obj->access = Kint_Object::ACCESS_PUBLIC;
  3773.         if ($o->access_path !== null)
  3774.         {
  3775.             $base_obj->access_path = $o->access_path;
  3776.             if (preg_match('/^[A-Za-z0-9_]+$/', $base_obj->name))
  3777.             {
  3778.                 $base_obj->access_path .= '->' . $base_obj->name;
  3779.             }
  3780.             else
  3781.             {
  3782.                 $base_obj->access_path .= '->{' . var_export($base_obj->name, true) . '}';
  3783.             }
  3784.         }
  3785.         if (!isset($var->$prop))
  3786.         {
  3787.             $base_obj->type = 'null';
  3788.         }
  3789.         elseif (isset(self::$blacklist[$prop]))
  3790.         {
  3791.             $base_obj = $base_obj->transplant(new Kint_Object_Instance());
  3792.             $base_obj->hints[] = 'blacklist';
  3793.             $base_obj->classname = self::$blacklist[$prop];
  3794.         }
  3795.         elseif ($prop === 'attributes')
  3796.         {
  3797.             $depth_stash = $this
  3798.                 ->parser->max_depth;
  3799.             $this
  3800.                 ->parser->max_depth = 0;
  3801.             $base_obj = $this
  3802.                 ->parser
  3803.                 ->parse($var->$prop, $base_obj);
  3804.             $this
  3805.                 ->parser->max_depth = $depth_stash;
  3806.         }
  3807.         else
  3808.         {
  3809.             $base_obj = $this
  3810.                 ->parser
  3811.                 ->parse($var->$prop, $base_obj);
  3812.         }
  3813.         return $base_obj;
  3814.     }
  3815.     protected static function textualNodeToString(Kint_Object_Instance $o)
  3816.     {
  3817.         if (empty($o->value) || empty($o
  3818.             ->value
  3819.             ->contents) || empty($o->classname))
  3820.         {
  3821.             return;
  3822.         }
  3823.         if (!in_array($o->classname, array(
  3824.             'DOMText',
  3825.             'DOMAttr',
  3826.             'DOMComment'
  3827.         )))
  3828.         {
  3829.             return;
  3830.         }
  3831.         foreach ($o
  3832.             ->value->contents as $property)
  3833.         {
  3834.             if ($property->name === 'nodeValue')
  3835.             {
  3836.                 $ret = clone $property;
  3837.                 $ret->name = $o->name;
  3838.                 return $ret;
  3839.             }
  3840.         }
  3841.     }
  3842. }
  3843. class Kint_Parser_DateTime extends Kint_Parser_Plugin
  3844. {
  3845.     public function getTypes()
  3846.     {
  3847.         if (KINT_PHP53)
  3848.         {
  3849.             return array(
  3850.                 'object'
  3851.             );
  3852.         }
  3853.         else
  3854.         {
  3855.             return array();
  3856.         }
  3857.     }
  3858.     public function getTriggers()
  3859.     {
  3860.         if (KINT_PHP53)
  3861.         {
  3862.             return Kint_Parser::TRIGGER_SUCCESS;
  3863.         }
  3864.         else
  3865.         {
  3866.             return Kint_Parser::TRIGGER_NONE;
  3867.         }
  3868.     }
  3869.     public function parse(&$var, Kint_Object & $o, $trigger)
  3870.     {
  3871.         if (!$var instanceof DateTime)
  3872.         {
  3873.             return;
  3874.         }
  3875.         $o = $o->transplant(new Kint_Object_DateTime($var));
  3876.     }
  3877. }
  3878. class Kint_Parser_FsPath extends Kint_Parser_Plugin
  3879. {
  3880.     public static $blacklist = array(
  3881.         '/',
  3882.         '.'
  3883.     );
  3884.     public function getTypes()
  3885.     {
  3886.         return array(
  3887.             'string'
  3888.         );
  3889.     }
  3890.     public function getTriggers()
  3891.     {
  3892.         return Kint_Parser::TRIGGER_SUCCESS;
  3893.     }
  3894.     public function parse(&$var, Kint_Object & $o, $trigger)
  3895.     {
  3896.         if (strlen($var) > 2048 || preg_match('/[:?<>"*|]/', $var) || !preg_match('/[\\/\\.\\' . DIRECTORY_SEPARATOR . ']/', $var) || !@file_exists($var) || in_array($var, self::$blacklist))
  3897.         {
  3898.             return;
  3899.         }
  3900.         $r = new Kint_Object_Representation_SplFileInfo(new SplFileInfo($var));
  3901.         $r->hints[] = 'fspath';
  3902.         $o->addRepresentation($r, 0);
  3903.     }
  3904. }
  3905. class Kint_Parser_Iterator extends Kint_Parser_Plugin
  3906. {
  3907.     public static $blacklist = array(
  3908.         'PDOStatement',
  3909.         'DOMNodeList',
  3910.         'DOMNamedNodeMap',
  3911.     );
  3912.     public function getTypes()
  3913.     {
  3914.         return array(
  3915.             'object'
  3916.         );
  3917.     }
  3918.     public function getTriggers()
  3919.     {
  3920.         return Kint_Parser::TRIGGER_SUCCESS;
  3921.     }
  3922.     public function parse(&$var, Kint_Object & $o, $trigger)
  3923.     {
  3924.         if (!$var instanceof Traversable)
  3925.         {
  3926.             return;
  3927.         }
  3928.         foreach (self::$blacklist as $class)
  3929.         {
  3930.             if ($var instanceof $class)
  3931.             {
  3932.                 $b = new Kint_Object();
  3933.                 $b->name = $class . ' Iterator Contents';
  3934.                 $b->access_path = 'iterator_to_array(' . $o->access_path . ', true)';
  3935.                 $b->depth = $o->depth + 1;
  3936.                 $b->hints[] = 'blacklist';
  3937.                 $r = new Kint_Object_Representation('Iterator');
  3938.                 $r->contents = array(
  3939.                     $b
  3940.                 );
  3941.                 $o->addRepresentation($r);
  3942.                 return;
  3943.             }
  3944.         }
  3945.         $data = iterator_to_array($var);
  3946.         if ($data === false)
  3947.         {
  3948.             return;
  3949.         }
  3950.         $base_obj = new Kint_Object();
  3951.         $base_obj->depth = $o->depth;
  3952.         if ($o->access_path)
  3953.         {
  3954.             $base_obj->access_path = 'iterator_to_array(' . $o->access_path . ')';
  3955.         }
  3956.         $r = new Kint_Object_Representation('Iterator');
  3957.         $r->contents = $this
  3958.             ->parser
  3959.             ->parse($data, $base_obj);
  3960.         $r->contents = $r
  3961.             ->contents
  3962.             ->value->contents;
  3963.         $primary = reset($o->representations);
  3964.         if ($primary && $primary === $o->value && $primary->contents === array())
  3965.         {
  3966.             $o->addRepresentation($r, 0);
  3967.         }
  3968.         else
  3969.         {
  3970.             $o->addRepresentation($r);
  3971.         }
  3972.     }
  3973. }
  3974. class Kint_Parser_Json extends Kint_Parser_Plugin
  3975. {
  3976.     public function getTypes()
  3977.     {
  3978.         if (KINT_PHP52)
  3979.         {
  3980.             return array(
  3981.                 'string'
  3982.             );
  3983.         }
  3984.         else
  3985.         {
  3986.             return array();
  3987.         }
  3988.     }
  3989.     public function getTriggers()
  3990.     {
  3991.         if (KINT_PHP52)
  3992.         {
  3993.             return Kint_Parser::TRIGGER_SUCCESS;
  3994.         }
  3995.         else
  3996.         {
  3997.             return Kint_Parser::TRIGGER_NONE;
  3998.         }
  3999.     }
  4000.     public function parse(&$var, Kint_Object & $o, $trigger)
  4001.     {
  4002.         if (!isset($var[0]) || ($var[0] !== '{' && $var[0] !== '[') || ($json = json_decode($var, true)) === null)
  4003.         {
  4004.             return;
  4005.         }
  4006.         $json = (array)$json;
  4007.         if (empty($json))
  4008.         {
  4009.             return;
  4010.         }
  4011.         $base_obj = new Kint_Object();
  4012.         $base_obj->depth = $o->depth;
  4013.         if ($o->access_path)
  4014.         {
  4015.             $base_obj->access_path = 'json_decode(' . $o->access_path . ', true)';
  4016.         }
  4017.         $r = new Kint_Object_Representation('Json');
  4018.         $r->contents = $this
  4019.             ->parser
  4020.             ->parse($json, $base_obj);
  4021.         if (!in_array('depth_limit', $r
  4022.             ->contents
  4023.             ->hints))
  4024.         {
  4025.             $r->contents = $r
  4026.                 ->contents
  4027.                 ->value->contents;
  4028.         }
  4029.         $o->addRepresentation($r, 0);
  4030.     }
  4031. }
  4032. class Kint_Parser_Microtime extends Kint_Parser_Plugin
  4033. {
  4034.     private static $last = null;
  4035.     private static $start = null;
  4036.     private static $times = 0;
  4037.     private static $group = 0;
  4038.     public function getTypes()
  4039.     {
  4040.         return array(
  4041.             'string'
  4042.         );
  4043.     }
  4044.     public function getTriggers()
  4045.     {
  4046.         return Kint_Parser::TRIGGER_SUCCESS;
  4047.     }
  4048.     public function parse(&$var, Kint_Object & $o, $trigger)
  4049.     {
  4050.         if (!preg_match('/0\.[0-9]{8} [0-9]{10}/', $var))
  4051.         {
  4052.             return;
  4053.         }
  4054.         if ($o->name !== 'microtime()' || $o->depth !== 0)
  4055.         {
  4056.             return;
  4057.         }
  4058.         list($usec, $sec) = explode(' ', $var);
  4059.         $time = (float)$usec + (float)$sec;
  4060.         if (self::$last !== null)
  4061.         {
  4062.             $last_time = array_sum(array_map('floatval', explode(' ', self::$last)));
  4063.             $lap = $time - $last_time;
  4064.             ++self::$times;
  4065.         }
  4066.         else
  4067.         {
  4068.             $lap = null;
  4069.             self::$start = $time;
  4070.         }
  4071.         self::$last = $var;
  4072.         if ($lap !== null)
  4073.         {
  4074.             $total = $time - self::$start;
  4075.             $r = new Kint_Object_Representation_Microtime(self::$group, $lap, $total, self::$times);
  4076.         }
  4077.         else
  4078.         {
  4079.             $r = new Kint_Object_Representation_Microtime(self::$group);
  4080.         }
  4081.         $r->contents = $var;
  4082.         $r->implicit_label = true;
  4083.         $o->removeRepresentation($o
  4084.             ->value
  4085.             ->name);
  4086.         $o->addRepresentation($r);
  4087.     }
  4088.     public static function clean()
  4089.     {
  4090.         self::$last = null;
  4091.         self::$start = null;
  4092.         self::$times = 0;
  4093.         ++self::$group;
  4094.     }
  4095. }
  4096. abstract class Kint_Parser_Plugin
  4097. {
  4098.     protected $parser;
  4099.     public function setParser(Kint_Parser $p)
  4100.     {
  4101.         $this->parser = $p;
  4102.     }
  4103.     public function getTypes()
  4104.     {
  4105.         return array();
  4106.     }
  4107.     public function getTriggers()
  4108.     {
  4109.         return Kint_Parser::TRIGGER_NONE;
  4110.     }
  4111.     abstract public function parse(&$variable, Kint_Object & $o, $trigger);
  4112. }
  4113. class Kint_Parser_Serialize extends Kint_Parser_Plugin
  4114. {
  4115.     public static $safe_mode = true;
  4116.     public static $options = array(
  4117.         true
  4118.     );
  4119.     public function getTypes()
  4120.     {
  4121.         return array(
  4122.             'string'
  4123.         );
  4124.     }
  4125.     public function getTriggers()
  4126.     {
  4127.         return Kint_Parser::TRIGGER_SUCCESS;
  4128.     }
  4129.     public function parse(&$var, Kint_Object & $o, $trigger)
  4130.     {
  4131.         $trimmed = rtrim($var);
  4132.         if ($trimmed !== 'N;' && !preg_match('/^(?:[COabis]:\d+[:;]|d:\d+(?:\.\d+);)/', $trimmed))
  4133.         {
  4134.             return;
  4135.         }
  4136.         if (!self::$safe_mode || !in_array($trimmed[0], array(
  4137.             'C',
  4138.             'O',
  4139.             'a'
  4140.         )))
  4141.         {
  4142.             $blacklist = false;
  4143.             if (KINT_PHP70)
  4144.             {
  4145.                 $data = @unserialize($trimmed, self::$options);
  4146.             }
  4147.             else
  4148.             {
  4149.                 $data = @unserialize($trimmed);
  4150.             }
  4151.             if ($data === false && substr($trimmed, 0, 4) !== 'b:0;')
  4152.             {
  4153.                 return;
  4154.             }
  4155.         }
  4156.         else
  4157.         {
  4158.             $blacklist = true;
  4159.         }
  4160.         $base_obj = new Kint_Object();
  4161.         $base_obj->depth = $o->depth + 1;
  4162.         $base_obj->name = 'unserialize(' . $o->name . ')';
  4163.         if ($o->access_path)
  4164.         {
  4165.             $base_obj->access_path = 'unserialize(' . $o->access_path;
  4166.             if (!KINT_PHP70 || self::$options === array(
  4167.                 true
  4168.             ))
  4169.             {
  4170.                 $base_obj->access_path .= ')';
  4171.             }
  4172.             elseif (self::$options === array(
  4173.                 false
  4174.             ))
  4175.             {
  4176.                 $base_obj->access_path .= ', false)';
  4177.             }
  4178.             else
  4179.             {
  4180.                 $base_obj->access_path .= ', Kint_Parser_Serialize::$options)';
  4181.             }
  4182.         }
  4183.         $r = new Kint_Object_Representation('Serialized');
  4184.         if ($blacklist)
  4185.         {
  4186.             $base_obj->hints[] = 'blacklist';
  4187.             $r->contents = $base_obj;
  4188.         }
  4189.         else
  4190.         {
  4191.             $r->contents = $this
  4192.                 ->parser
  4193.                 ->parse($data, $base_obj);
  4194.         }
  4195.         $o->addRepresentation($r, 0);
  4196.     }
  4197. }
  4198. class Kint_Parser_SimpleXMLElement extends Kint_Parser_Plugin
  4199. {
  4200.     public static $verbose = false;
  4201.     public function getTypes()
  4202.     {
  4203.         return array(
  4204.             'object'
  4205.         );
  4206.     }
  4207.     public function getTriggers()
  4208.     {
  4209.         return Kint_Parser::TRIGGER_SUCCESS;
  4210.     }
  4211.     public function parse(&$var, Kint_Object & $o, $trigger)
  4212.     {
  4213.         if (!$var instanceof SimpleXMLElement)
  4214.         {
  4215.             return;
  4216.         }
  4217.         $o->hints[] = 'simplexml_element';
  4218.         if (!self::$verbose)
  4219.         {
  4220.             $o->removeRepresentation('properties');
  4221.             $o->removeRepresentation('iterator');
  4222.             $o->removeRepresentation('methods');
  4223.         }
  4224.         $a = new Kint_Object_Representation('Attributes');
  4225.         $base_obj = new Kint_Object();
  4226.         $base_obj->depth = $o->depth;
  4227.         if ($o->access_path)
  4228.         {
  4229.             $base_obj->access_path = '(string) ' . $o->access_path;
  4230.         }
  4231.         if ($var->attributes())
  4232.         {
  4233.             $attribs = iterator_to_array($var->attributes());
  4234.             $attribs = array_map('strval', $attribs);
  4235.         }
  4236.         else
  4237.         {
  4238.             $attribs = array();
  4239.         }
  4240.         $depth_stash = $this
  4241.             ->parser->max_depth;
  4242.         $this
  4243.             ->parser->max_depth = 0;
  4244.         $a->contents = $this
  4245.             ->parser
  4246.             ->parse($attribs, $base_obj);
  4247.         $this
  4248.             ->parser->max_depth = $depth_stash;
  4249.         $a->contents = $a
  4250.             ->contents
  4251.             ->value->contents;
  4252.         $o->addRepresentation($a, 0);
  4253.         $children = $var->children();
  4254.         if ($o->value)
  4255.         {
  4256.             $c = new Kint_Object_Representation('Children');
  4257.             foreach ($o
  4258.                 ->value->contents as $value)
  4259.             {
  4260.                 if ($value->name === '@attributes')
  4261.                 {
  4262.                     continue;
  4263.                 }
  4264.                 elseif (isset($children->{$value->name}))
  4265.                 {
  4266.                     $i = 0;
  4267.                     while (isset($children->{$value->name}[$i]))
  4268.                     {
  4269.                         $base_obj = new Kint_Object();
  4270.                         $base_obj->depth = $o->depth + 1;
  4271.                         $base_obj->name = $value->name;
  4272.                         if ($value->access_path)
  4273.                         {
  4274.                             $base_obj->access_path = $value->access_path . '[' . $i . ']';
  4275.                         }
  4276.                         $value = $this
  4277.                             ->parser
  4278.                             ->parse($children->{$value->name}[$i], $base_obj);
  4279.                         if ($value->access_path && $value->type === 'string')
  4280.                         {
  4281.                             $value->access_path = '(string) ' . $value->access_path;
  4282.                         }
  4283.                         $c->contents[] = $value;
  4284.                         ++$i;
  4285.                     }
  4286.                 }
  4287.             }
  4288.             $o->size = count($c->contents);
  4289.             if (!$o->size)
  4290.             {
  4291.                 $o->size = null;
  4292.                 if (strlen((string)$var))
  4293.                 {
  4294.                     $base_obj = new Kint_Object_Blob();
  4295.                     $base_obj->depth = $o->depth + 1;
  4296.                     $base_obj->name = $o->name;
  4297.                     if ($o->access_path)
  4298.                     {
  4299.                         $base_obj->access_path = '(string) ' . $o->access_path;
  4300.                     }
  4301.                     $value = (string)$var;
  4302.                     $depth_stash = $this
  4303.                         ->parser->max_depth;
  4304.                     $this
  4305.                         ->parser->max_depth = 0;
  4306.                     $value = $this
  4307.                         ->parser
  4308.                         ->parse($value, $base_obj);
  4309.                     $this
  4310.                         ->parser->max_depth = $depth_stash;
  4311.                     $c = new Kint_Object_Representation('Contents');
  4312.                     $c->implicit_label = true;
  4313.                     $c->contents = array(
  4314.                         $value
  4315.                     );
  4316.                 }
  4317.             }
  4318.             $o->addRepresentation($c, 0);
  4319.         }
  4320.     }
  4321. }
  4322. class Kint_Parser_SplFileInfo extends Kint_Parser_Plugin
  4323. {
  4324.     public function getTypes()
  4325.     {
  4326.         return array(
  4327.             'object'
  4328.         );
  4329.     }
  4330.     public function getTriggers()
  4331.     {
  4332.         return Kint_Parser::TRIGGER_COMPLETE;
  4333.     }
  4334.     public function parse(&$var, Kint_Object & $o, $trigger)
  4335.     {
  4336.         if (!$var instanceof SplFileInfo)
  4337.         {
  4338.             return;
  4339.         }
  4340.         $r = new Kint_Object_Representation_SplFileInfo(clone $var);
  4341.         $o->addRepresentation($r, 0);
  4342.         $o->size = $r->getSize();
  4343.     }
  4344. }
  4345. class Kint_Parser_SplObjectStorage extends Kint_Parser_Plugin
  4346. {
  4347.     public function getTypes()
  4348.     {
  4349.         if (KINT_PHP53)
  4350.         {
  4351.             return array(
  4352.                 'object'
  4353.             );
  4354.         }
  4355.         else
  4356.         {
  4357.             return array();
  4358.         }
  4359.     }
  4360.     public function getTriggers()
  4361.     {
  4362.         if (KINT_PHP53)
  4363.         {
  4364.             return Kint_Parser::TRIGGER_COMPLETE;
  4365.         }
  4366.         else
  4367.         {
  4368.             return Kint_Parser::TRIGGER_NONE;
  4369.         }
  4370.     }
  4371.     public function parse(&$var, Kint_Object & $o, $trigger)
  4372.     {
  4373.         if (!$var instanceof SplObjectStorage || !($r = $o->getRepresentation('iterator')))
  4374.         {
  4375.             return;
  4376.         }
  4377.         $r = $o->getRepresentation('iterator');
  4378.         if ($r)
  4379.         {
  4380.             $o->size = !is_array($r->contents) ? null : count($r->contents);
  4381.         }
  4382.     }
  4383. }
  4384. class Kint_Parser_Stream extends Kint_Parser_Plugin
  4385. {
  4386.     public function getTypes()
  4387.     {
  4388.         return array(
  4389.             'resource'
  4390.         );
  4391.     }
  4392.     public function getTriggers()
  4393.     {
  4394.         return Kint_Parser::TRIGGER_SUCCESS;
  4395.     }
  4396.     public function parse(&$var, Kint_Object & $o, $trigger)
  4397.     {
  4398.         if (!$o instanceof Kint_Object_Resource || $o->resource_type !== 'stream')
  4399.         {
  4400.             return;
  4401.         }
  4402.         if (!$meta = stream_get_meta_data($var))
  4403.         {
  4404.             return;
  4405.         }
  4406.         $rep = new Kint_Object_Representation('Stream');
  4407.         $rep->implicit_label = true;
  4408.         $base_obj = new Kint_Object();
  4409.         $base_obj->depth = $o->depth;
  4410.         if ($o->access_path)
  4411.         {
  4412.             $base_obj->access_path = 'stream_get_meta_data(' . $o->access_path . ')';
  4413.         }
  4414.         $rep->contents = $this
  4415.             ->parser
  4416.             ->parse($meta, $base_obj);
  4417.         if (!in_array('depth_limit', $rep
  4418.             ->contents
  4419.             ->hints))
  4420.         {
  4421.             $rep->contents = $rep
  4422.                 ->contents
  4423.                 ->value->contents;
  4424.         }
  4425.         $o->addRepresentation($rep, 0);
  4426.         $o = $o->transplant(new Kint_Object_Stream($meta));
  4427.     }
  4428. }
  4429. class Kint_Parser_Table extends Kint_Parser_Plugin
  4430. {
  4431.     public function getTypes()
  4432.     {
  4433.         return array(
  4434.             'array'
  4435.         );
  4436.     }
  4437.     public function getTriggers()
  4438.     {
  4439.         return Kint_Parser::TRIGGER_SUCCESS;
  4440.     }
  4441.     public function parse(&$var, Kint_Object & $o, $trigger)
  4442.     {
  4443.         if (empty($o
  4444.             ->value
  4445.             ->contents))
  4446.         {
  4447.             return;
  4448.         }
  4449.         $array = $this
  4450.             ->parser
  4451.             ->getCleanArray($var);
  4452.         if (count($array) < 2)
  4453.         {
  4454.             return;
  4455.         }
  4456.         $keys = null;
  4457.         foreach ($array as $elem)
  4458.         {
  4459.             if (!is_array($elem) || count($elem) < 2)
  4460.             {
  4461.                 return;
  4462.             }
  4463.             elseif ($keys === null)
  4464.             {
  4465.                 $keys = array_keys($elem);
  4466.             }
  4467.             elseif (array_keys($elem) !== $keys)
  4468.             {
  4469.                 return;
  4470.             }
  4471.         }
  4472.         foreach ($o
  4473.             ->value->contents as $childarray)
  4474.         {
  4475.             if (empty($childarray
  4476.                 ->value
  4477.                 ->contents))
  4478.             {
  4479.                 return;
  4480.             }
  4481.         }
  4482.         $table = new Kint_Object_Representation('Table');
  4483.         $table->contents = $o
  4484.             ->value->contents;
  4485.         $table->hints[] = 'table';
  4486.         $o->addRepresentation($table, 0);
  4487.     }
  4488. }
  4489. class Kint_Parser_Throwable extends Kint_Parser_Plugin
  4490. {
  4491.     public function getTypes()
  4492.     {
  4493.         return array(
  4494.             'object'
  4495.         );
  4496.     }
  4497.     public function getTriggers()
  4498.     {
  4499.         return Kint_Parser::TRIGGER_SUCCESS;
  4500.     }
  4501.     public function parse(&$var, Kint_Object & $o, $trigger)
  4502.     {
  4503.         if (!$var instanceof Exception && (!KINT_PHP70 || !$var instanceof Throwable))
  4504.         {
  4505.             return;
  4506.         }
  4507.         $o = $o->transplant(new Kint_Object_Throwable($var));
  4508.     }
  4509. }
  4510. class Kint_Parser_Timestamp extends Kint_Parser_Plugin
  4511. {
  4512.     public static $blacklist = array(
  4513.         2147483648,
  4514.         2147483647,
  4515.         1073741824,
  4516.         1073741823,
  4517.     );
  4518.     public function getTypes()
  4519.     {
  4520.         return array(
  4521.             'string',
  4522.             'integer'
  4523.         );
  4524.     }
  4525.     public function getTriggers()
  4526.     {
  4527.         return Kint_Parser::TRIGGER_SUCCESS;
  4528.     }
  4529.     public function parse(&$var, Kint_Object & $o, $trigger)
  4530.     {
  4531.         if (is_string($var) && !ctype_digit($var))
  4532.         {
  4533.             return;
  4534.         }
  4535.         if (in_array($var, self::$blacklist))
  4536.         {
  4537.             return;
  4538.         }
  4539.         $len = strlen($var);
  4540.         if ($len === 9 || $len === 10)
  4541.         {
  4542.             $o
  4543.                 ->value->label = 'Timestamp';
  4544.             $o
  4545.                 ->value
  4546.                 ->hints[] = 'timestamp';
  4547.         }
  4548.     }
  4549. }
  4550. class Kint_Parser_ToString extends Kint_Parser_Plugin
  4551. {
  4552.     public static $blacklist = array(
  4553.         'SimpleXMLElement',
  4554.     );
  4555.     public function getTypes()
  4556.     {
  4557.         return array(
  4558.             'object'
  4559.         );
  4560.     }
  4561.     public function getTriggers()
  4562.     {
  4563.         return Kint_Parser::TRIGGER_SUCCESS;
  4564.     }
  4565.     public function parse(&$var, Kint_Object & $o, $trigger)
  4566.     {
  4567.         $reflection = new ReflectionClass($var);
  4568.         if (!$reflection->hasMethod('__toString'))
  4569.         {
  4570.             return;
  4571.         }
  4572.         foreach (self::$blacklist as $class)
  4573.         {
  4574.             if ($var instanceof $class)
  4575.             {
  4576.                 return;
  4577.             }
  4578.         }
  4579.         $r = new Kint_Object_Representation('toString');
  4580.         $r->contents = (string)$var;
  4581.         $o->addRepresentation($r);
  4582.     }
  4583. }
  4584. class Kint_Parser_Trace extends Kint_Parser_Plugin
  4585. {
  4586.     public static $blacklist = array(
  4587.         'spl_autoload_call'
  4588.     );
  4589.     public function getTypes()
  4590.     {
  4591.         return array(
  4592.             'array'
  4593.         );
  4594.     }
  4595.     public function getTriggers()
  4596.     {
  4597.         return Kint_Parser::TRIGGER_SUCCESS;
  4598.     }
  4599.     public function parse(&$var, Kint_Object & $o, $trigger)
  4600.     {
  4601.         if (!$o->value)
  4602.         {
  4603.             return;
  4604.         }
  4605.         $trace = $this
  4606.             ->parser
  4607.             ->getCleanArray($var);
  4608.         if (count($trace) !== count($o
  4609.             ->value
  4610.             ->contents) || !self::isTrace($trace))
  4611.         {
  4612.             return;
  4613.         }
  4614.         $o = $o->transplant(new Kint_Object_Trace());
  4615.         $rep = $o->value;
  4616.         $old_trace = $rep->contents;
  4617.         self::normalizeAliases(self::$blacklist);
  4618.         $rep->contents = array();
  4619.         foreach ($old_trace as $frame)
  4620.         {
  4621.             $index = $frame->name;
  4622.             if (!isset($trace[$index]['function']))
  4623.             {
  4624.                 continue;
  4625.             }
  4626.             if (self::frameIsListed($trace[$index], self::$blacklist))
  4627.             {
  4628.                 continue;
  4629.             }
  4630.             $rep->contents[$index] = $frame->transplant(new Kint_Object_TraceFrame());
  4631.             $rep->contents[$index]->assignFrame($trace[$index]);
  4632.         }
  4633.         ksort($rep->contents);
  4634.         $rep->contents = array_values($rep->contents);
  4635.         $o->clearRepresentations();
  4636.         $o->addRepresentation($rep);
  4637.         $o->size = count($rep->contents);
  4638.     }
  4639.     public static function isTrace(array $trace)
  4640.     {
  4641.         if (!Kint_Object::isSequential($trace))
  4642.         {
  4643.             return false;
  4644.         }
  4645.         static $bt_structure = array(
  4646.             'function' => 'string',
  4647.             'line' => 'integer',
  4648.             'file' => 'string',
  4649.             'class' => 'string',
  4650.             'object' => 'object',
  4651.             'type' => 'string',
  4652.             'args' => 'array',
  4653.         );
  4654.         $file_found = false;
  4655.         foreach ($trace as $frame)
  4656.         {
  4657.             if (!is_array($frame) || !isset($frame['function']))
  4658.             {
  4659.                 return false;
  4660.             }
  4661.             foreach ($frame as $key => $val)
  4662.             {
  4663.                 if (!isset($bt_structure[$key]))
  4664.                 {
  4665.                     return false;
  4666.                 }
  4667.                 elseif (gettype($val) !== $bt_structure[$key])
  4668.                 {
  4669.                     return false;
  4670.                 }
  4671.                 elseif ($key === 'file')
  4672.                 {
  4673.                     $file_found = true;
  4674.                 }
  4675.             }
  4676.         }
  4677.         return $file_found;
  4678.     }
  4679.     public static function frameIsListed(array $frame, array $matches)
  4680.     {
  4681.         if (isset($frame['class']))
  4682.         {
  4683.             $called = array(
  4684.                 strtolower($frame['class']) ,
  4685.                 strtolower($frame['function'])
  4686.             );
  4687.         }
  4688.         else
  4689.         {
  4690.             $called = strtolower($frame['function']);
  4691.         }
  4692.         return in_array($called, $matches, true);
  4693.     }
  4694.     public static function normalizeAliases(array & $aliases)
  4695.     {
  4696.         foreach ($aliases as $index => & $alias)
  4697.         {
  4698.             if (is_array($alias) && count($alias) === 2)
  4699.             {
  4700.                 $alias = array_values(array_filter($alias, 'is_string'));
  4701.                 if (count($alias) === 2 && preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $alias[1]) && preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\\\\]*$/', $alias[0]))
  4702.                 {
  4703.                     $alias = array(
  4704.                         strtolower(ltrim($alias[0], '\\')) ,
  4705.                         strtolower($alias[1]) ,
  4706.                     );
  4707.                 }
  4708.                 else
  4709.                 {
  4710.                     unset($aliases[$index]);
  4711.                     continue;
  4712.                 }
  4713.             }
  4714.             elseif (is_string($alias))
  4715.             {
  4716.                 if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $alias))
  4717.                 {
  4718.                     $alias = strtolower($alias);
  4719.                 }
  4720.                 else
  4721.                 {
  4722.                     unset($aliases[$index]);
  4723.                     continue;
  4724.                 }
  4725.             }
  4726.             else
  4727.             {
  4728.                 unset($aliases[$index]);
  4729.             }
  4730.         }
  4731.         $aliases = array_values($aliases);
  4732.     }
  4733. }
  4734. class Kint_Parser_Xml extends Kint_Parser_Plugin
  4735. {
  4736.     public static $parse_method = 'SimpleXML';
  4737.     public function getTypes()
  4738.     {
  4739.         return array(
  4740.             'string'
  4741.         );
  4742.     }
  4743.     public function getTriggers()
  4744.     {
  4745.         return Kint_Parser::TRIGGER_SUCCESS;
  4746.     }
  4747.     public function parse(&$var, Kint_Object & $o, $trigger)
  4748.     {
  4749.         if (substr($var, 0, 5) !== 'access_path); if (empty($xml)) { return; } list($xml, $access_path, $name) = $xml; $base_obj = new Kint_Object(); $base_obj->depth = $o->depth + 1; $base_obj->name = $name; $base_obj->access_path = $access_path; $r = new Kint_Object_Representation('XML'); $r->contents = $this->parser->parse($xml, $base_obj); $o->addRepresentation($r, 0); } protected static function xmlToSimpleXML($var, $parent_path) { try { $errors = libxml_use_internal_errors(true); $xml = simplexml_load_string($var); libxml_use_internal_errors($errors); } catch (Exception $e) { if (isset($errors)) { libxml_use_internal_errors($errors); } return; } if (!$xml) { return; } if ($parent_path === null) { $access_path = null; } else { $access_path = 'simplexml_load_string('.$parent_path.') '; } $name = $xml->getName(); return array($xml, $access_path, $name); } protected static function xmlToDOMDocument($var, $parent_path) { if (!self::xmlToSimpleXML($var, $parent_path)) { return; } $xml = new DOMDocument(); $xml->loadXML($var); $xml = $xml->firstChild; if ($parent_path === null) { $access_path = null; } else { $access_path = '@DOMDocument::loadXML('.$parent_path.')->firstChild'; } $name = $xml->nodeName; return array($xml, $access_path, $name); } } class Kint_Renderer_Cli extends Kint_Renderer_Text { public static $cli_colors = true; public static $force_utf8 = false; public static $detect_width = true; public static $min_terminal_width = 40; protected static $terminal_width = null; protected $windows_output = false; public function __construct(array $params = array()) { parent::__construct($params); if (!self::$force_utf8) { $this->windows_output = KINT_WIN; } if (!self::$terminal_width) { if (!KINT_WIN && self::$detect_width) { self::$terminal_width = exec('tputcols'); } if (self::$terminal_width < self::$min_terminal_width) { self::$terminal_width = self::$default_width; } } $this->header_width = self::$terminal_width; } protected function utf8_to_windows($string) { return str_replace( array('┌', '═', '┐', '│', '└', '─', '┘'), array("\xda", "\xdc", "\xbf", "\xb3", "\xc0", "\xc4", "\xd9"), $string ); } public function colorValue($string) { if (!self::$cli_colors) { return $string; } else { return "\x1b[32m".str_replace("\n", "\x1b[0m\n\x1b[32m", $string)."\x1b[0m"; } } public function colorType($string) { if (!self::$cli_colors) { return $string; } else { return "\x1b[35;1m".str_replace("\n", "\x1b[0m\n\x1b[35;1m", $string)."\x1b[0m"; } } public function colorTitle($string) { if (!self::$cli_colors) { return $string; } else { return "\x1b[36m".str_replace("\n", "\x1b[0m\n\x1b[36m", $string)."\x1b[0m"; } } public function renderTitle(Kint_Object $o) { if ($this->windows_output) { return $this->utf8_to_windows(parent::renderTitle($o)); } else { return parent::renderTitle($o); } } public function preRender() { return PHP_EOL; } public function postRender() { if ($this->windows_output) { return $this->utf8_to_windows(parent::postRender()); } else { return parent::postRender(); } } public function escape($string, $encoding = false) { return str_replace("\x1b", '\\x1b', $string); } } class Kint_Renderer_Plain extends Kint_Renderer_Text { public static $pre_render_sources = array( 'script' => array(), 'style' => array( array('Kint_Renderer_Plain', 'renderCss'), ), 'raw' => array(), ); public static $theme = 'plain . css'; public static $disable_utf8 = false; protected static $been_run = false; protected $mod_return = false; protected $file_link_format = false; public function __construct(array $params = array()) { parent::__construct($params); if (isset($params['settings']['return '])) { $this->mod_return = $params['settings']['return ']; } if (isset($params['settings']['file_link_format'])) { $this->file_link_format = $params['settings']['file_link_format']; } } protected function utf8_to_htmlentity($string) { return str_replace( array('┌', '═', '┐', '│', '└', '─', '┘'), array('┌', '═', '┐', '│', '└', '─', '┘'), $string ); } public function colorValue($string) { return ''.$string.''; } public function colorType($string) { return ''.$string.''; } public function colorTitle($string) { return ''.$string.''; } public function renderTitle(Kint_Object $o) { if (self::$disable_utf8) { return $this->utf8_to_htmlentity(parent::renderTitle($o)); } else { return parent::renderTitle($o); } } protected static function renderCss() { if (file_exists(KINT_DIR.' / resources / compiled / '.self::$theme)) { return file_get_contents(KINT_DIR.' / resources / compiled / '.self::$theme); } else { return file_get_contents(self::$theme); } } public function preRender() { $output = ''; if (!self::$been_run || $this->mod_return) { foreach (self::$pre_render_sources as $type => $values) { $contents = ''; foreach ($values as $v) { if (is_callable($v)) { $contents .= call_user_func($v, $this); } elseif (is_string($v)) { $contents .= $v; } } if (!strlen($contents)) { continue; } switch ($type) { case 'script': $output .= ''; break; case 'style': $output .= ''; break; default: $output .= $contents; } } if (!$this->mod_return) { self::$been_run = true; } } return $output.''; } public function postRender() { if (self::$disable_utf8) { return $this->utf8_to_htmlentity(parent::postRender()).''; } else { return parent::postRender().''; } } public function ideLink($file, $line) { $shortenedPath = $this->escape(Kint::shortenPath($file)); if (!$this->file_link_format) { return $shortenedPath.':
  4750.             '.$line; } $ideLink = Kint::getIdeLink($file, $line); $class = (strpos($ideLink, 'http: //') === 0) ? 'class="kint-ide-link" ' : ''; return "{$shortenedPath}:{$line}"; } public function escape($string, $encoding = false) { if ($encoding === false) { $encoding = Kint_Object_Blob::detectEncoding($string); } $original_encoding = $encoding; if ($encoding === false || $encoding === 'ASCII') { $encoding = 'UTF-8'; } $string = htmlspecialchars($string, ENT_NOQUOTES, $encoding); if (extension_loaded('mbstring') && $original_encoding !== 'ASCII') { $string = mb_encode_numericentity($string, array(0x80, 0xffff, 0, 0xffff), $encoding); } return $string; } } class Kint_Renderer_Rich extends Kint_Renderer { public static $object_renderers = array( 'blacklist' => 'Kint_Renderer_Rich_Blacklist', 'callable' => 'Kint_Renderer_Rich_Callable', 'closure' => 'Kint_Renderer_Rich_Closure', 'color' => 'Kint_Renderer_Rich_Color', 'depth_limit' => 'Kint_Renderer_Rich_DepthLimit', 'nothing' => 'Kint_Renderer_Rich_Nothing', 'recursion' => 'Kint_Renderer_Rich_Recursion', 'simplexml_element' => 'Kint_Renderer_Rich_SimpleXMLElement', 'trace_frame' => 'Kint_Renderer_Rich_TraceFrame', ); public static $tab_renderers = array( 'binary' => 'Kint_Renderer_Rich_Binary', 'color' => 'Kint_Renderer_Rich_ColorDetails', 'docstring' => 'Kint_Renderer_Rich_Docstring', 'microtime' => 'Kint_Renderer_Rich_Microtime', 'source' => 'Kint_Renderer_Rich_Source', 'table' => 'Kint_Renderer_Rich_Table', 'timestamp' => 'Kint_Renderer_Rich_Timestamp', ); public static $pre_render_sources = array( 'script' => array( array('Kint_Renderer_Rich', 'renderJs'), array('Kint_Renderer_Rich_Microtime', 'renderJs'), ), 'style' => array( array('Kint_Renderer_Rich', 'renderCss'), ), 'raw' => array(), ); public static $access_paths = true; public static $strlen_max = 80; public static $theme = 'original.css'; public static $escape_types = false; protected static $been_run = false; protected $plugin_objs = array(); protected $mod_return = false; protected $callee; protected $mini_trace; protected $previous_caller; protected $file_link_format = false; protected $show_minitrace = true; protected $auto_expand = false; public function __construct(array $params = array()) { parent::__construct($params); $params += array( 'modifiers' => array(), 'minitrace' => array(), 'callee' => null, 'caller' => null, ); $this->callee = $params['callee']; $this->mini_trace = $params['minitrace']; $this->previous_caller = $params['caller']; if (isset($params['settings']['return'])) { $this->mod_return = $params['settings']['return']; } if (isset($params['settings']['file_link_format'])) { $this->file_link_format = $params['settings']['file_link_format']; } if (empty($params['settings']['display_called_from'])) { $this->show_minitrace = false; } if (!empty($params['settings']['expanded'])) { $this->auto_expand = true; } } public function render(Kint_Object $o) { if ($plugin = $this->getPlugin(self::$object_renderers, $o->hints)) { if (strlen($output = $plugin->render($o))) { return $output; } } $children = $this->renderChildren($o); $header = $this->renderHeaderWrapper($o, (bool) strlen($children), $this->renderHeader($o)); return '
  4751.                 '.$header.$children.''; } public function renderHeaderWrapper(Kint_Object $o, $has_children, $contents) { $out = 'auto_expand)
  4752.                 {
  4753.                     $out .= ' kint-show';
  4754.                 }
  4755.                 $out .= '"';
  4756.             }
  4757.             $out .= '>';
  4758.             if (self::$access_paths && $o->depth > 0 && $ap = $o->getAccessPath())
  4759.             {
  4760.                 $out .= '⇄';
  4761.             }
  4762.             if ($has_children)
  4763.             {
  4764.                 $out .= '→
  4765. ';
  4766.             }
  4767.             $out .= $contents;
  4768.             if (!empty($ap))
  4769.             {
  4770.                 $out .= '
  4771. ' . $this->escape($ap) . '
  4772. ';
  4773.             }
  4774.             return $out . '';
  4775.         }
  4776.         public function renderHeader(Kint_Object $o)
  4777.         {
  4778.             $output = '';
  4779.             if (($s = $o->getModifiers()) !== null)
  4780.             {
  4781.                 $output .= '' . $s . ' ';
  4782.             }
  4783.             if (($s = $o->getName()) !== null)
  4784.             {
  4785.                 $output .= '' . $this->escape($s) . ' ';
  4786.                 if ($s = $o->getOperator())
  4787.                 {
  4788.                     $output .= $this->escape($s, 'ASCII') . ' ';
  4789.                 }
  4790.             }
  4791.             if (($s = $o->getType()) !== null)
  4792.             {
  4793.                 if (self::$escape_types)
  4794.                 {
  4795.                     $s = $this->escape($s);
  4796.                 }
  4797.                 if ($o->reference)
  4798.                 {
  4799.                     $s = '&' . $s;
  4800.                 }
  4801.                 $output .= '' . $s . ' ';
  4802.             }
  4803.             if (($s = $o->getSize()) !== null)
  4804.             {
  4805.                 if (self::$escape_types)
  4806.                 {
  4807.                     $s = $this->escape($s);
  4808.                 }
  4809.                 $output .= '(' . $s . ') ';
  4810.             }
  4811.             if (($s = $o->getValueShort()) !== null)
  4812.             {
  4813.                 $s = preg_replace('/\s+/', ' ', $s);
  4814.                 if (self::$strlen_max && Kint_Object_Blob::strlen($s) > self::$strlen_max)
  4815.                 {
  4816.                     $s = substr($s, 0, self::$strlen_max) . '...';
  4817.                 }
  4818.                 $output .= $this->escape($s);
  4819.             }
  4820.             return trim($output);
  4821.         }
  4822.         public function renderChildren(Kint_Object $o)
  4823.         {
  4824.             $contents = array();
  4825.             $tabs = array();
  4826.             foreach ($o->getRepresentations() as $rep)
  4827.             {
  4828.                 $result = $this->renderTab($o, $rep);
  4829.                 if (strlen($result))
  4830.                 {
  4831.                     $contents[] = $result;
  4832.                     $tabs[] = $rep;
  4833.                 }
  4834.             }
  4835.             if (empty($tabs))
  4836.             {
  4837.                 return '';
  4838.             }
  4839.             $output = '
  4840. ';
  4841.             if (count($tabs) === 1 && $tabs[0]->labelIsImplicit())
  4842.             {
  4843.                 $output .= reset($contents);
  4844.             }
  4845.             else
  4846.             {
  4847.                 $output .= '
  4848. ';
  4849.                 foreach ($tabs as $i => $tab)
  4850.                 {
  4851.                     if ($i === 0)
  4852.                     {
  4853.                         $output .= '
  4854. ';
  4855.                     }
  4856.                     else
  4857.                     {
  4858.                         $output .= '
  4859. ';
  4860.                     }
  4861.                     $output .= $this->escape($tab->getLabel()) . '
  4862. ';
  4863.                 }
  4864.                 $output .= '
  4865. ';
  4866.                 foreach ($contents as $tab)
  4867.                 {
  4868.                     $output .= '
  4869. ' . $tab . '
  4870. ';
  4871.                 }
  4872.                 $output .= '
  4873. ';
  4874.             }
  4875.             return $output . '
  4876. ';
  4877.         }
  4878.         protected function renderTab(Kint_Object $o, Kint_Object_Representation $rep)
  4879.         {
  4880.             if ($plugin = $this->getPlugin(self::$tab_renderers, $rep->hints))
  4881.             {
  4882.                 if (strlen($output = $plugin->render($rep)))
  4883.                 {
  4884.                     return $output;
  4885.                 }
  4886.             }
  4887.             if (is_array($rep->contents))
  4888.             {
  4889.                 $output = '';
  4890.                 foreach ($rep->contents as $obj)
  4891.                 {
  4892.                     $output .= $this->render($obj);
  4893.                 }
  4894.                 return $output;
  4895.             }
  4896.             elseif (is_string($rep->contents))
  4897.             {
  4898.                 $show_contents = false;
  4899.                 if ($o->type !== 'string' || $o->value !== $rep)
  4900.                 {
  4901.                     $show_contents = true;
  4902.                 }
  4903.                 elseif (preg_match('/(:?[\r\n\t\f\v]| {2})/', $rep->contents))
  4904.                 {
  4905.                     $show_contents = true;
  4906.                 }
  4907.                 elseif (self::$strlen_max && Kint_Object_Blob::strlen($rep->contents) > self::$strlen_max)
  4908.                 {
  4909.                     $show_contents = true;
  4910.                 }
  4911.                 if ($o->type === 'string' && $o->value === $rep && $o->encoding === false)
  4912.                 {
  4913.                     $show_contents = false;
  4914.                 }
  4915.                 if ($show_contents)
  4916.                 {
  4917.                     return '
  4918. ' . $this->escape($rep->contents) . "\n
  4919. ";
  4920.                 }
  4921.             }
  4922.             elseif ($rep->contents instanceof Kint_Object)
  4923.             {
  4924.                 return $this->render($rep->contents);
  4925.             }
  4926.             return;
  4927.         }
  4928.         protected static function renderJs()
  4929.         {
  4930.             return file_get_contents(KINT_DIR . '/resources/compiled/rich.js');
  4931.         }
  4932.         protected static function renderCss()
  4933.         {
  4934.             if (file_exists(KINT_DIR . '/resources/compiled/' . self::$theme))
  4935.             {
  4936.                 return file_get_contents(KINT_DIR . '/resources/compiled/' . self::$theme);
  4937.             }
  4938.             else
  4939.             {
  4940.                 return file_get_contents(self::$theme);
  4941.             }
  4942.         }
  4943.         public function preRender()
  4944.         {
  4945.             $output = '';
  4946.             if (!self::$been_run || $this->mod_return)
  4947.             {
  4948.                 foreach (self::$pre_render_sources as $type => $values)
  4949.                 {
  4950.                     $contents = '';
  4951.                     foreach ($values as $v)
  4952.                     {
  4953.                         if (is_callable($v))
  4954.                         {
  4955.                             $contents .= call_user_func($v, $this);
  4956.                         }
  4957.                         elseif (is_string($v))
  4958.                         {
  4959.                             $contents .= $v;
  4960.                         }
  4961.                     }
  4962.                     if (!strlen($contents))
  4963.                     {
  4964.                         continue;
  4965.                     }
  4966.                     switch ($type)
  4967.                     {
  4968.                         case 'script':
  4969.                             $output .= '';
  4970.                         break;
  4971.                         case 'style':
  4972.                             $output .= '';
  4973.                         break;
  4974.                         default:
  4975.                             $output .= $contents;
  4976.                     }
  4977.                 }
  4978.                 if (!$this->mod_return)
  4979.                 {
  4980.                     self::$been_run = true;
  4981.                 }
  4982.             }
  4983.             return $output . '
  4984. ';
  4985.         }
  4986.         public function postRender()
  4987.         {
  4988.             if (!$this->show_minitrace)
  4989.             {
  4990.                 return '
  4991. ';
  4992.             }
  4993.             $output = '
  4994. ';
  4995.             $output .= '→ ';
  4996.             if (isset($this->callee['file']))
  4997.             {
  4998.                 if (!empty($this->mini_trace))
  4999.                 {
  5000.                     $output .= '
  5001. ';
  5002.                 }
  5003.                 $output .= 'Called from ' . $this->ideLink($this->callee['file'], $this->callee['line']);
  5004.             }
  5005.             $caller = '';
  5006.             if (isset($this->previous_caller['class']))
  5007.             {
  5008.                 $caller .= $this->previous_caller['class'];
  5009.             }
  5010.             if (isset($this->previous_caller['type']))
  5011.             {
  5012.                 $caller .= $this->previous_caller['type'];
  5013.             }
  5014.             if (isset($this->previous_caller['function']) && !in_array($this->previous_caller['function'], array(
  5015.                 'include',
  5016.                 'include_once',
  5017.                 'require',
  5018.                 'require_once'
  5019.             )))
  5020.             {
  5021.                 $caller .= $this->previous_caller['function'] . '()';
  5022.             }
  5023.             if ($caller)
  5024.             {
  5025.                 $output .= ' [' . $caller . ']';
  5026.             }
  5027.             if (!empty($this->mini_trace))
  5028.             {
  5029.                 $output .= '
  5030. ';
  5031.                 foreach ($this->mini_trace as $step)
  5032.                 {
  5033.                     $output .= '
  5034. ' . $this->ideLink($step['file'], $step['line']);
  5035.                     if (isset($step['function']) && !in_array($step['function'], array(
  5036.                         'include',
  5037.                         'include_once',
  5038.                         'require',
  5039.                         'require_once'
  5040.                     )))
  5041.                     {
  5042.                         $output .= ' [';
  5043.                         if (isset($step['class']))
  5044.                         {
  5045.                             $output .= $step['class'];
  5046.                         }
  5047.                         if (isset($step['type']))
  5048.                         {
  5049.                             $output .= $step['type'];
  5050.                         }
  5051.                         $output .= $step['function'] . '()]';
  5052.                     }
  5053.                 }
  5054.                 $output .= '
  5055. ';
  5056.             }
  5057.             $output .= '
  5058. ';
  5059.             return $output;
  5060.         }
  5061.         public function escape($string, $encoding = false)
  5062.         {
  5063.             if ($encoding === false)
  5064.             {
  5065.                 $encoding = Kint_Object_Blob::detectEncoding($string);
  5066.             }
  5067.             $original_encoding = $encoding;
  5068.             if ($encoding === false || $encoding === 'ASCII')
  5069.             {
  5070.                 $encoding = 'UTF-8';
  5071.             }
  5072.             $string = htmlspecialchars($string, ENT_NOQUOTES, $encoding);
  5073.             if (extension_loaded('mbstring') && $original_encoding !== 'ASCII')
  5074.             {
  5075.                 $string = mb_encode_numericentity($string, array(
  5076.                     0x80,
  5077.                     0xffff,
  5078.                     0,
  5079.                     0xffff
  5080.                 ) , $encoding);
  5081.             }
  5082.             return $string;
  5083.         }
  5084.         protected function getPlugin(array $plugins, array $hints)
  5085.         {
  5086.             if ($plugins = $this->matchPlugins($plugins, $hints))
  5087.             {
  5088.                 $plugin = end($plugins);
  5089.                 if (!isset($this->plugin_objs[$plugin]))
  5090.                 {
  5091.                     $this->plugin_objs[$plugin] = new $plugin($this);
  5092.                 }
  5093.                 return $this->plugin_objs[$plugin];
  5094.             }
  5095.         }
  5096.         protected function ideLink($file, $line)
  5097.         {
  5098.             $shortenedPath = $this->escape(Kint::shortenPath($file));
  5099.             if (!$this->file_link_format)
  5100.             {
  5101.                 return $shortenedPath . ':' . $line;
  5102.             }
  5103.             $ideLink = Kint::getIdeLink($file, $line);
  5104.             $class = (strpos($ideLink, 'http://') === 0) ? 'class="kint-ide-link" ' : '';
  5105.             return "{$shortenedPath}:{$line}";
  5106.         }
  5107.     }
  5108.     class Kint_Renderer_Text extends Kint_Renderer
  5109.     {
  5110.         public static $object_renderers = array(
  5111.             'blacklist' => 'Kint_Renderer_Text_Blacklist',
  5112.             'depth_limit' => 'Kint_Renderer_Text_DepthLimit',
  5113.             'nothing' => 'Kint_Renderer_Text_Nothing',
  5114.             'recursion' => 'Kint_Renderer_Text_Recursion',
  5115.             'trace' => 'Kint_Renderer_Text_Trace',
  5116.         );
  5117.         public static $parser_plugin_whitelist = array(
  5118.             'Kint_Parser_Blacklist',
  5119.             'Kint_Parser_Stream',
  5120.             'Kint_Parser_Trace',
  5121.         );
  5122.         public static $strlen_max = 0;
  5123.         public static $default_width = 80;
  5124.         public static $default_indent = 4;
  5125.         public static $decorations = true;
  5126.         public $header_width = 80;
  5127.         public $indent_width = 4;
  5128.         protected $plugin_objs = array();
  5129.         protected $previous_caller;
  5130.         protected $callee;
  5131.         protected $show_minitrace = true;
  5132.         public function __construct(array $params = array())
  5133.         {
  5134.             parent::__construct($params);
  5135.             $params += array(
  5136.                 'callee' => null,
  5137.                 'caller' => null,
  5138.             );
  5139.             $this->callee = $params['callee'];
  5140.             $this->previous_caller = $params['caller'];
  5141.             $this->show_minitrace = !empty($params['settings']['display_called_from']);
  5142.             $this->header_width = self::$default_width;
  5143.             $this->indent_width = self::$default_indent;
  5144.         }
  5145.         public function render(Kint_Object $o)
  5146.         {
  5147.             if ($plugin = $this->getPlugin(self::$object_renderers, $o->hints))
  5148.             {
  5149.                 if (strlen($output = $plugin->render($o)))
  5150.                 {
  5151.                     return $output;
  5152.                 }
  5153.             }
  5154.             $out = '';
  5155.             if ($o->depth == 0)
  5156.             {
  5157.                 $out .= $this->colorTitle($this->renderTitle($o)) . PHP_EOL;
  5158.             }
  5159.             $out .= $this->renderHeader($o);
  5160.             $out .= $this->renderChildren($o) . PHP_EOL;
  5161.             return $out;
  5162.         }
  5163.         public function boxText($text, $width)
  5164.         {
  5165.             if (Kint_Object_Blob::strlen($text) > $width - 4)
  5166.             {
  5167.                 $text = Kint_Object_Blob::substr($text, 0, $width - 7) . '...';
  5168.             }
  5169.             $text .= str_repeat(' ', $width - 4 - Kint_Object_Blob::strlen($text));
  5170.             $out = '┌' . str_repeat('─', $width - 2) . '┐' . PHP_EOL;
  5171.             $out .= '│ ' . $this->escape($text) . ' │' . PHP_EOL;
  5172.             $out .= '└' . str_repeat('─', $width - 2) . '┘';
  5173.             return $out;
  5174.         }
  5175.         public function renderTitle(Kint_Object $o)
  5176.         {
  5177.             if (($name = $o->getName()) === null)
  5178.             {
  5179.                 $name = 'literal';
  5180.             }
  5181.             if (self::$decorations)
  5182.             {
  5183.                 return $this->boxText($name, $this->header_width);
  5184.             }
  5185.             elseif (Kint_Object_Blob::strlen($name) > $this->header_width)
  5186.             {
  5187.                 return Kint_Object_Blob::substr($name, 0, $this->header_width - 3) . '...';
  5188.             }
  5189.             else
  5190.             {
  5191.                 return $name;
  5192.             }
  5193.         }
  5194.         public function renderHeader(Kint_Object $o)
  5195.         {
  5196.             $output = array();
  5197.             if ($o->depth)
  5198.             {
  5199.                 if (($s = $o->getModifiers()) !== null)
  5200.                 {
  5201.                     $output[] = $s;
  5202.                 }
  5203.                 if ($o->name !== null)
  5204.                 {
  5205.                     $output[] = $this->escape(var_export($o->name, true));
  5206.                     if (($s = $o->getOperator()) !== null)
  5207.                     {
  5208.                         $output[] = $this->escape($s);
  5209.                     }
  5210.                 }
  5211.             }
  5212.             if (($s = $o->getType()) !== null)
  5213.             {
  5214.                 if ($o->reference)
  5215.                 {
  5216.                     $s = '&' . $s;
  5217.                 }
  5218.                 $output[] = $this->colorType($this->escape($s));
  5219.             }
  5220.             if (($s = $o->getSize()) !== null)
  5221.             {
  5222.                 $output[] = '(' . $this->escape($s) . ')';
  5223.             }
  5224.             if (($s = $o->getValueShort()) !== null)
  5225.             {
  5226.                 if (self::$strlen_max && Kint_Object_Blob::strlen($s) > self::$strlen_max)
  5227.                 {
  5228.                     $s = substr($s, 0, self::$strlen_max) . '...';
  5229.                 }
  5230.                 $output[] = $this->colorValue($this->escape($s));
  5231.             }
  5232.             return str_repeat(' ', $o->depth * $this->indent_width) . implode(' ', $output);
  5233.         }
  5234.         public function renderChildren(Kint_Object $o)
  5235.         {
  5236.             if ($o->type === 'array')
  5237.             {
  5238.                 $output = ' [';
  5239.             }
  5240.             elseif ($o->type === 'object')
  5241.             {
  5242.                 $output = ' (';
  5243.             }
  5244.             else
  5245.             {
  5246.                 return '';
  5247.             }
  5248.             $children = '';
  5249.             if ($o->value && is_array($o
  5250.                 ->value
  5251.                 ->contents))
  5252.             {
  5253.                 foreach ($o
  5254.                     ->value->contents as $child)
  5255.                 {
  5256.                     $children .= $this->render($child);
  5257.                 }
  5258.             }
  5259.             if ($children)
  5260.             {
  5261.                 $output .= PHP_EOL . $children;
  5262.                 $output .= str_repeat(' ', $o->depth * $this->indent_width);
  5263.             }
  5264.             if ($o->type === 'array')
  5265.             {
  5266.                 $output .= ']';
  5267.             }
  5268.             elseif ($o->type === 'object')
  5269.             {
  5270.                 $output .= ')';
  5271.             }
  5272.             return $output;
  5273.         }
  5274.         public function colorValue($string)
  5275.         {
  5276.             return $string;
  5277.         }
  5278.         public function colorType($string)
  5279.         {
  5280.             return $string;
  5281.         }
  5282.         public function colorTitle($string)
  5283.         {
  5284.             return $string;
  5285.         }
  5286.         public function postRender()
  5287.         {
  5288.             if (self::$decorations)
  5289.             {
  5290.                 $output = str_repeat('═', $this->header_width);
  5291.             }
  5292.             else
  5293.             {
  5294.                 $output = '';
  5295.             }
  5296.             if (!$this->show_minitrace)
  5297.             {
  5298.                 return $this->colorTitle($output);
  5299.             }
  5300.             else
  5301.             {
  5302.                 if ($output)
  5303.                 {
  5304.                     $output .= PHP_EOL;
  5305.                 }
  5306.                 return $this->colorTitle($output . $this->calledFrom() . PHP_EOL);
  5307.             }
  5308.         }
  5309.         public function parserPlugins(array $plugins)
  5310.         {
  5311.             $return = array();
  5312.             foreach ($plugins as $index => $plugin)
  5313.             {
  5314.                 foreach (self::$parser_plugin_whitelist as $whitelist)
  5315.                 {
  5316.                     if ($plugin instanceof $whitelist)
  5317.                     {
  5318.                         $return[] = $plugin;
  5319.                         continue 2;
  5320.                     }
  5321.                 }
  5322.             }
  5323.             return $return;
  5324.         }
  5325.         protected function calledFrom()
  5326.         {
  5327.             $output = '';
  5328.             if (isset($this->callee['file']))
  5329.             {
  5330.                 $output .= 'Called from ' . $this->ideLink($this->callee['file'], $this->callee['line']);
  5331.             }
  5332.             $caller = '';
  5333.             if (isset($this->previous_caller['class']))
  5334.             {
  5335.                 $caller .= $this->previous_caller['class'];
  5336.             }
  5337.             if (isset($this->previous_caller['type']))
  5338.             {
  5339.                 $caller .= $this->previous_caller['type'];
  5340.             }
  5341.             if (isset($this->previous_caller['function']) && !in_array($this->previous_caller['function'], array(
  5342.                 'include',
  5343.                 'include_once',
  5344.                 'require',
  5345.                 'require_once'
  5346.             )))
  5347.             {
  5348.                 $caller .= $this->previous_caller['function'] . '()';
  5349.             }
  5350.             if ($caller)
  5351.             {
  5352.                 $output .= ' [' . $caller . ']';
  5353.             }
  5354.             return $output;
  5355.         }
  5356.         public function ideLink($file, $line)
  5357.         {
  5358.             return $this->escape(Kint::shortenPath($file)) . ':' . $line;
  5359.         }
  5360.         protected function getPlugin(array $plugins, array $hints)
  5361.         {
  5362.             if ($plugins = $this->matchPlugins($plugins, $hints))
  5363.             {
  5364.                 $plugin = end($plugins);
  5365.                 if (!isset($this->plugin_objs[$plugin]))
  5366.                 {
  5367.                     $this->plugin_objs[$plugin] = new $plugin($this);
  5368.                 }
  5369.                 return $this->plugin_objs[$plugin];
  5370.             }
  5371.         }
  5372.         public function escape($string, $encoding = false)
  5373.         {
  5374.             return $string;
  5375.         }
  5376.     }
  5377.     class Kint_Renderer_Rich_Binary extends Kint_Renderer_Rich_Plugin
  5378.     {
  5379.         public static $line_length = 0x10;
  5380.         public static $chunk_length = 0x4;
  5381.         public function render($r)
  5382.         {
  5383.             $out = '
  5384. ';
  5385.             $chunks = str_split($r->contents, self::$line_length);
  5386.             foreach ($chunks as $index => $chunk)
  5387.             {
  5388.                 $out .= sprintf('%08X', $index * self::$line_length) . ":\t";
  5389.                 $out .= implode(' ', str_split(str_pad(bin2hex($chunk) , 2 * self::$line_length, ' ') , self::$chunk_length));
  5390.                 $out .= "\t" . preg_replace('/[^\x20-\x7E]/', '.', $chunk) . "\n";
  5391.             }
  5392.             $out .= '
  5393. ';
  5394.             return $out;
  5395.         }
  5396.     }
  5397.     class Kint_Renderer_Rich_Blacklist extends Kint_Renderer_Rich_Plugin
  5398.     {
  5399.         public function render($o)
  5400.         {
  5401.             return '
  5402. ' . $this->renderHeaderLocked($o, 'Blacklisted') . '
  5403. ';
  5404.         }
  5405.     }
  5406.     class Kint_Renderer_Rich_Callable extends Kint_Renderer_Rich_Plugin
  5407.     {
  5408.         protected static $method_cache = array();
  5409.         public function render($o)
  5410.         {
  5411.             if ($o instanceof Kint_Object_Method && strlen($o->owner_class) && strlen($o->name) && !empty(self::$method_cache[$o->owner_class][$o->name]))
  5412.             {
  5413.                 $children = self::$method_cache[$o->owner_class][$o->name]['children'];
  5414.                 $header = $this
  5415.                     ->renderer
  5416.                     ->renderHeaderWrapper($o, (bool)strlen($children) , self::$method_cache[$o->owner_class][$o->name]['header']);
  5417.                 return '
  5418. ' . $header . $children . '
  5419. ';
  5420.             }
  5421.             $children = $this
  5422.                 ->renderer
  5423.                 ->renderChildren($o);
  5424.             $header = '';
  5425.             if (($s = $o->getModifiers()) !== null)
  5426.             {
  5427.                 $header .= '' . $s . ' ';
  5428.             }
  5429.             if (($s = $o->getName()) !== null)
  5430.             {
  5431.                 $function = $this
  5432.                     ->renderer
  5433.                     ->escape($s) . '(' . $this
  5434.                     ->renderer
  5435.                     ->escape($o->getParams()) . ')';
  5436.                 if (($url = $o->getPhpDocUrl()) !== null)
  5437.                 {
  5438.                     $function = '' . $function . '';
  5439.                 }
  5440.                 $header .= '' . $function . '';
  5441.             }
  5442.             if (!empty($o->returntype))
  5443.             {
  5444.                 $header .= ': ' . $this
  5445.                     ->renderer
  5446.                     ->escape($o->returntype) . '';
  5447.             }
  5448.             if (($s = $o->getValueShort()) !== null)
  5449.             {
  5450.                 if (Kint_Renderer_Rich::$strlen_max && Kint_Object_Blob::strlen($s) > Kint_Renderer_Rich::$strlen_max)
  5451.                 {
  5452.                     $s = substr($s, 0, Kint_Renderer_Rich::$strlen_max) . '...';
  5453.                 }
  5454.                 $header .= ' ' . $this
  5455.                     ->renderer
  5456.                     ->escape($s);
  5457.             }
  5458.             if ($o instanceof Kint_Object_Method && strlen($o->owner_class) && strlen($o->name))
  5459.             {
  5460.                 $cache = array(
  5461.                     'header' => $header,
  5462.                     'children' => $children,
  5463.                 );
  5464.                 if (!isset(self::$method_cache[$o->owner_class]))
  5465.                 {
  5466.                     self::$method_cache[$o->owner_class] = array(
  5467.                         $o->name => $cache
  5468.                     );
  5469.                 }
  5470.                 elseif (!isset(self::$method_cache[$o->owner_class][$o->name]))
  5471.                 {
  5472.                     self::$method_cache[$o->owner_class][$o->name] = $cache;
  5473.                 }
  5474.             }
  5475.             $header = $this
  5476.                 ->renderer
  5477.                 ->renderHeaderWrapper($o, (bool)strlen($children) , $header);
  5478.             return '
  5479. ' . $header . $children . '
  5480. ';
  5481.         }
  5482.     }
  5483.     class Kint_Renderer_Rich_Closure extends Kint_Renderer_Rich_Plugin
  5484.     {
  5485.         public function render($o)
  5486.         {
  5487.             $children = $this
  5488.                 ->renderer
  5489.                 ->renderChildren($o);
  5490.             if (!($o instanceof Kint_Object_Closure))
  5491.             {
  5492.                 $header = $this
  5493.                     ->renderer
  5494.                     ->renderHeader($o);
  5495.             }
  5496.             else
  5497.             {
  5498.                 $header = '';
  5499.                 if (($s = $o->getModifiers()) !== null)
  5500.                 {
  5501.                     $header .= '' . $s . ' ';
  5502.                 }
  5503.                 if (($s = $o->getName()) !== null)
  5504.                 {
  5505.                     $header .= '' . $this
  5506.                         ->renderer
  5507.                         ->escape($s) . '(' . $this
  5508.                         ->renderer
  5509.                         ->escape($o->getParams()) . ') ';
  5510.                 }
  5511.                 $header .= 'Closure ';
  5512.                 $header .= $this
  5513.                     ->renderer
  5514.                     ->escape(Kint::shortenPath($o->filename)) . ':' . (int)$o->startline;
  5515.             }
  5516.             $header = $this
  5517.                 ->renderer
  5518.                 ->renderHeaderWrapper($o, (bool)strlen($children) , $header);
  5519.             return '
  5520. ' . $header . $children . '
  5521. ';
  5522.         }
  5523.     }
  5524.     class Kint_Renderer_Rich_Color extends Kint_Renderer_Rich_Plugin
  5525.     {
  5526.         public function render($o)
  5527.         {
  5528.             $children = $this
  5529.                 ->renderer
  5530.                 ->renderChildren($o);
  5531.             $header = $this
  5532.                 ->renderer
  5533.                 ->renderHeader($o);
  5534.             $header .= '
  5535. ';
  5536.             $header = $this
  5537.                 ->renderer
  5538.                 ->renderHeaderWrapper($o, (bool)strlen($children) , $header);
  5539.             return '
  5540. ' . $header . $children . '
  5541. ';
  5542.         }
  5543.     }
  5544.     class Kint_Renderer_Rich_ColorDetails extends Kint_Renderer_Rich_Plugin
  5545.     {
  5546.         public function render($r)
  5547.         {
  5548.             if (!$r instanceof Kint_Object_Representation_Color)
  5549.             {
  5550.                 return false;
  5551.             }
  5552.             $out = '';
  5553.             if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_NAME))
  5554.             {
  5555.                 $out .= '' . $color . "\n";
  5556.             }
  5557.             if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_HEX_3))
  5558.             {
  5559.                 $out .= '' . $color . "\n";
  5560.             }
  5561.             if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_HEX_6))
  5562.             {
  5563.                 $out .= '' . $color . "\n";
  5564.             }
  5565.             if ($r->hasAlpha())
  5566.             {
  5567.                 if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_HEX_4))
  5568.                 {
  5569.                     $out .= '' . $color . "\n";
  5570.                 }
  5571.                 if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_HEX_8))
  5572.                 {
  5573.                     $out .= '' . $color . "\n";
  5574.                 }
  5575.                 if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_RGBA))
  5576.                 {
  5577.                     $out .= '' . $color . "\n";
  5578.                 }
  5579.                 if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_HSLA))
  5580.                 {
  5581.                     $out .= '' . $color . "\n";
  5582.                 }
  5583.             }
  5584.             else
  5585.             {
  5586.                 if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_RGB))
  5587.                 {
  5588.                     $out .= '' . $color . "\n";
  5589.                 }
  5590.                 if ($color = $r->getColor(Kint_Object_Representation_Color::COLOR_HSL))
  5591.                 {
  5592.                     $out .= '' . $color . "\n";
  5593.                 }
  5594.             }
  5595.             if (!strlen($out))
  5596.             {
  5597.                 return false;
  5598.             }
  5599.             return '
  5600. ' . $out . '
  5601. ';
  5602.         }
  5603.     }
  5604.     class Kint_Renderer_Rich_DepthLimit extends Kint_Renderer_Rich_Plugin
  5605.     {
  5606.         public function render($o)
  5607.         {
  5608.             return '
  5609. ' . $this->renderHeaderLocked($o, 'Depth Limit') . '
  5610. ';
  5611.         }
  5612.     }
  5613.     class Kint_Renderer_Rich_Docstring extends Kint_Renderer_Rich_Plugin
  5614.     {
  5615.         public function render($r)
  5616.         {
  5617.             if (!($r instanceof Kint_Object_Representation_Docstring))
  5618.             {
  5619.                 return false;
  5620.             }
  5621.             $docstring = array();
  5622.             foreach (explode("\n", $r->contents) as $line)
  5623.             {
  5624.                 $docstring[] = trim($line);
  5625.             }
  5626.             $docstring = implode("\n", $docstring);
  5627.             $location = array();
  5628.             if ($r->class)
  5629.             {
  5630.                 $location[] = 'Inherited from ' . $this
  5631.                     ->renderer
  5632.                     ->escape($r->class);
  5633.             }
  5634.             if ($r->file && $r->line)
  5635.             {
  5636.                 $location[] = 'Defined in ' . $this
  5637.                     ->renderer
  5638.                     ->escape(Kint::shortenPath($r->file)) . ':' . ((int)$r->line);
  5639.             }
  5640.             if ($location)
  5641.             {
  5642.                 if (strlen($docstring))
  5643.                 {
  5644.                     $docstring .= "\n\n";
  5645.                 }
  5646.                 $location = '' . implode("\n", $location) . '';
  5647.             }
  5648.             elseif (strlen($docstring) === 0)
  5649.             {
  5650.                 return '';
  5651.             }
  5652.             return '
  5653. ' . $this
  5654.                 ->renderer
  5655.                 ->escape($docstring) . $location . '
  5656. ';
  5657.         }
  5658.     }
  5659.     class Kint_Renderer_Rich_Microtime extends Kint_Renderer_Rich_Plugin
  5660.     {
  5661.         public function render($r)
  5662.         {
  5663.             if (!($r instanceof Kint_Object_Representation_Microtime))
  5664.             {
  5665.                 return false;
  5666.             }
  5667.             list($usec, $sec) = explode(' ', $r->contents);
  5668.             $out = @date('Y-m-d H:i:s', $sec) . '.' . substr($usec, 2, 4);
  5669.             if ($r->lap !== null)
  5670.             {
  5671.                 $out .= "\nSINCE LAST CALL: " . round($r->lap, 4) . 's.';
  5672.             }
  5673.             if ($r->total !== null)
  5674.             {
  5675.                 $out .= "\nSINCE START: " . round($r->total, 4) . 's.';
  5676.             }
  5677.             if ($r->avg !== null)
  5678.             {
  5679.                 $out .= "\nAVERAGE DURATION: " . round($r->avg, 4) . 's.';
  5680.             }
  5681.             $unit = array(
  5682.                 'B',
  5683.                 'KB',
  5684.                 'MB',
  5685.                 'GB',
  5686.                 'TB'
  5687.             );
  5688.             $out .= "\nMEMORY USAGE: " . $r->mem . ' bytes (';
  5689.             $i = floor(log($r->mem, 1024));
  5690.             $out .= round($r->mem / pow(1024, $i) , 3) . ' ' . $unit[$i] . ')';
  5691.             $i = floor(log($r->mem_real, 1024));
  5692.             $out .= ' (real ' . round($r->mem_real / pow(1024, $i) , 3) . ' ' . $unit[$i] . ')';
  5693.             if ($r->mem_peak !== null && $r->mem_peak_real !== null)
  5694.             {
  5695.                 $out .= "\nPEAK MEMORY USAGE: " . $r->mem_peak . ' bytes (';
  5696.                 $i = floor(log($r->mem_peak, 1024));
  5697.                 $out .= round($r->mem_peak / pow(1024, $i) , 3) . ' ' . $unit[$i] . ')';
  5698.                 $i = floor(log($r->mem_peak_real, 1024));
  5699.                 $out .= ' (real ' . round($r->mem_peak_real / pow(1024, $i) , 3) . ' ' . $unit[$i] . ')';
  5700.             }
  5701.             return '
  5702. ' . $out . '
  5703. ';
  5704.         }
  5705.         public static function renderJs()
  5706.         {
  5707.             return file_get_contents(KINT_DIR . '/resources/compiled/rich_microtime.js');
  5708.         }
  5709.     }
  5710.     class Kint_Renderer_Rich_Nothing extends Kint_Renderer_Rich_Plugin
  5711.     {
  5712.         public function render($o)
  5713.         {
  5714.             return '
  5715. No argument
  5716. ';
  5717.         }
  5718.     }
  5719.     abstract class Kint_Renderer_Rich_Plugin
  5720.     {
  5721.         protected $renderer;
  5722.         public function __construct(Kint_Renderer_Rich $r)
  5723.         {
  5724.             $this->renderer = $r;
  5725.         }
  5726.         public function renderHeaderLocked(Kint_Object $o, $content)
  5727.         {
  5728.             $header = '
  5729. ';
  5730.             if (Kint_Renderer_Rich::$access_paths && $o->depth > 0 && $ap = $o->getAccessPath())
  5731.             {
  5732.                 $header .= '⇄';
  5733.             }
  5734.             $header .= '→
  5735. ';
  5736.             if (($s = $o->getModifiers()) !== null)
  5737.             {
  5738.                 $header .= '' . $s . ' ';
  5739.             }
  5740.             if (($s = $o->getName()) !== null)
  5741.             {
  5742.                 $header .= '' . $this
  5743.                     ->renderer
  5744.                     ->escape($s) . ' ';
  5745.                 if ($s = $o->getOperator())
  5746.                 {
  5747.                     $header .= $this
  5748.                         ->renderer
  5749.                         ->escape($s, 'ASCII') . ' ';
  5750.                 }
  5751.             }
  5752.             if (($s = $o->getType()) !== null)
  5753.             {
  5754.                 $s = $this
  5755.                     ->renderer
  5756.                     ->escape($s);
  5757.                 if ($o->reference)
  5758.                 {
  5759.                     $s = '&' . $s;
  5760.                 }
  5761.                 $header .= '' . $s . ' ';
  5762.             }
  5763.             if (($s = $o->getSize()) !== null)
  5764.             {
  5765.                 $header .= '(' . $this
  5766.                     ->renderer
  5767.                     ->escape($s) . ') ';
  5768.             }
  5769.             $header .= $content;
  5770.             if (!empty($ap))
  5771.             {
  5772.                 $header .= '
  5773. ' . $this
  5774.                     ->renderer
  5775.                     ->escape($ap) . '
  5776. ';
  5777.             }
  5778.             return $header . '
  5779. ';
  5780.         }
  5781.         public static function renderLockedHeader(Kint_Object $o, $content)
  5782.         {
  5783.             static $show_dep = true;
  5784.             if ($show_dep)
  5785.             {
  5786.                 trigger_error('Kint_Renderer_Rich_Plugin::renderLockedHeader() is deprecated and will be removed in Kint 3.0. Use renderHeaderLocked instead.', KINT_PHP53 ? E_USER_DEPRECATED : E_USER_NOTICE);
  5787.                 $show_dep = false;
  5788.             }
  5789.             $header = '
  5790. ';
  5791.             if (Kint_Renderer_Rich::$access_paths && $o->depth > 0 && $ap = $o->getAccessPath())
  5792.             {
  5793.                 $header .= '⇄';
  5794.             }
  5795.             $header .= '→
  5796. ';
  5797.             if (($s = $o->getModifiers()) !== null)
  5798.             {
  5799.                 $header .= '' . $s . ' ';
  5800.             }
  5801.             if (($s = $o->getName()) !== null)
  5802.             {
  5803.                 $header .= '' . Kint_Object_Blob::escape($s) . ' ';
  5804.                 if ($s = $o->getOperator())
  5805.                 {
  5806.                     $header .= Kint_Object_Blob::escape($s, 'ASCII') . ' ';
  5807.                 }
  5808.             }
  5809.             if (($s = $o->getType()) !== null)
  5810.             {
  5811.                 $s = Kint_Object_Blob::escape($s);
  5812.                 if ($o->reference)
  5813.                 {
  5814.                     $s = '&' . $s;
  5815.                 }
  5816.                 $header .= '' . $s . ' ';
  5817.             }
  5818.             if (($s = $o->getSize()) !== null)
  5819.             {
  5820.                 $header .= '(' . Kint_Object_Blob::escape($s) . ') ';
  5821.             }
  5822.             $header .= $content;
  5823.             if (!empty($ap))
  5824.             {
  5825.                 $header .= '
  5826. ' . Kint_Object_Blob::escape($ap) . '
  5827. ';
  5828.             }
  5829.             return $header . '
  5830. ';
  5831.         }
  5832.         abstract public function render($o);
  5833.     }
  5834.     class Kint_Renderer_Rich_Recursion extends Kint_Renderer_Rich_Plugin
  5835.     {
  5836.         public function render($o)
  5837.         {
  5838.             return '
  5839. ' . $this->renderHeaderLocked($o, 'Recursion') . '
  5840. ';
  5841.         }
  5842.     }
  5843.     class Kint_Renderer_Rich_SimpleXMLElement extends Kint_Renderer_Rich_Plugin
  5844.     {
  5845.         public function render($o)
  5846.         {
  5847.             $children = $this
  5848.                 ->renderer
  5849.                 ->renderChildren($o);
  5850.             $header = '';
  5851.             if (($s = $o->getModifiers()) !== null)
  5852.             {
  5853.                 $header .= '' . $s . ' ';
  5854.             }
  5855.             if (($s = $o->getName()) !== null)
  5856.             {
  5857.                 $header .= '' . $this
  5858.                     ->renderer
  5859.                     ->escape($s) . ' ';
  5860.                 if ($s = $o->getOperator())
  5861.                 {
  5862.                     $header .= $this
  5863.                         ->renderer
  5864.                         ->escape($s, 'ASCII') . ' ';
  5865.                 }
  5866.             }
  5867.             if (($s = $o->getType()) !== null)
  5868.             {
  5869.                 $s = $this
  5870.                     ->renderer
  5871.                     ->escape($s);
  5872.                 if ($o->reference)
  5873.                 {
  5874.                     $s = '&' . $s;
  5875.                 }
  5876.                 $header .= '' . $this
  5877.                     ->renderer
  5878.                     ->escape($s) . ' ';
  5879.             }
  5880.             if (($s = $o->getSize()) !== null)
  5881.             {
  5882.                 $header .= '(' . $this
  5883.                     ->renderer
  5884.                     ->escape($s) . ') ';
  5885.             }
  5886.             if ($s === null && $c = $o->getRepresentation('contents'))
  5887.             {
  5888.                 $c = reset($c->contents);
  5889.                 if ($c && ($s = $c->getValueShort()) !== null)
  5890.                 {
  5891.                     if (Kint_Renderer_Rich::$strlen_max && Kint_Object_Blob::strlen($s) > Kint_Renderer_Rich::$strlen_max)
  5892.                     {
  5893.                         $s = substr($s, 0, Kint_Renderer_Rich::$strlen_max) . '...';
  5894.                     }
  5895.                     $header .= $this
  5896.                         ->renderer
  5897.                         ->escape($s);
  5898.                 }
  5899.             }
  5900.             $header = $this
  5901.                 ->renderer
  5902.                 ->renderHeaderWrapper($o, (bool)strlen($children) , $header);
  5903.             return '
  5904. ' . $header . $children . '
  5905. ';
  5906.         }
  5907.     }
  5908.     class Kint_Renderer_Rich_Source extends Kint_Renderer_Rich_Plugin
  5909.     {
  5910.         public function render($r)
  5911.         {
  5912.             if (!($r instanceof Kint_Object_Representation_Source) || empty($r->source))
  5913.             {
  5914.                 return false;
  5915.             }
  5916.             $source = $r->source;
  5917.             foreach ($source as $linenum => $line)
  5918.             {
  5919.                 if (trim($line) || $linenum === $r->line)
  5920.                 {
  5921.                     break;
  5922.                 }
  5923.                 else
  5924.                 {
  5925.                     unset($source[$linenum]);
  5926.                 }
  5927.             }
  5928.             foreach (array_reverse($source, true) as $linenum => $line)
  5929.             {
  5930.                 if (trim($line) || $linenum === $r->line)
  5931.                 {
  5932.                     break;
  5933.                 }
  5934.                 else
  5935.                 {
  5936.                     unset($source[$linenum]);
  5937.                 }
  5938.             }
  5939.             $start = '';
  5940.             $highlight = '';
  5941.             $end = '';
  5942.             foreach ($source as $linenum => $line)
  5943.             {
  5944.                 if ($linenum < $r->line)
  5945.                 {
  5946.                     $start .= $line . "\n";
  5947.                 }
  5948.                 elseif ($linenum === $r->line)
  5949.                 {
  5950.                     $highlight = '
  5951. ' . $this
  5952.                         ->renderer
  5953.                         ->escape($line) . '
  5954. ';
  5955.                 }
  5956.                 else
  5957.                 {
  5958.                     $end .= $line . "\n";
  5959.                 }
  5960.             }
  5961.             $output = $this
  5962.                 ->renderer
  5963.                 ->escape($start) . $highlight . $this
  5964.                 ->renderer
  5965.                 ->escape(substr($end, 0, -1));
  5966.             if ($output)
  5967.             {
  5968.                 reset($source);
  5969.                 return '
  5970. ' . $output . '
  5971. ';
  5972.             }
  5973.         }
  5974.     }
  5975.     class Kint_Renderer_Rich_Table extends Kint_Renderer_Rich_Plugin
  5976.     {
  5977.         public static $respect_str_length = true;
  5978.         public function render($r)
  5979.         {
  5980.             $out = '
  5981. ';
  5982.             $firstrow = reset($r->contents);
  5983.             foreach ($firstrow
  5984.                 ->value->contents as $field)
  5985.             {
  5986.                 $out .= '';
  5987.             }
  5988.             $out .= '';
  5989.             foreach ($r->contents as $row)
  5990.             {
  5991.                 $out .= '';
  5992.                 foreach ($row
  5993.                     ->value->contents as $field)
  5994.                 {
  5995.                     $out .= 'getType()) !== null) { $type = $this->renderer->escape($s); if ($field->reference) { $ref = ' & '; $type = $ref.$type; } if (($s = $field->getSize()) !== null) { $size .= '('.$this->renderer->escape($s).') '; } } if ($type) { $out .= 'title = "'.$type.$size.'"'; } $out .= ' > '; switch ($field->type) { case 'boolean': $out .= $field->value->contents ? ''.$ref.'true' : ''.$ref.'false'; break; case 'integer': case 'double': $out .= (string) $field->value->contents; break; case 'null': $out .= ''.$ref.'null'; break; case 'string': $val = $field->value->contents; if (Kint_Renderer_Rich::$strlen_max && self::$respect_str_length && Kint_Object_Blob::strlen($val) > Kint_Renderer_Rich::$strlen_max) { $val = substr($val, 0, Kint_Renderer_Rich::$strlen_max).'...'; } $out .= $this->renderer->escape($val); break; case 'array ': $out .= ''.$ref.'array '.$size; break; case 'object': $out .= ''.$ref.$this->renderer->escape($field->classname).''.$size; break; case 'resource': $out .= ''.$ref.'resource'; break; default: $out .= ''.$ref.'unknown'; break; } if (in_array('blacklist', $field->hints)) { $out .= 'Blacklisted'; } elseif (in_array('recursion', $field->hints)) { $out .= 'Recursion'; } elseif (in_array('depth_limit', $field->hints)) { $out .= 'DepthLimit'; } $out .= ''; } $out .= ''; } $out .= ''.$this->renderer->escape($field->name).''; $out .= $this->renderer->escape($row->name); $out .= ''; return $out; } } class Kint_Renderer_Rich_Timestamp extends Kint_Renderer_Rich_Plugin { public function render($r) { return ''.@date('Y - m - dH:
  5996.                         i:
  5997.                             s', $r->contents).''; } } class Kint_Renderer_Rich_TraceFrame extends Kint_Renderer_Rich_Plugin { public function render($o) { $children = $this->renderer->renderChildren($o); if (!($o instanceof Kint_Object_TraceFrame)) { $header = $this->renderer->renderHeader($o); } else { if (!empty($o->trace['file']) && !empty($o->trace['line'])) { $header = ''.$this->renderer->escape(Kint::shortenPath($o->trace['file'])).':
  5998.                                 '.(int) $o->trace['line'].''; } else { $header = 'PHPinternalcall'; } if ($o->trace['class ']) { $header .= $this->renderer->escape($o->trace['class '].$o->trace['type']); } if (is_string($o->trace['function '])) { $function = $this->renderer->escape($o->trace['function '].'() '); } else { $function = $this->renderer->escape($o->trace['function ']->getName().'('.$o->trace['function ']->getParams().') '); if (($url = $o->trace['function ']->getPhpDocUrl()) !== null) { $function = ''.$function.''; } } $header .= ''.$function.''; } $header = $this->renderer->renderHeaderWrapper($o, (bool) strlen($children), $header); return ''.$header.$children.''; } } class Kint_Renderer_Text_Blacklist extends Kint_Renderer_Text_Plugin { public function render($o) { $out = ''; if ($o->depth == 0) { $out .= $this->renderer->colorTitle($this->renderer->renderTitle($o)).PHP_EOL; } $out .= $this->renderer->renderHeader($o).''.$this->renderer->colorValue('BLACKLISTED').PHP_EOL; return $out; } } class Kint_Renderer_Text_DepthLimit extends Kint_Renderer_Text_Plugin { public function render($o) { $out = ''; if ($o->depth == 0) { $out .= $this->renderer->colorTitle($this->renderer->renderTitle($o)).PHP_EOL; } $out .= $this->renderer->renderHeader($o).''.$this->renderer->colorValue('DEPTHLIMIT').PHP_EOL; return $out; } } class Kint_Renderer_Text_Nothing extends Kint_Renderer_Text_Plugin { public function render($o) { if (Kint_Renderer_Text::$decorations) { return $this->renderer->colorTitle($this->renderer->boxText('Noargument', $this->renderer->header_width)).PHP_EOL; } else { return $this->renderer->colorTitle('Noargument').PHP_EOL; } } } abstract class Kint_Renderer_Text_Plugin { protected $renderer; public function __construct(Kint_Renderer_Text $r) { $this->renderer = $r; } abstract public function render($o); } class Kint_Renderer_Text_Recursion extends Kint_Renderer_Text_Plugin { public function render($o) { $out = ''; if ($o->depth == 0) { $out .= $this->renderer->colorTitle($this->renderer->renderTitle($o)).PHP_EOL; } $out .= $this->renderer->renderHeader($o).''.$this->renderer->colorValue('RECURSION').PHP_EOL; return $out; } } class Kint_Renderer_Text_Trace extends Kint_Renderer_Text_Plugin { public function render($o) { $out = ''; if ($o->depth == 0) { $out .= $this->renderer->colorTitle($this->renderer->renderTitle($o)).PHP_EOL; } $out .= $this->renderer->renderHeader($o).':
  5999.                                     '.PHP_EOL; $indent = str_repeat('', ($o->depth + 1) * $this->renderer->indent_width); $i = 1; foreach ($o->value->contents as $frame) { $framedesc = $indent.str_pad($i.':
  6000.                                         ', 4, ''); if ($frame->trace['file']) { $framedesc .= $this->renderer->ideLink($frame->trace['file'], $frame->trace['line']).PHP_EOL; } else { $framedesc .= 'PHPinternalcall'.PHP_EOL; } $framedesc .= $indent.''; if ($frame->trace['class ']) { $framedesc .= $this->renderer->escape($frame->trace['class ']); if ($frame->trace['object']) { $framedesc .= $this->renderer->escape('->'); } else { $framedesc .= '::'; } } if (is_string($frame->trace['function '])) { $framedesc .= $this->renderer->escape($frame->trace['function ']).'(...) '; } elseif ($frame->trace['function '] instanceof Kint_Object_Method) { $framedesc .= $this->renderer->escape($frame->trace['function ']->getName()); $framedesc .= '('.$this->renderer->escape($frame->trace['function ']->getParams()).') '; } $out .= $this->renderer->colorType($framedesc).PHP_EOL.PHP_EOL; if ($source = $frame->getRepresentation('source')) { $line_wanted = $source->line; $source = $source->source; foreach ($source as $linenum => $line) { if (trim($line) || $linenum === $line_wanted) { break; } else { unset($source[$linenum]); } } foreach (array_reverse($source, true) as $linenum => $line) { if (trim($line) || $linenum === $line_wanted) { break; } else { unset($source[$linenum]); } } foreach ($source as $lineno => $line) { if ($lineno == $line_wanted) { $out .= $indent.$this->renderer->colorValue($this->renderer->escape($line)).PHP_EOL; } else { $out .= $indent.$this->renderer->escape($line).PHP_EOL; } } } ++$i; } return $out; } } Kint::$file_link_format = ini_get('xdebug . file_link_format'); if (isset($_SERVER['DOCUMENT_ROOT'])) { Kint::$app_root_dirs = array( $_SERVER['DOCUMENT_ROOT'] => '', realpath($_SERVER['DOCUMENT_ROOT']) => '', ); } if (!function_exists('d')) { function d() { $args = func_get_args(); return call_user_func_array(array('Kint', 'dump'), $args); } Kint::$aliases[] = 'd'; } if (!function_exists('s')) { function s() { if (!Kint::$enabled_mode) { return 0; } $stash = Kint::settings(); if (Kint::$enabled_mode !== Kint::MODE_TEXT) { Kint::$enabled_mode = Kint::MODE_PLAIN; if (PHP_SAPI === 'cli' && Kint::$cli_detection === true) { Kint::$enabled_mode = Kint::$mode_default_cli; } } $args = func_get_args(); $out = call_user_func_array(array('Kint', 'dump'), $args); Kint::settings($stash); return $out; } Kint::$aliases[] = 's'; } Kint_Renderer_Rich::$pre_render_sources['script'] = array ( 0 => 'void0 === window . kintRich && (window . kintRich = function ()
  6001.                                         {
  6002.                                             "use strict";
  6003.                                             var e =
  6004.                                             {
  6005.                                                 selectText:
  6006.                                                     function (e)
  6007.                                                     {
  6008.                                                         var t = window . getSelection() , a = document . createRange();
  6009.                                                         a . selectNodeContents(e . lastChild) , a . setStart(e . firstChild, 0) , t . removeAllRanges() , t . addRange(a)
  6010.                                                     }
  6011.                                                     , each:
  6012.                                                         function (e, t)
  6013.                                                         {
  6014.                                                             Array . prototype . slice . call(document . querySelectorAll(e) , 0) . foreach (t)
  6015.                                                         }
  6016.                                                         , hasClass:
  6017.                                                             function (e, t)
  6018.                                                             {
  6019.                                                                 return !!e . classList && (void0 === t && (t = "kint-show") , e . classList . contains(t))
  6020.                                                             }
  6021.                                                             , addClass:
  6022.                                                                 function (e, t)
  6023.                                                                 {
  6024.                                                                     void0 === t && (t = "kint-show") , e . classList . add(t)
  6025.                                                                 }
  6026.                                                                 , removeClass:
  6027.                                                                     function (e, t)
  6028.                                                                     {
  6029.                                                                         return void0 === t && (t = "kint-show") , e . classList . remove(t) , e
  6030.                                                                     }
  6031.                                                                     , toggle:
  6032.                                                                         function (t, a)
  6033.                                                                         {
  6034.                                                                             var o = e . getChildren(t);
  6035.                                                                             o && (void0 === a && (a = e . hasClass(t)) , a ? e . removeClass(t) : e . addClass(t) , 1 === o . childNodes . length && (o = o . childNodes[0] . childNodes[0]) && e . hasClass(o, "kint-parent") && e . toggle(o, a))
  6036.                                                                         }
  6037.                                                                         , toggleChildren:
  6038.                                                                             function (t, a)
  6039.                                                                             {
  6040.                                                                                 var o = e . getChildren(t);
  6041.                                                                                 if (o)
  6042.                                                                                 {
  6043.                                                                                     var r = o . getElementsByClassName("kint-parent") , s = r . length;
  6044.                                                                                     for (void0 === a && (a = !e . hasClass(t));s--;) e . toggle(r[s], a)
  6045.                                                                                 }
  6046.                                                                             }
  6047.                                                                             , toggleAll:
  6048.                                                                                 function (t)
  6049.                                                                                 {
  6050.                                                                                     for (var a = document . getElementsByClassName("kint-parent") , o = a . length, r = !e . hasClass(t . parentNode);o--;) e . toggle(a[o], r)
  6051.                                                                                 }
  6052.                                                                                 , switchTab:
  6053.                                                                                     function (t)
  6054.                                                                                     {
  6055.                                                                                         var a, o = t . previousSibling, r = 0;
  6056.                                                                                         for (t . parentNode . getElementsByClassName("kint-active-tab") [0] . className = "", t . className = "kint-active-tab";o;) 1 === o . nodeType && r++, o = o . previousSibling;
  6057.                                                                                         a = t . parentNode . nextSibling . childNodes;
  6058.                                                                                         for (var s = 0;s"},openInNewWindow:function(t){var a=window.open();a&&(a.document.open(),a.document.write(e.mktag("html")+e.mktag("head")+e.mktag("title")+"Kint("+(new Date).toISOString()+") "+e.mktag(" / title")+e.mktag(\'meta charset="utf - 8"\')+document.getElementsByClassName("kint - script")[0].outerHTML+document.getElementsByClassName("kint - style")[0].outerHTML+e.mktag(" / head")+e.mktag("body")+\'
  6059. Take some notes!
  6060. \'+t.parentNode.outerHTML+""+e.mktag(" / body")),a.document.close())},sortTable:function(e,t){var a=e.tBodies[0];[].slice.call(e.tBodies[0].rows).sort(function(e,a){if(e=e.cells[t].textContent.trim().toLocaleLowerCase(),a=a.cells[t].textContent.trim().toLocaleLowerCase(),isNaN(e)||isNaN(a)){if(isNaN(e)&&!isNaN(a))return 1;if(isNaN(a)&&!isNaN(e))return-1}else e=parseFloat(e),a=parseFloat(a);return ea?1:0}).forEach(function(e){a.appendChild(e)})},showAccessPath:function(t){for(var a=t.childNodes,o=0;oli:not(.kint-active-tab)", function (t)
  6061.                                                                                         {
  6062.                                                                                             0 === t . offsetWidth && 0 === t . offsetHeight || e . keyboardNav . targets . push(t)
  6063.                                                                                         })
  6064.                                                                                     }
  6065.                                                                                     , sync:
  6066.                                                                                         function (t)
  6067.                                                                                         {
  6068.                                                                                             var a = document . querySelector(".kint-focused");
  6069.                                                                                             if (a && e . removeClass(a, "kint-focused") , e . keyboardNav . active)
  6070.                                                                                             {
  6071.                                                                                                 var o = e . keyboardNav . targets[e . keyboardNav . target];
  6072.                                                                                                 e . addClass(o, "kint-focused") , t || e . keyboardNav . scroll(o)
  6073.                                                                                             }
  6074.                                                                                         }
  6075.                                                                                         , scroll:
  6076.                                                                                             function (e)
  6077.                                                                                             {
  6078.                                                                                                 var t = function (e)
  6079.                                                                                                 {
  6080.                                                                                                     return e . offsetTop + (e . offsetParent ? t(e . offsetParent) : 0)
  6081.                                                                                                 }
  6082.                                                                                                 , a = t(e) - window . innerHeight / 2;
  6083.                                                                                                 window . scrollTo(0, a)
  6084.                                                                                             }
  6085.                                                                                             , moveCursor:
  6086.                                                                                                 function (t)
  6087.                                                                                                 {
  6088.                                                                                                     for (e . keyboardNav . target += t;e . keyboardNav . target < 0;) e . keyboardNav . target += e . keyboardNav . targets . length;
  6089.                                                                                                     for (;e . keyboardNav . target >= e . keyboardNav . targets . length;) e . keyboardNav . target -= e . keyboardNav . targets . length;
  6090.                                                                                                     e . keyboardNav . sync()
  6091.                                                                                                 }
  6092.                                                                                                 , setCursor:
  6093.                                                                                                     function (t)
  6094.                                                                                                     {
  6095.                                                                                                         e . keyboardNav . fetchTargets();
  6096.                                                                                                         for (var a = 0;ar) && (i[e] . min = r) , (void0 === i[e] . max || i[e] . max . kint - microtime - lap"),0),t.forEach(function(t){var e,r=t.parentNode.getAttribute("data - kint - microtime - group"),o=parseFloat(t.innerHTML),a=i[r].avg,n=i[r].max,c=i[r].min;t.parentNode.querySelector(" . kint - microtime - avg").innerHTML=a,o===a&&o===c&&o===n||(o>a?(e=(o-a)/(n-a),t.style.background="hsl("+(40-40*e)+", 100 % , 65 %) "):(e=a===c?0:(a-o)/(a-c),t.style.background="hsl("+(40+80*e)+", 100 % , 65 %) "))})})); ', ); Kint_Renderer_Plain::$pre_render_sources['style'] = array ( 0 => '.kint-plain{background:rgba(255,255,255,0.9);white-space:pre;display:block;font-family:monospace}.kint-plain i{color:#d00;font-style:normal}.kint-plain u{color:#030;text-decoration:none;font-weight:bold} ', ); Kint_Renderer_Rich::$pre_render_sources['style'] = array ( 0 => '.kint-rich{font-size:13px;overflow-x:auto;white-space:nowrap;background:rgba(255,255,255,0.9)}.kint-rich::selection,.kint-rich::-moz-selection,.kint-rich::-webkit-selection{background:#aaa;color:#1d1e1e}.kint-rich .kint-focused{box-shadow:0 0 3px 2px red}.kint-rich,.kint-rich::before,.kint-rich::after,.kint-rich *,.kint-rich *::before,.kint-rich *::after{box-sizing:border-box;border-radius:0;color:#1d1e1e;float:none !important;font-family:Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;line-height:15px;margin:0;padding:0;text-align:left}.kint-rich{margin:8px 0}.kint-rich dt,.kint-rich dl{width:auto}.kint-rich dt,.kint-rich div.access-path{background:#f8f8f8;border:1px solid #d7d7d7;color:#1d1e1e;display:block;font-weight:bold;list-style:none outside none;overflow:auto;padding:4px}.kint-rich dt:hover,.kint-rich div.access-path:hover{border-color:#aaa}.kint-rich li>dl>dt>.kint-popup-trigger,.kint-rich li>dl>dt>.kint-access-path-trigger{background:rgba(248,248,248,0.8)}.kint-rich>dl dl{padding:0 0 0 12px}.kint-rich dt.kint-parent>nav,.kint-rich>footer>nav{background:url(\'data:image/svg+xml;utf8,\') no-repeat scroll 0 0/100% auto transparent;cursor:pointer;display:inline-block;height:15px;width:15px;margin-right:3px;vertical-align:middle}.kint-rich dt.kint-parent:hover>nav,.kint-rich>footer>nav:hover{background-position:0 25%}.kint-rich dt.kint-parent.kint-show>nav,.kint-rich>footer.kint-show>nav{background-position:0 50%}.kint-rich dt.kint-parent.kint-show:hover>nav,.kint-rich>footer.kint-show>nav:hover{background-position:0 75%}.kint-rich>footer>nav,.kint-rich dt.kint-parent>nav{background:url(\'data:image/svg+xml;utf8,\') no-repeat scroll 0 0/100% auto transparent;cursor:pointer;display:inline-block;height:15px;width:15px;margin-right:3px;vertical-align:middle}.kint-rich>footer.kint-locked>nav,.kint-rich dt.kint-parent.kint-locked>nav{background-position:0 100%}.kint-rich dt.kint-parent+dd{display:none;border-left:1px dashed #d7d7d7}.kint-rich dt.kint-parent.kint-show+dd{display:block}.kint-rich var,.kint-rich var a{color:#06f;font-style:normal}.kint-rich dt:hover var,.kint-rich dt:hover var a{color:red}.kint-rich dfn{font-style:normal;font-family:monospace;color:#1d1e1e}.kint-rich pre{color:#1d1e1e;margin:0 0 0 12px;padding:5px;overflow-y:hidden;border-top:0;border:1px solid #d7d7d7;background:#f8f8f8;display:block;word-break:normal}.kint-rich .kint-popup-trigger,.kint-rich .kint-access-path-trigger{float:right !important;cursor:pointer;padding:0 3px;color:#aaa;position:relative}.kint-rich .kint-popup-trigger:hover,.kint-rich .kint-access-path-trigger:hover{color:#d7d7d7}.kint-rich dt.kint-parent>.kint-popup-trigger{font-size:13px}.kint-rich div.access-path{background:#f8f8f8;display:none;margin-top:5px;padding:4px;white-space:pre}.kint-rich div.access-path.kint-show{display:block}.kint-rich footer{padding:0 3px 3px;font-size:9px}.kint-rich footer>.kint-popup-trigger{font-size:12px}.kint-rich footer nav{height:10px;width:10px}.kint-rich footer>ol{display:none;margin-left:32px}.kint-rich footer.kint-show>ol{display:block}.kint-rich a{color:#1d1e1e;text-shadow:none;text-decoration:underline}.kint-rich a:hover{color:#1d1e1e;border-bottom:1px dotted #1d1e1e}.kint-rich ul{list-style:none;padding-left:12px}.kint-rich ul:not(.kint-tabs) li{border-left:1px dashed #d7d7d7}.kint-rich ul:not(.kint-tabs) li>dl{border-left:none}.kint-rich ul.kint-tabs{margin:0 0 0 12px;padding-left:0;background:#f8f8f8;border:1px solid #d7d7d7;border-top:0}.kint-rich ul.kint-tabs>li{background:#f8f8f8;border:1px solid #d7d7d7;cursor:pointer;display:inline-block;height:24px;margin:2px;padding:0 12px;vertical-align:top}.kint-rich ul.kint-tabs>li:hover,.kint-rich ul.kint-tabs>li.kint-active-tab:hover{border-color:#aaa;color:red}.kint-rich ul.kint-tabs>li.kint-active-tab{background:#f8f8f8;border-top:0;margin-top:-1px;height:27px;line-height:24px}.kint-rich ul.kint-tabs>li:not(.kint-active-tab){line-height:20px}.kint-rich ul.kint-tabs li+li{margin-left:0}.kint-rich ul:not(.kint-tabs)>li:not(:first-child){display:none}.kint-rich dt:hover+dd>ul>li.kint-active-tab{border-color:#aaa;color:red}.kint-rich dt>.kint-color-preview{width:16px;height:16px;display:inline-block;vertical-align:middle;margin-left:10px;border:1px solid #d7d7d7;background-color:#ccc;background-image:url(\'data:image/svg+xml;utf8,\');background-size:100%}.kint-rich dt>.kint-color-preview:hover{border-color:#aaa}.kint-rich dt>.kint-color-preview>div{width:100%;height:100%}.kint-rich table{border-collapse:collapse;empty-cells:show;border-spacing:0}.kint-rich table *{font-size:12px}.kint-rich table dt{background:none;padding:2px}.kint-rich table dt .kint-parent{min-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.kint-rich table td,.kint-rich table th{border:1px solid #d7d7d7;padding:2px;vertical-align:center}.kint-rich table th{cursor:alias}.kint-rich table td:first-child,.kint-rich table th{font-weight:bold;background:#f8f8f8;color:#1d1e1e}.kint-rich table td{background:#f8f8f8;white-space:pre}.kint-rich table td>dl{padding:0}.kint-rich table pre{border-top:0;border-right:0}.kint-rich table thead th:first-child{background:none;border:0}.kint-rich table tr:hover>td{box-shadow:0 0 1px 0 #aaa inset}.kint-rich table tr:hover var{color:red}.kint-rich table ul.kint-tabs li.kint-active-tab{height:20px;line-height:17px}.kint-rich pre.kint-source{margin-left:-1px}.kint-rich pre.kint-source:before{display:block;content:attr(data-kint-sourcerange);margin-bottom:0.5em;padding-bottom:0.5em;border-bottom:1px solid #f8f8f8}.kint-rich pre.kint-source>div.kint-highlight{background:#f8f8f8}.kint-rich .kint-microtime-lap{box-shadow:0 0 2px 0 #b6cedb;height:16px;text-align:center;text-shadow:-1px 0 #839496, 0 1px #839496, 1px 0 #839496, 0 -1px #839496;width:230px;color:#fdf6e3}.kint-rich .kint-focused{box-shadow:0 0 3px 2px red}.kint-rich dt{font-weight:normal}.kint-rich dt.kint-parent{margin-top:4px}.kint-rich dl dl{margin-top:4px;padding-left:25px;border-left:none}.kint-rich>dl>dt{background:#f8f8f8}.kint-rich ul{margin:0;padding-left:0}.kint-rich ul:not(.kint-tabs)>li{border-left:0}.kint-rich ul.kint-tabs{background:#f8f8f8;border:1px solid #d7d7d7;border-width:0 1px 1px 1px;padding:4px 0 0 12px;margin-left:-1px;margin-top:-1px}.kint-rich ul.kint-tabs li,.kint-rich ul.kint-tabs li+li{margin:0 0 0 4px}.kint-rich ul.kint-tabs li{border-bottom-width:0;height:25px}.kint-rich ul.kint-tabs li:first-child{margin-left:0}.kint-rich ul.kint-tabs li.kint-active-tab{border-top:1px solid #d7d7d7;background:#fff;font-weight:bold;padding-top:0;border-bottom:1px solid #fff !important;margin-bottom:-1px}.kint-rich ul.kint-tabs li.kint-active-tab:hover{border-bottom:1px solid #fff}.kint-rich ul>li>pre{border:1px solid #d7d7d7}.kint-rich dt:hover+dd>ul{border-color:#aaa}.kint-rich pre{background:#fff;margin-top:4px;margin-left:25px}.kint-rich .kint-popup-trigger:hover{color:red}.kint-rich .kint-source{margin-left:-1px}.kint-rich .kint-source .kint-highlight{background:#cfc}.kint-rich table td{background:#fff}.kint-rich table td>dl{padding:0;margin:0}.kint-rich table td>dl>dt.kint-parent{margin:0}.kint-rich table td:first-child,.kint-rich table td,.kint-rich table th{padding:2px 4px}.kint-rich table dd,.kint-rich table dt{background:#fff}.kint-rich table tr:hover>td{box-shadow:none;background:#cfc} ', );
Add Comment
Please, Sign In to add comment