update patch 1

This commit is contained in:
fiqhpratama
2024-12-02 01:18:34 +07:00
parent 453d9bb470
commit 25026b0a85
3380 changed files with 103529 additions and 363623 deletions
@@ -26,12 +26,11 @@ use Symfony\Component\VarDumper\Dumper\CliDumper;
*/
class CliDescriptor implements DumpDescriptorInterface
{
private CliDumper $dumper;
private mixed $lastIdentifier = null;
public function __construct(CliDumper $dumper)
{
$this->dumper = $dumper;
public function __construct(
private CliDumper $dumper,
) {
}
public function describe(OutputInterface $output, Data $data, array $context, int $clientId): void
@@ -47,7 +46,7 @@ class CliDescriptor implements DumpDescriptorInterface
if (isset($context['request'])) {
$request = $context['request'];
$this->lastIdentifier = $request['identifier'];
$section = sprintf('%s %s', $request['method'], $request['uri']);
$section = \sprintf('%s %s', $request['method'], $request['uri']);
if ($controller = $request['controller']) {
$rows[] = ['controller', rtrim($this->dumper->dump($controller, true), "\n")];
}
@@ -62,9 +61,9 @@ class CliDescriptor implements DumpDescriptorInterface
if (isset($context['source'])) {
$source = $context['source'];
$sourceInfo = sprintf('%s on line %d', $source['name'], $source['line']);
$sourceInfo = \sprintf('%s on line %d', $source['name'], $source['line']);
if ($fileLink = $source['file_link'] ?? null) {
$sourceInfo = sprintf('<href=%s>%s</>', $fileLink, $sourceInfo);
$sourceInfo = \sprintf('<href=%s>%s</>', $fileLink, $sourceInfo);
}
$rows[] = ['source', $sourceInfo];
$file = $source['file_relative'] ?? $source['file'];
@@ -24,12 +24,11 @@ use Symfony\Component\VarDumper\Dumper\HtmlDumper;
*/
class HtmlDescriptor implements DumpDescriptorInterface
{
private HtmlDumper $dumper;
private bool $initialized = false;
public function __construct(HtmlDumper $dumper)
{
$this->dumper = $dumper;
public function __construct(
private HtmlDumper $dumper,
) {
}
public function describe(OutputInterface $output, Data $data, array $context, int $clientId): void
@@ -45,22 +44,22 @@ class HtmlDescriptor implements DumpDescriptorInterface
if (isset($context['request'])) {
$request = $context['request'];
$controller = "<span class='dumped-tag'>{$this->dumper->dump($request['controller'], true, ['maxDepth' => 0])}</span>";
$title = sprintf('<code>%s</code> <a href="%s">%s</a>', $request['method'], $uri = $request['uri'], $uri);
$title = \sprintf('<code>%s</code> <a href="%s">%s</a>', $request['method'], $uri = $request['uri'], $uri);
$dedupIdentifier = $request['identifier'];
} elseif (isset($context['cli'])) {
$title = '<code>$ </code>'.$context['cli']['command_line'];
$dedupIdentifier = $context['cli']['identifier'];
} else {
$dedupIdentifier = uniqid('', true);
$dedupIdentifier = bin2hex(random_bytes(4));
}
$sourceDescription = '';
if (isset($context['source'])) {
$source = $context['source'];
$projectDir = $source['project_dir'] ?? null;
$sourceDescription = sprintf('%s on line %d', $source['name'], $source['line']);
$sourceDescription = \sprintf('%s on line %d', $source['name'], $source['line']);
if (isset($source['file_link'])) {
$sourceDescription = sprintf('<a href="%s">%s</a>', $source['file_link'], $sourceDescription);
$sourceDescription = \sprintf('<a href="%s">%s</a>', $source['file_link'], $sourceDescription);
}
}
@@ -105,7 +104,7 @@ HTML
$renderedTags = '';
foreach ($tags as $key => $value) {
$renderedTags .= sprintf('<li><span class="badge">%s</span>%s</li>', $key, $value);
$renderedTags .= \sprintf('<li><span class="badge">%s</span>%s</li>', $key, $value);
}
return <<<HTML
+7 -8
View File
@@ -38,14 +38,13 @@ use Symfony\Component\VarDumper\Server\DumpServer;
#[AsCommand(name: 'server:dump', description: 'Start a dump server that collects and displays dumps in a single place')]
class ServerDumpCommand extends Command
{
private DumpServer $server;
/** @var DumpDescriptorInterface[] */
private array $descriptors;
public function __construct(DumpServer $server, array $descriptors = [])
{
$this->server = $server;
public function __construct(
private DumpServer $server,
array $descriptors = [],
) {
$this->descriptors = $descriptors + [
'cli' => new CliDescriptor(new CliDumper()),
'html' => new HtmlDescriptor(new HtmlDumper()),
@@ -57,7 +56,7 @@ class ServerDumpCommand extends Command
protected function configure(): void
{
$this
->addOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format (%s)', implode(', ', $this->getAvailableFormats())), 'cli')
->addOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format (%s)', implode(', ', $this->getAvailableFormats())), 'cli')
->setHelp(<<<'EOF'
<info>%command.name%</info> starts a dump server that collects and displays
dumps in a single place for debugging you application:
@@ -80,7 +79,7 @@ EOF
$format = $input->getOption('format');
if (!$descriptor = $this->descriptors[$format] ?? null) {
throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $format));
throw new InvalidArgumentException(\sprintf('Unsupported format "%s".', $format));
}
$errorIo = $io->getErrorStyle();
@@ -88,7 +87,7 @@ EOF
$this->server->start();
$errorIo->success(sprintf('Server listening on %s', $this->server->getHost()));
$errorIo->success(\sprintf('Server listening on %s', $this->server->getHost()));
$errorIo->comment('Quit the server with CONTROL-C.');
$this->server->listen(function (Data $data, array $context, int $clientId) use ($descriptor, $io) {