diff --git a/build/kint.phar b/build/kint.phar index ad12ad5fc..d6c1843a9 100644 Binary files a/build/kint.phar and b/build/kint.phar differ diff --git a/src/Parser/SimpleXMLElementPlugin.php b/src/Parser/SimpleXMLElementPlugin.php index a4ad6d623..db6f9b9c1 100644 --- a/src/Parser/SimpleXMLElementPlugin.php +++ b/src/Parser/SimpleXMLElementPlugin.php @@ -125,7 +125,9 @@ public function parse(&$var, Value &$o, int $trigger): void } } - $x->addRepresentation($a, 0); + if ($a->contents) { + $x->addRepresentation($a, 0); + } // Children $c = new Representation('Children'); @@ -195,14 +197,14 @@ public function parse(&$var, Value &$o, int $trigger): void $s = $this->parser->parse($value, $base_obj); $srep = $s->getRepresentation('contents'); - $svalrep = $s->value && 'contents' == $s->value->getName() ? $s : null; + $svalrep = $s->value && 'contents' == $s->value->getName() ? $s->value : null; if ($srep || $svalrep) { $x->setIsStringValue(true); $x->value = $srep ?: $svalrep; if ($srep) { - $x->replaceRepresentation($x->value, 0); + $x->replaceRepresentation($srep, 0); } } diff --git a/src/Renderer/Rich/SimpleXMLElementPlugin.php b/src/Renderer/Rich/SimpleXMLElementPlugin.php new file mode 100644 index 000000000..87d987079 --- /dev/null +++ b/src/Renderer/Rich/SimpleXMLElementPlugin.php @@ -0,0 +1,56 @@ +isStringValue() || !empty($o->getRepresentation('attributes')->contents)) { + return null; + } + + $b = new BlobValue(); + $b->transplant($o); + $b->type = 'string'; + + $children = $this->renderer->renderChildren($b); + $header = $this->renderer->renderHeader($o); + $header = $this->renderer->renderHeaderWrapper($o, (bool) \strlen($children), $header); + + return '
'.$header.$children.'
'; + } +} diff --git a/src/Renderer/RichRenderer.php b/src/Renderer/RichRenderer.php index 4ef045f46..ecedb40b5 100644 --- a/src/Renderer/RichRenderer.php +++ b/src/Renderer/RichRenderer.php @@ -56,6 +56,7 @@ class RichRenderer extends AbstractRenderer 'color' => Rich\ColorPlugin::class, 'depth_limit' => Rich\DepthLimitPlugin::class, 'recursion' => Rich\RecursionPlugin::class, + 'simplexml_element' => Rich\SimpleXMLElementPlugin::class, 'trace_frame' => Rich\TraceFramePlugin::class, ]; diff --git a/src/Zval/SimpleXMLElementValue.php b/src/Zval/SimpleXMLElementValue.php index 97d778ee3..0f152230e 100644 --- a/src/Zval/SimpleXMLElementValue.php +++ b/src/Zval/SimpleXMLElementValue.php @@ -33,6 +33,11 @@ class SimpleXMLElementValue extends InstanceValue protected $is_string_value = false; + public function isStringValue(): bool + { + return $this->is_string_value; + } + public function setIsStringValue(bool $is_string_value): void { $this->is_string_value = $is_string_value;