Skip to content

Commit

Permalink
fix(var-dumper):cli renderer must use provided output that may be buf…
Browse files Browse the repository at this point in the history
…fered
  • Loading branch information
roxblnfk committed Jun 29, 2024
1 parent e41d505 commit b3ec161
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Sender/Console/Renderer/Sentry/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static function renderTrace(OutputInterface $output, array $frames, bool
"<fg=gray>%s</><fg=white;options=bold>%s<fg=yellow>%s</>\n%s<fg=yellow>%s</><fg=gray>%s()</>",
\str_pad("#$i", $numPad, ' '),
(string) $file,
$line !== '' ? ":$line": '',
$line !== '' ? ":$line" : '',
\str_repeat(' ', $numPad),
$class,
(string) $function,
Expand Down
13 changes: 6 additions & 7 deletions src/Sender/Console/Renderer/VarDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*/
final class VarDumper implements Renderer
{
private static ?DumpDescriptorInterface $describer = null;

public function isSupport(Frame $frame): bool
{
return $frame->type === ProtoType::VarDumper;
Expand All @@ -41,15 +39,16 @@ public function render(OutputInterface $output, Frame $frame): void
$payload === false and throw new \RuntimeException("Unable to decode the message.");

[$data, $context] = $payload;

self::$describer->describe(new SymfonyStyle(new ArrayInput([]), $output), $data, $context, 0);
$this
->getDescriber($output)
->describe(new SymfonyStyle(new ArrayInput([]), $output), $data, $context, 0);
}

private function getDescriber(): DumpDescriptorInterface
private function getDescriber(OutputInterface $output): DumpDescriptorInterface
{
return new class() implements DumpDescriptorInterface {
return new class(new CliDumper($output)) implements DumpDescriptorInterface {
public function __construct(
private readonly CliDumper $dumper = new CliDumper(),
private readonly CliDumper $dumper,
) {}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Sender/Console/Support/Tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Buggregator\Trap\Sender\Console\Support;

use Buggregator\Trap\Support\Json;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Terminal;
Expand Down

0 comments on commit b3ec161

Please sign in to comment.