'Kint\\Renderer\\Rich\\BlacklistPlugin', 'callable' => 'Kint\\Renderer\\Rich\\CallablePlugin', 'closure' => 'Kint\\Renderer\\Rich\\ClosurePlugin', 'color' => 'Kint\\Renderer\\Rich\\ColorPlugin', 'depth_limit' => 'Kint\\Renderer\\Rich\\DepthLimitPlugin', 'recursion' => 'Kint\\Renderer\\Rich\\RecursionPlugin', 'simplexml_element' => 'Kint\\Renderer\\Rich\\SimpleXMLElementPlugin', 'trace_frame' => 'Kint\\Renderer\\Rich\\TraceFramePlugin', ); /** * RichRenderer tab plugins should implement Kint\Renderer\Rich\TabPluginInterface. */ public static $tab_plugins = array( 'binary' => 'Kint\\Renderer\\Rich\\BinaryPlugin', 'color' => 'Kint\\Renderer\\Rich\\ColorPlugin', 'docstring' => 'Kint\\Renderer\\Rich\\DocstringPlugin', 'microtime' => 'Kint\\Renderer\\Rich\\MicrotimePlugin', 'source' => 'Kint\\Renderer\\Rich\\SourcePlugin', 'table' => 'Kint\\Renderer\\Rich\\TablePlugin', 'timestamp' => 'Kint\\Renderer\\Rich\\TimestampPlugin', ); public static $pre_render_sources = array( 'script' => array( array('Kint\\Renderer\\RichRenderer', 'renderJs'), array('Kint\\Renderer\\Rich\\MicrotimePlugin', 'renderJs'), ), 'style' => array( array('Kint\\Renderer\\RichRenderer', 'renderCss'), ), 'raw' => array(), ); /** * Whether or not to render access paths. * * Access paths can become incredibly heavy with very deep and wide * structures. Given mostly public variables it will typically make * up one quarter of the output HTML size. * * If this is an unacceptably large amount and your browser is groaning * under the weight of the access paths - your first order of buisiness * should be to get a new browser. Failing that, use this to turn them off. * * @var bool */ public static $access_paths = true; /** * The maximum length of a string before it is truncated. * * Falsey to disable * * @var int */ public static $strlen_max = 80; /** * Path to the CSS file to load by default. * * @var string */ public static $theme = 'original.css'; /** * Assume types and sizes don't need to be escaped. * * Turn this off if you use anything but ascii in your class names, * but it'll cause a slowdown of around 10% * * @var bool */ public static $escape_types = false; /** * Move all dumps to a folder at the bottom of the body. * * @var bool */ public static $folder = true; /** * Sort mode for object properties. * * @var int */ public static $sort = self::SORT_NONE; public static $needs_pre_render = true; public static $needs_folder_render = true; public static $always_pre_render = false; protected $plugin_objs = array(); protected $expand = false; protected $force_pre_render = false; protected $pre_render; protected $use_folder; public function __construct() { $this->pre_render = self::$needs_pre_render; $this->use_folder = self::$folder; if (self::$always_pre_render) { $this->setForcePreRender(); } } public function setCallInfo(array $info) { parent::setCallInfo($info); if (\in_array('!', $this->call_info['modifiers'], true)) { $this->setExpand(true); $this->use_folder = false; } if (\in_array('@', $this->call_info['modifiers'], true)) { $this->setForcePreRender(); } } public function setStatics(array $statics) { parent::setStatics($statics); if (!empty($statics['expanded'])) { $this->setExpand(true); } if (!empty($statics['return'])) { $this->setForcePreRender(); } } public function setExpand($expand) { $this->expand = $expand; } public function getExpand() { return $this->expand; } public function setForcePreRender() { $this->force_pre_render = true; $this->pre_render = true; } public function setPreRender($pre_render) { $this->setForcePreRender(); // TODO: Remove line in next major version $this->pre_render = $pre_render; } public function getPreRender() { return $this->pre_render; } public function setUseFolder($use_folder) { $this->use_folder = $use_folder; } public function getUseFolder() { return $this->use_folder; } public function render(BasicObject $o) { if ($plugin = $this->getPlugin(self::$object_plugins, $o->hints)) { if (\strlen($output = $plugin->renderObject($o))) { return $output; } } $children = $this->renderChildren($o); $header = $this->renderHeaderWrapper($o, (bool) \strlen($children), $this->renderHeader($o)); return '
'.$header.$children.'
'; } public function renderNothing() { return '
No argument
'; } public function renderHeaderWrapper(BasicObject $o, $has_children, $contents) { $out = 'expand) { $out .= ' kint-show'; } $out .= '"'; } $out .= '>'; if (self::$access_paths && $o->depth > 0 && $ap = $o->getAccessPath()) { $out .= ''; } if ($has_children) { $out .= ''; if (0 === $o->depth) { $out .= ''; $out .= ''; } $out .= ''; } $out .= $contents; if (!empty($ap)) { $out .= '
'.$this->escape($ap).'
'; } return $out.''; } public function renderHeader(BasicObject $o) { $output = ''; if (null !== ($s = $o->getModifiers())) { $output .= ''.$s.' '; } if (null !== ($s = $o->getName())) { $output .= ''.$this->escape($s).' '; if ($s = $o->getOperator()) { $output .= $this->escape($s, 'ASCII').' '; } } if (null !== ($s = $o->getType())) { if (self::$escape_types) { $s = $this->escape($s); } if ($o->reference) { $s = '&'.$s; } $output .= ''.$s.' '; } if (null !== ($s = $o->getSize())) { if (self::$escape_types) { $s = $this->escape($s); } $output .= '('.$s.') '; } if (null !== ($s = $o->getValueShort())) { $s = \preg_replace('/\\s+/', ' ', $s); if (self::$strlen_max) { $s = Utils::truncateString($s, self::$strlen_max); } $output .= $this->escape($s); } return \trim($output); } public function renderChildren(BasicObject $o) { $contents = array(); $tabs = array(); foreach ($o->getRepresentations() as $rep) { $result = $this->renderTab($o, $rep); if (\strlen($result)) { $contents[] = $result; $tabs[] = $rep; } } if (empty($tabs)) { return ''; } $output = '
'; if (1 === \count($tabs) && $tabs[0]->labelIsImplicit()) { $output .= \reset($contents); } else { $output .= ''; } return $output.'
'; } public function preRender() { $output = ''; if ($this->pre_render) { foreach (self::$pre_render_sources as $type => $values) { $contents = ''; foreach ($values as $v) { $contents .= \call_user_func($v, $this); } if (!\strlen($contents)) { continue; } switch ($type) { case 'script': $output .= ''; break; case 'style': $output .= ''; break; default: $output .= $contents; } } // Don't pre-render on every dump if (!$this->force_pre_render) { self::$needs_pre_render = false; } } $output .= '
'; return $output; } public function postRender() { if (!$this->show_trace) { return '
'; } $output = ''; return $output; } public function escape($string, $encoding = false) { if (false === $encoding) { $encoding = BlobObject::detectEncoding($string); } $original_encoding = $encoding; if (false === $encoding || 'ASCII' === $encoding) { $encoding = 'UTF-8'; } $string = \htmlspecialchars($string, ENT_NOQUOTES, $encoding); // this call converts all non-ASCII characters into numeirc htmlentities if (\function_exists('mb_encode_numericentity') && 'ASCII' !== $original_encoding) { $string = \mb_encode_numericentity($string, array(0x80, 0xffff, 0, 0xffff), $encoding); } return $string; } public function ideLink($file, $line) { $path = $this->escape(Kint::shortenPath($file)).':'.$line; $ideLink = Kint::getIdeLink($file, $line); if (!$ideLink) { return $path; } $class = ''; if (\preg_match('/https?:\\/\\//i', $ideLink)) { $class = 'class="kint-ide-link" '; } return ''.$path.''; } protected function renderTab(BasicObject $o, Representation $rep) { if ($plugin = $this->getPlugin(self::$tab_plugins, $rep->hints)) { if (\strlen($output = $plugin->renderTab($rep))) { return $output; } } if (\is_array($rep->contents)) { $output = ''; if ($o instanceof InstanceObject && 'properties' === $rep->getName()) { foreach (self::sortProperties($rep->contents, self::$sort) as $obj) { $output .= $this->render($obj); } } else { foreach ($rep->contents as $obj) { $output .= $this->render($obj); } } return $output; } if (\is_string($rep->contents)) { $show_contents = false; // If it is the value representation of a string and its whitespace // was truncated in the header, always display the full string if ('string' !== $o->type || $o->value !== $rep) { $show_contents = true; } else { if (\preg_match('/(:?[\\r\\n\\t\\f\\v]| {2})/', $rep->contents)) { $show_contents = true; } elseif (self::$strlen_max && BlobObject::strlen($o->getValueShort()) > self::$strlen_max) { $show_contents = true; } if (empty($o->encoding)) { $show_contents = false; } } if ($show_contents) { return '
'.$this->escape($rep->contents)."\n
"; } } if ($rep->contents instanceof BasicObject) { return $this->render($rep->contents); } } protected function getPlugin(array $plugins, array $hints) { if ($plugins = $this->matchPlugins($plugins, $hints)) { $plugin = \end($plugins); if (!isset($this->plugin_objs[$plugin])) { $this->plugin_objs[$plugin] = new $plugin($this); } return $this->plugin_objs[$plugin]; } } protected static function renderJs() { return \file_get_contents(KINT_DIR.'/resources/compiled/shared.js').\file_get_contents(KINT_DIR.'/resources/compiled/rich.js'); } protected static function renderCss() { if (\file_exists(KINT_DIR.'/resources/compiled/'.self::$theme)) { return \file_get_contents(KINT_DIR.'/resources/compiled/'.self::$theme); } return \file_get_contents(self::$theme); } protected static function renderFolder() { return '
Kint
'; } }