diff --git a/build/kint.phar b/build/kint.phar
index 4430b2e32..af20abb77 100644
Binary files a/build/kint.phar and b/build/kint.phar differ
diff --git a/src/Parser/HtmlPlugin.php b/src/Parser/HtmlPlugin.php
index 448f5ca32..996f94e09 100644
--- a/src/Parser/HtmlPlugin.php
+++ b/src/Parser/HtmlPlugin.php
@@ -98,7 +98,12 @@ public function parse(&$var, Value &$o, int $trigger): void
}
$r = new Representation('HTML');
- $r->contents = $iter->contents;
+ $r->contents = [];
+
+ foreach ($iter->contents as $val) {
+ $val->hints[] = 'omit_spl_id';
+ $r->contents[] = $val;
+ }
$o->addRepresentation($r, 0);
}
diff --git a/src/Parser/SerializePlugin.php b/src/Parser/SerializePlugin.php
index d284c4f9b..deceda52a 100644
--- a/src/Parser/SerializePlugin.php
+++ b/src/Parser/SerializePlugin.php
@@ -84,6 +84,7 @@ public function parse(&$var, Value &$o, int $trigger): void
$base_obj = new Value('unserialize('.$o->name.')');
$base_obj->depth = $o->depth + 1;
+ $base_obj->hints[] = 'omit_spl_id';
if (null !== $o->access_path) {
$base_obj->access_path = 'unserialize('.$o->access_path;
diff --git a/src/Parser/SimpleXMLElementPlugin.php b/src/Parser/SimpleXMLElementPlugin.php
index 07e2a9019..4c1e17a80 100644
--- a/src/Parser/SimpleXMLElementPlugin.php
+++ b/src/Parser/SimpleXMLElementPlugin.php
@@ -217,6 +217,8 @@ protected function getChildrenRepresentation(SimpleXMLElementValue $element, Sim
$obj->name = $nsAlias.':'.$name;
}
+ $obj->hints[] = 'omit_spl_id';
+
if (null !== $element->access_path) {
if ('' === $nsAlias) {
$obj->access_path = $element->access_path.'->';
diff --git a/src/Parser/XmlPlugin.php b/src/Parser/XmlPlugin.php
index 960bd7d06..6408c0c15 100644
--- a/src/Parser/XmlPlugin.php
+++ b/src/Parser/XmlPlugin.php
@@ -79,6 +79,7 @@ public function parse(&$var, Value &$o, int $trigger): void
$base_obj = new Value($name);
$base_obj->access_path = $access_path;
$base_obj->depth = $o->depth + 1;
+ $base_obj->hints[] = 'omit_spl_id';
$r = new Representation('XML');
$r->contents = $this->getParser()->parse($xml, $base_obj);
diff --git a/src/Renderer/AbstractRenderer.php b/src/Renderer/AbstractRenderer.php
index 12452e40e..63f0ffcad 100644
--- a/src/Renderer/AbstractRenderer.php
+++ b/src/Renderer/AbstractRenderer.php
@@ -48,11 +48,17 @@ abstract class AbstractRenderer implements ConstructableRendererInterface
protected array $call_info = [];
protected array $statics = [];
protected bool $show_trace = true;
+ protected bool $render_spl_ids = true;
public function __construct()
{
}
+ public function shouldRenderObjectIds(): bool
+ {
+ return $this->render_spl_ids;
+ }
+
public function setCallInfo(array $info): void
{
if (!isset($info['modifiers']) || !\is_array($info['modifiers'])) {
diff --git a/src/Renderer/RendererInterface.php b/src/Renderer/RendererInterface.php
index f9c30faa3..4bdebfd46 100644
--- a/src/Renderer/RendererInterface.php
+++ b/src/Renderer/RendererInterface.php
@@ -47,6 +47,8 @@ public function setShowTrace(bool $show_trace): void;
public function getShowTrace(): bool;
+ public function shouldRenderObjectIds(): bool;
+
public function filterParserPlugins(array $plugins): array;
public function preRender(): string;
diff --git a/src/Renderer/Rich/AbstractPlugin.php b/src/Renderer/Rich/AbstractPlugin.php
index bac4eb56f..032358d90 100644
--- a/src/Renderer/Rich/AbstractPlugin.php
+++ b/src/Renderer/Rich/AbstractPlugin.php
@@ -74,7 +74,7 @@ public function renderLockedHeader(Value $o, string $content): string
$header .= ''.$s.'';
- if ($o instanceof InstanceValue) {
+ if ($o instanceof InstanceValue && $this->renderer->shouldRenderObjectIds()) {
$header .= '#'.$o->spl_object_id;
}
diff --git a/src/Renderer/Rich/ClosurePlugin.php b/src/Renderer/Rich/ClosurePlugin.php
index 7223024ed..5a5663cae 100644
--- a/src/Renderer/Rich/ClosurePlugin.php
+++ b/src/Renderer/Rich/ClosurePlugin.php
@@ -47,7 +47,11 @@ public function renderValue(Value $o): ?string
$header .= ''.$s.' ';
}
- $header .= ''.$this->renderer->escape($o->getName()).'('.$this->renderer->escape($o->getParams()).') Closure#'.$o->spl_object_id;
+ $header .= ''.$this->renderer->escape($o->getName()).'('.$this->renderer->escape($o->getParams()).') Closure';
+
+ if ($this->renderer->shouldRenderObjectIds()) {
+ $header .= '#'.$o->spl_object_id;
+ }
if (null !== $o->filename) {
$header .= ' '.$this->renderer->escape(Kint::shortenPath($o->filename)).':'.(int) $o->startline;
diff --git a/src/Renderer/RichRenderer.php b/src/Renderer/RichRenderer.php
index 9c8955415..e75c38cde 100644
--- a/src/Renderer/RichRenderer.php
+++ b/src/Renderer/RichRenderer.php
@@ -220,9 +220,19 @@ public function shouldFolderRender(): bool
public function render(Value $o): string
{
+ $render_spl_ids_stash = $this->render_spl_ids;
+
+ if ($this->render_spl_ids && \in_array('omit_spl_id', $o->hints, true)) {
+ $this->render_spl_ids = false;
+ }
+
if (($plugin = $this->getPlugin(self::$value_plugins, $o->hints)) && $plugin instanceof ValuePluginInterface) {
$output = $plugin->renderValue($o);
if (null !== $output && \strlen($output)) {
+ if (!$this->render_spl_ids && $render_spl_ids_stash) {
+ $this->render_spl_ids = true;
+ }
+
return $output;
}
}
@@ -230,6 +240,10 @@ public function render(Value $o): string
$children = $this->renderChildren($o);
$header = $this->renderHeaderWrapper($o, (bool) \strlen($children), $this->renderHeader($o));
+ if (!$this->render_spl_ids && $render_spl_ids_stash) {
+ $this->render_spl_ids = true;
+ }
+
return '
'.$header.$children.'
';
}
@@ -303,7 +317,7 @@ public function renderHeader(Value $o): string
$output .= ''.$s.'';
- if ($o instanceof InstanceValue) {
+ if ($o instanceof InstanceValue && $this->shouldRenderObjectIds()) {
$output .= '#'.$o->spl_object_id;
}
diff --git a/src/Renderer/TextRenderer.php b/src/Renderer/TextRenderer.php
index 71f99789c..9344b9d8d 100644
--- a/src/Renderer/TextRenderer.php
+++ b/src/Renderer/TextRenderer.php
@@ -124,9 +124,19 @@ public function __construct()
public function render(Value $o): string
{
+ $render_spl_ids_stash = $this->render_spl_ids;
+
+ if ($this->render_spl_ids && \in_array('omit_spl_id', $o->hints, true)) {
+ $this->render_spl_ids = false;
+ }
+
if ($plugin = $this->getPlugin(self::$plugins, $o->hints)) {
$output = $plugin->render($o);
if (null !== $output && \strlen($output)) {
+ if (!$this->render_spl_ids && $render_spl_ids_stash) {
+ $this->render_spl_ids = true;
+ }
+
return $output;
}
}
@@ -140,6 +150,10 @@ public function render(Value $o): string
$out .= $this->renderHeader($o);
$out .= $this->renderChildren($o).PHP_EOL;
+ if (!$this->render_spl_ids && $render_spl_ids_stash) {
+ $this->render_spl_ids = true;
+ }
+
return $out;
}
@@ -204,7 +218,7 @@ public function renderHeader(Value $o): string
$s = $this->colorType($this->escape($s));
- if ($o instanceof InstanceValue) {
+ if ($o instanceof InstanceValue && $this->shouldRenderObjectIds()) {
$s .= '#'.$o->spl_object_id;
}
diff --git a/tests/Parser/HtmlPluginTest.php b/tests/Parser/HtmlPluginTest.php
index 2acc888a4..39c0156b4 100644
--- a/tests/Parser/HtmlPluginTest.php
+++ b/tests/Parser/HtmlPluginTest.php
@@ -66,18 +66,22 @@ public function testParse()
$o = $p->parse($v, clone $b);
+ $this->assertNotContains('omit_spl_id', $o->hints);
+
$r = $o->getRepresentation('html');
$this->assertNotNull($r);
$this->assertCount(2, $r->contents);
$this->assertInstanceOf(InstanceValue::class, $r->contents[0]);
+ $this->assertContains('omit_spl_id', $r->contents[0]->hints);
$this->assertSame(DocumentType::class, $r->contents[0]->classname);
$this->assertSame('html', $r->contents[0]->name);
$this->assertSame(0, $r->contents[0]->size);
$this->assertSame('\\Dom\\HTMLDocument::createFromString($v)->childNodes->item(0)', $r->contents[0]->access_path);
$this->assertInstanceOf(InstanceValue::class, $r->contents[1]);
+ $this->assertContains('omit_spl_id', $r->contents[1]->hints);
$this->assertSame(HTMLElement::class, $r->contents[1]->classname);
$this->assertSame('html', $r->contents[1]->name);
$this->assertSame(0, $r->contents[1]->size);
diff --git a/tests/Parser/SerializePluginTest.php b/tests/Parser/SerializePluginTest.php
index 4f0d5cbab..eec9c9fda 100644
--- a/tests/Parser/SerializePluginTest.php
+++ b/tests/Parser/SerializePluginTest.php
@@ -88,6 +88,8 @@ public function testParse()
'unserialize($v, '.\var_export(['allowed_classes' => false], true).')[\'obj\']',
$obj->getRepresentation('serialized')->contents->value->contents[0]->access_path
);
+ $this->assertNotContains('omit_spl_id', $obj->hints);
+ $this->assertNotContains('omit_spl_id', $obj->getRepresentation('serialized')->contents->value->hints);
SerializePlugin::$allowed_classes = [self::class];
$obj = $p->parse($v, clone $b);
diff --git a/tests/Parser/SimpleXMLElementPluginTest.php b/tests/Parser/SimpleXMLElementPluginTest.php
index acb7ce5df..f383dd0d1 100644
--- a/tests/Parser/SimpleXMLElementPluginTest.php
+++ b/tests/Parser/SimpleXMLElementPluginTest.php
@@ -124,6 +124,7 @@ public function testParse()
$this->assertSame('$v', $x->name);
$this->assertSame('$v', $x->access_path);
+ $this->assertNotContains('omit_spl_id', $x->hints);
$this->assertNull($x->getRepresentation('tostring'));
$this->assertInstanceOf(Representation::class, $x->getRepresentation('children'));
$this->assertInstanceOf(Representation::class, $x->getRepresentation('attributes'));
@@ -144,6 +145,7 @@ public function testParse()
$this->assertSame('g', $g1->name);
$this->assertSame('$v->g', $g1->access_path);
+ $this->assertContains('omit_spl_id', $g1->hints);
$this->assertNull($g1->getRepresentation('tostring'));
$this->assertInstanceOf(Representation::class, $g1->getRepresentation('children'));
$this->assertInstanceOf(Representation::class, $g1->getRepresentation('attributes'));
@@ -168,6 +170,7 @@ public function testParse()
$this->assertSame('inner', $inner->name);
$this->assertSame('(string) $v->g->inner', $inner->access_path);
+ $this->assertContains('omit_spl_id', $inner->hints);
$this->assertInstanceOf(Representation::class, $inner->getRepresentation('tostring'));
$this->assertNull($inner->getRepresentation('children'));
$this->assertNull($inner->getRepresentation('attributes'));
@@ -184,6 +187,7 @@ public function testParse()
$this->assertSame('g', $g2->name);
$this->assertSame('$v->g[1]', $g2->access_path);
+ $this->assertContains('omit_spl_id', $g2->hints);
$this->assertNull($g2->getRepresentation('tostring'));
$this->assertNull($g2->getRepresentation('children'));
$this->assertNull($g2->getRepresentation('attributes'));
@@ -198,6 +202,7 @@ public function testParse()
$this->assertSame('wrap', $wrap->name);
$this->assertSame('$v->wrap', $wrap->access_path);
+ $this->assertContains('omit_spl_id', $wrap->hints);
$this->assertNull($wrap->getRepresentation('tostring'));
$this->assertInstanceOf(Representation::class, $wrap->getRepresentation('children'));
$this->assertNull($wrap->getRepresentation('attributes'));
@@ -213,6 +218,7 @@ public function testParse()
$this->assertSame('wrap', $wrap2->name);
$this->assertSame('$v->wrap->wrap', $wrap2->access_path);
+ $this->assertContains('omit_spl_id', $wrap2->hints);
$this->assertNull($wrap2->getRepresentation('tostring'));
$this->assertInstanceOf(Representation::class, $wrap2->getRepresentation('children'));
$this->assertNull($wrap2->getRepresentation('attributes'));
@@ -228,6 +234,7 @@ public function testParse()
$this->assertSame('text', $text->name);
$this->assertSame('(string) $v->wrap->wrap->text', $text->access_path);
+ $this->assertContains('omit_spl_id', $text->hints);
$this->assertInstanceOf(Representation::class, $text->getRepresentation('tostring'));
$this->assertNull($text->getRepresentation('children'));
$this->assertNull($text->getRepresentation('attributes'));
@@ -244,6 +251,7 @@ public function testParse()
$this->assertSame('not-php-compatible', $incomp->name);
$this->assertSame('$v->wrap->{\'not-php-compatible\'}', $incomp->access_path);
+ $this->assertContains('omit_spl_id', $incomp->hints);
$this->assertNull($incomp->getRepresentation('tostring'));
$this->assertNull($incomp->getRepresentation('children'));
$this->assertInstanceOf(Representation::class, $incomp->getRepresentation('attributes'));
@@ -263,6 +271,7 @@ public function testParse()
$this->assertSame('value', $value->name);
$this->assertSame('(string) $v->wrap->value', $value->access_path);
+ $this->assertContains('omit_spl_id', $value->hints);
$this->assertInstanceOf(Representation::class, $value->getRepresentation('tostring'));
$this->assertNull($value->getRepresentation('children'));
$this->assertInstanceOf(Representation::class, $value->getRepresentation('attributes'));
@@ -284,6 +293,7 @@ public function testParse()
$this->assertSame('both', $both->name);
$this->assertSame('(string) $v->both', $both->access_path);
+ $this->assertContains('omit_spl_id', $both->hints);
$this->assertInstanceOf(Representation::class, $both->getRepresentation('tostring'));
$this->assertNull($both->getRepresentation('children'));
$this->assertInstanceOf(Representation::class, $both->getRepresentation('attributes'));
diff --git a/tests/Parser/XmlPluginTest.php b/tests/Parser/XmlPluginTest.php
index d90d8b5bc..f2c82c2ad 100644
--- a/tests/Parser/XmlPluginTest.php
+++ b/tests/Parser/XmlPluginTest.php
@@ -67,10 +67,13 @@ public function testParseSimpleXML()
$o = $p->parse($v, clone $b);
+ $this->assertNotContains('omit_spl_id', $o->hints);
+
$r = $o->getRepresentation('xml');
$this->assertNotNull($r);
$this->assertInstanceOf(InstanceValue::class, $r->contents);
+ $this->assertContains('omit_spl_id', $r->contents->hints);
$this->assertSame('SimpleXMLElement', $r->contents->classname);
$this->assertSame('x', $r->contents->name);
$this->assertSame(2, $r->contents->size);
@@ -108,10 +111,13 @@ public function testParseDOMDocument()
$o = $p->parse($v, clone $b);
+ $this->assertNotContains('omit_spl_id', $o->hints);
+
$r = $o->getRepresentation('xml');
$this->assertNotNull($r);
$this->assertInstanceOf(InstanceValue::class, $r->contents);
+ $this->assertContains('omit_spl_id', $r->contents->hints);
$this->assertSame(DOMElement::class, $r->contents->classname);
$this->assertSame('x', $r->contents->name);
// Since PHP 8.1 there's a new schemaTypeInfo property that parses normally
@@ -150,6 +156,8 @@ public function testParseXMLDocument()
$o = $p->parse($v, clone $b);
+ $this->assertNotContains('omit_spl_id', $o->hints);
+
$r = $o->getRepresentation('xml');
if (!KINT_PHP84) {
@@ -160,6 +168,7 @@ public function testParseXMLDocument()
$this->assertNotNull($r);
$this->assertInstanceOf(InstanceValue::class, $r->contents);
+ $this->assertContains('omit_spl_id', $r->contents->hints);
$this->assertSame(Element::class, $r->contents->classname);
$this->assertSame('x', $r->contents->name);
$this->assertSame(0, $r->contents->size);