%s
', esc($attr['lang']), $v);
+ }
+ if ('label' === $style) {
+ $v .= ' ';
+ }
+
+ return $v;
+ }
+
+ /**
+ * @return void
+ */
+ protected function dumpLine(int $depth, bool $endOfValue = false)
+ {
+ if (-1 === $this->lastDepth) {
+ $this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad) . $this->line;
+ }
+
+ if (-1 === $depth) {
+ $args = ['"' . $this->dumpId . '"'];
+ if ($this->extraDisplayOptions) {
+ $args[] = json_encode($this->extraDisplayOptions, \JSON_FORCE_OBJECT);
+ }
+ // Replace is for BC
+ $this->line .= sprintf(str_replace('"%s"', '%s', $this->dumpSuffix), implode(', ', $args));
+ }
+ $this->lastDepth = $depth;
+
+ $this->line = mb_encode_numericentity($this->line, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8');
+
+ if (-1 === $depth) {
+ AbstractDumper::dumpLine(0);
+ }
+ AbstractDumper::dumpLine($depth);
+ }
+
+ private function getSourceLink(string $file, int $line): string|false
+ {
+ $options = $this->extraDisplayOptions + $this->displayOptions;
+
+ if ($fmt = $options['fileLinkFormat']) {
+ return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line);
+ }
+
+ return false;
+ }
+}
+
+function esc(string $str): string
+{
+ return htmlspecialchars($str, \ENT_QUOTES, 'UTF-8');
+}
+
diff --git a/app/modules/VarDumper/Application/Dump/MtRandDumpIdGenerator.php b/app/modules/VarDumper/Application/Dump/MtRandDumpIdGenerator.php
new file mode 100644
index 00000000..1fcd750e
--- /dev/null
+++ b/app/modules/VarDumper/Application/Dump/MtRandDumpIdGenerator.php
@@ -0,0 +1,13 @@
+type;
+ }
+
+ public function getValue(): string
+ {
+ return $this->value;
+ }
+
+ public function __toString(): string
+ {
+ return $this->value;
+ }
+
+ public function jsonSerialize(): string
+ {
+ return $this->__toString();
+ }
+}
diff --git a/app/modules/VarDumper/Application/VarDumperBootloader.php b/app/modules/VarDumper/Application/VarDumperBootloader.php
new file mode 100644
index 00000000..4ee91539
--- /dev/null
+++ b/app/modules/VarDumper/Application/VarDumperBootloader.php
@@ -0,0 +1,19 @@
+ MtRandDumpIdGenerator::class,
+ ];
+ }
+}
diff --git a/app/modules/VarDumper/Interfaces/TCP/Service.php b/app/modules/VarDumper/Interfaces/TCP/Service.php
index b655a4e3..266eb880 100644
--- a/app/modules/VarDumper/Interfaces/TCP/Service.php
+++ b/app/modules/VarDumper/Interfaces/TCP/Service.php
@@ -5,7 +5,12 @@
namespace Modules\VarDumper\Interfaces\TCP;
use App\Application\Commands\HandleReceivedEvent;
+use Modules\VarDumper\Application\Dump\BodyInterface;
+use Modules\VarDumper\Application\Dump\DumpIdGeneratorInterface;
+use Modules\VarDumper\Application\Dump\HtmlBody;
+use Modules\VarDumper\Application\Dump\HtmlDumper;
use Modules\VarDumper\Application\Dump\MessageParser;
+use Modules\VarDumper\Application\Dump\PrimitiveBody;
use Spiral\Cqrs\CommandBusInterface;
use Spiral\RoadRunner\Tcp\Request;
use Spiral\RoadRunner\Tcp\TcpEvent;
@@ -13,12 +18,12 @@
use Spiral\RoadRunnerBridge\Tcp\Response\ResponseInterface;
use Spiral\RoadRunnerBridge\Tcp\Service\ServiceInterface;
use Symfony\Component\VarDumper\Cloner\Data;
-use Symfony\Component\VarDumper\Dumper\HtmlDumper;
final readonly class Service implements ServiceInterface
{
public function __construct(
private CommandBusInterface $commandBus,
+ private DumpIdGeneratorInterface $dumpId,
) {
}
@@ -49,19 +54,26 @@ private function fireEvent(array $payload): void
'value' => $this->convertToPrimitive($payload[0]),
],
'context' => $payload[1],
- ]
- )
+ ],
+ ),
);
}
- private function convertToPrimitive(Data $data): string|null
+ private function convertToPrimitive(Data $data): BodyInterface|null
{
if (\in_array($data->getType(), ['string', 'boolean'])) {
- return (string)$data->getValue();
+ return new PrimitiveBody(
+ type: $data->getType(),
+ value: $data->getValue(),
+ );
}
- $dumper = new HtmlDumper();
+ $dumper = new HtmlDumper(
+ generator: $this->dumpId,
+ );
- return $dumper->dump($data, true);
+ return new HtmlBody(
+ value: $dumper->dump($data, true),
+ );
}
}
diff --git a/app/src/Application/Kernel.php b/app/src/Application/Kernel.php
index 42727284..cf58cc1f 100644
--- a/app/src/Application/Kernel.php
+++ b/app/src/Application/Kernel.php
@@ -15,6 +15,7 @@
use Modules\Ray\Application\RayBootloader;
use Modules\HttpDumps\Application\HttpDumpsBootloader;
use Modules\Sentry\Application\SentryBootloader;
+use Modules\VarDumper\Application\VarDumperBootloader;
use Spiral\Boot\Bootloader\CoreBootloader;
use Spiral\Bootloader as Framework;
use Spiral\Cqrs\Bootloader\CqrsBootloader;
@@ -103,6 +104,7 @@ protected function defineBootloaders(): array
AppBootloader::class,
InspectorBootloader::class,
SentryBootloader::class,
+ VarDumperBootloader::class,
RayBootloader::class,
HttpDumpsBootloader::class,
ProfilerBootloader::class,
diff --git a/phpunit.xml b/phpunit.xml
index 42bb75ba..c99b4e28 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -23,6 +23,7 @@
{#2296 + +"type": "string" + +"value": "foo" +} ++ +HTML, + ], $data['data']['payload']['payload']); + + $this->assertNotEmpty($data['data']['uuid']); + $this->assertNotEmpty($data['data']['timestamp']); return true; });