diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 61884ea95..4ba1fbeb9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,6 +22,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + extensions: ds coverage: none - run: composer install --no-progress --prefer-dist @@ -41,6 +42,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: 7.4 + extensions: ds coverage: none - run: composer install --no-progress --prefer-dist diff --git a/src/Tracy/Dumper/Dumper.php b/src/Tracy/Dumper/Dumper.php index 59946c14d..c8b06ce54 100644 --- a/src/Tracy/Dumper/Dumper.php +++ b/src/Tracy/Dumper/Dumper.php @@ -80,6 +80,8 @@ class Dumper \DOMNode::class => [Exposer::class, 'exposeDOMNode'], \DOMNodeList::class => [Exposer::class, 'exposeDOMNodeList'], \DOMNamedNodeMap::class => [Exposer::class, 'exposeDOMNodeList'], + \Ds\Collection::class => [Exposer::class, 'exposeDsCollection'], + \Ds\Map::class => [Exposer::class, 'exposeDsMap'], ]; /** @var Describer */ diff --git a/src/Tracy/Dumper/Exposer.php b/src/Tracy/Dumper/Exposer.php index 183da7d74..0e5a1d7ff 100644 --- a/src/Tracy/Dumper/Exposer.php +++ b/src/Tracy/Dumper/Exposer.php @@ -179,4 +179,27 @@ public static function exposePhpIncompleteClass( } $value->value = $class . ' (Incomplete Class)'; } + + + public static function exposeDsCollection( + \Ds\Collection $obj, + Value $value, + Describer $describer + ): void { + foreach ($obj as $k => $v) { + $describer->addPropertyTo($value, (string) $k, $v, Value::PROP_VIRTUAL); + } + } + + + public static function exposeDsMap( + \Ds\Map $obj, + Value $value, + Describer $describer + ): void { + $i = 0; + foreach ($obj as $k => $v) { + $describer->addPropertyTo($value, (string) $i++, new \Ds\Pair($k, $v), Value::PROP_VIRTUAL); + } + } } diff --git a/tests/Tracy/Dumper.toText().specials.ds.phpt b/tests/Tracy/Dumper.toText().specials.ds.phpt new file mode 100644 index 000000000..f005b81e1 --- /dev/null +++ b/tests/Tracy/Dumper.toText().specials.ds.phpt @@ -0,0 +1,32 @@ +put('key', 'value'); +Assert::match(<<<'XX' +Ds\Map #%d% + 0: Ds\Pair #%d% + | key: 'key' + | value: 'value' +XX +, Dumper::toText($map));