diff --git a/build/kint.phar b/build/kint.phar index 4d352be0a..d731e8dfe 100644 Binary files a/build/kint.phar and b/build/kint.phar differ diff --git a/src/Kint.php b/src/Kint.php index cef137e0b..4bddb0103 100644 --- a/src/Kint.php +++ b/src/Kint.php @@ -174,7 +174,6 @@ class Kint implements FacadeInterface \Kint\Parser\MicrotimePlugin::class, \Kint\Parser\SimpleXMLElementPlugin::class, \Kint\Parser\SplFileInfoPlugin::class, - \Kint\Parser\SplObjectStoragePlugin::class, \Kint\Parser\StreamPlugin::class, \Kint\Parser\TablePlugin::class, \Kint\Parser\ThrowablePlugin::class, diff --git a/src/Parser/IteratorPlugin.php b/src/Parser/IteratorPlugin.php index d884ed9bd..53937b310 100644 --- a/src/Parser/IteratorPlugin.php +++ b/src/Parser/IteratorPlugin.php @@ -116,6 +116,8 @@ public function parse(&$var, Value &$o, int $trigger): void $primary = \reset($primary); if ($primary && $primary === $o->value && [] === $primary->contents) { $o->addRepresentation($r, 0); + $o->hints[] = 'iterator_primary'; + $o->size = \count($data) ?: null; } else { $o->addRepresentation($r); } diff --git a/src/Parser/SplObjectStoragePlugin.php b/src/Renderer/Text/IteratorPrimaryPlugin.php similarity index 67% rename from src/Parser/SplObjectStoragePlugin.php rename to src/Renderer/Text/IteratorPrimaryPlugin.php index bd671ad62..09a7e9c4b 100644 --- a/src/Parser/SplObjectStoragePlugin.php +++ b/src/Renderer/Text/IteratorPrimaryPlugin.php @@ -25,32 +25,18 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -namespace Kint\Parser; +namespace Kint\Renderer\Text; use Kint\Zval\Value; -use SplObjectStorage; -class SplObjectStoragePlugin extends AbstractPlugin +class IteratorPrimaryPlugin extends AbstractPlugin { - public function getTypes(): array + public function render(Value $o): string { - return ['object']; - } - - public function getTriggers(): int - { - return Parser::TRIGGER_COMPLETE; - } - - public function parse(&$var, Value &$o, int $trigger): void - { - if (!$var instanceof SplObjectStorage || !($r = $o->getRepresentation('iterator'))) { - return; - } + $out = clone $o; + $out->hints = \array_diff($out->hints, ['iterator_primary']); + $out->value = $o->getRepresentation('iterator') ?? $out->value; - $r = $o->getRepresentation('iterator'); - if ($r) { - $o->size = !\is_array($r->contents) ? null : \count($r->contents); - } + return $this->renderer->render($out); } } diff --git a/src/Renderer/TextRenderer.php b/src/Renderer/TextRenderer.php index 7c2236814..b101fada0 100644 --- a/src/Renderer/TextRenderer.php +++ b/src/Renderer/TextRenderer.php @@ -51,6 +51,7 @@ class TextRenderer extends AbstractRenderer 'blacklist' => Text\BlacklistPlugin::class, 'depth_limit' => Text\DepthLimitPlugin::class, 'enum' => Text\EnumPlugin::class, + 'iterator_primary' => Text\IteratorPrimaryPlugin::class, 'microtime' => Text\MicrotimePlugin::class, 'recursion' => Text\RecursionPlugin::class, 'trace' => Text\TracePlugin::class, @@ -67,6 +68,7 @@ class TextRenderer extends AbstractRenderer Parser\ArrayObjectPlugin::class, Parser\BlacklistPlugin::class, Parser\EnumPlugin::class, + Parser\IteratorPlugin::class, Parser\MicrotimePlugin::class, Parser\StreamPlugin::class, Parser\TracePlugin::class,