[] */ public static array $value_plugins = [ 'array_limit' => Rich\LockPlugin::class, 'blacklist' => Rich\LockPlugin::class, 'callable' => Rich\CallablePlugin::class, 'color' => Rich\ColorPlugin::class, 'depth_limit' => Rich\LockPlugin::class, 'recursion' => Rich\LockPlugin::class, 'trace_frame' => Rich\TraceFramePlugin::class, ]; /** * RichRenderer tab plugins should implement TabPluginInterface. * * @psalm-var array> */ public static array $tab_plugins = [ 'binary' => Rich\BinaryPlugin::class, 'callable' => Rich\CallableDefinitionPlugin::class, 'color' => Rich\ColorPlugin::class, 'microtime' => Rich\MicrotimePlugin::class, 'profiling' => Rich\ProfilePlugin::class, 'source' => Rich\SourcePlugin::class, 'table' => Rich\TablePlugin::class, ]; public static array $pre_render_sources = [ 'script' => [ [self::class, 'renderJs'], ], 'style' => [ [self::class, 'renderCss'], ], 'raw' => [], ]; /** * The maximum length of a string before it is truncated. * * Falsey to disable */ public static int $strlen_max = 80; /** * Timestamp to print in footer in date() format. */ public static ?string $timestamp = null; /** * 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. */ public static bool $access_paths = true; /** * 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% */ public static bool $escape_types = false; /** * Move all dumps to a folder at the bottom of the body. */ public static bool $folder = false; public static bool $needs_pre_render = true; public static bool $always_pre_render = false; protected array $plugin_objs = []; protected bool $expand = false; protected bool $force_pre_render = false; protected bool $use_folder = false; public function __construct() { parent::__construct(); self::$theme ??= 'original.css'; $this->use_folder = self::$folder; $this->force_pre_render = self::$always_pre_render; } public function setCallInfo(array $info): void { parent::setCallInfo($info); if (\in_array('!', $info['modifiers'], true)) { $this->expand = true; $this->use_folder = false; } if (\in_array('@', $info['modifiers'], true)) { $this->force_pre_render = true; } } public function setStatics(array $statics): void { parent::setStatics($statics); if (!empty($statics['expanded'])) { $this->expand = true; } if (!empty($statics['return'])) { $this->force_pre_render = true; } } public function shouldPreRender(): bool { return $this->force_pre_render || self::$needs_pre_render; } public function render(AbstractValue $v): string { $render_spl_ids_stash = $this->render_spl_ids; if ($this->render_spl_ids && $v->flags & AbstractValue::FLAG_GENERATED) { $this->render_spl_ids = false; } if ($plugin = $this->getValuePlugin($v)) { $output = $plugin->renderValue($v); if (null !== $output && \strlen($output)) { if (!$this->render_spl_ids && $render_spl_ids_stash) { $this->render_spl_ids = true; } return $output; } } $children = $this->renderChildren($v); $header = $this->renderHeaderWrapper($v->getContext(), (bool) \strlen($children), $this->renderHeader($v)); if (!$this->render_spl_ids && $render_spl_ids_stash) { $this->render_spl_ids = true; } return '
'.$header.$children.'
'; } public function renderHeaderWrapper(ContextInterface $c, bool $has_children, string $contents): string { $out = 'expand) { $out .= ' kint-show'; } $out .= '"'; } $out .= '>'; if (self::$access_paths && $c->getDepth() > 0 && null !== ($ap = $c->getAccessPath())) { $out .= ''; } if ($has_children) { if (0 === $c->getDepth()) { if (!$this->use_folder) { $out .= ''; } $out .= ''; $out .= ''; } $out .= ''; } $out .= $contents; if (!empty($ap)) { $out .= '
'.$this->escape($ap).'
'; } return $out.''; } public function renderHeader(AbstractValue $v): string { $c = $v->getContext(); $output = ''; if ($c instanceof ClassDeclaredContext) { $output .= ''.$c->getModifiers().' '; } $output .= ''.$this->escape($v->getDisplayName()).' '; if ($c instanceof PropertyContext && null !== ($s = $c->getHooks())) { $output .= ''.$this->escape($s).' '; } if (null !== ($s = $c->getOperator())) { $output .= $this->escape($s, 'ASCII').' '; } $s = $v->getDisplayType(); if (self::$escape_types) { $s = $this->escape($s); } if ($c->isRef()) { $s = '&'.$s; } $output .= ''.$s.''; if ($v instanceof InstanceValue && $this->shouldRenderObjectIds()) { $output .= '#'.$v->getSplObjectId(); } $output .= ' '; if (null !== ($s = $v->getDisplaySize())) { if (self::$escape_types) { $s = $this->escape($s); } $output .= '('.$s.') '; } if (null !== ($s = $v->getDisplayValue())) { $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(AbstractValue $v): string { $contents = []; $tabs = []; foreach ($v->getRepresentations() as $rep) { $result = $this->renderTab($v, $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 .= '
    '; foreach ($tabs as $i => $tab) { if (0 === $i) { $output .= '
  • '; } else { $output .= '
  • '; } $output .= $this->escape($tab->getLabel()).'
  • '; } $output .= '
    '; foreach ($contents as $i => $tab) { if (0 === $i) { $output .= '
  • '; } else { $output .= '
  • '; } $output .= $tab.'
  • '; } $output .= '
'; } return $output.'
'; } public function preRender(): string { $output = ''; if ($this->shouldPreRender()) { 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 .= '