diff --git a/src/Symfony/Bundle/DebugBundle/DebugBundle.php b/src/Symfony/Bundle/DebugBundle/DebugBundle.php index a24321e22910d..9782bf8e39899 100644 --- a/src/Symfony/Bundle/DebugBundle/DebugBundle.php +++ b/src/Symfony/Bundle/DebugBundle/DebugBundle.php @@ -35,14 +35,19 @@ public function boot() // The dump data collector is used by default, so dump output is sent to // the WDT. In a CLI context, if dump is used too soon, the data collector // will buffer it, and release it at the end of the script. - VarDumper::setHandler(function ($var) use ($container) { + VarDumper::setHandler(function ($var, string $label = null) use ($container) { $dumper = $container->get('data_collector.dump'); $cloner = $container->get('var_dumper.cloner'); - $handler = function ($var) use ($dumper, $cloner) { - $dumper->dump($cloner->cloneVar($var)); + $handler = function ($var, string $label = null) use ($dumper, $cloner) { + $var = $cloner->cloneVar($var); + if (null !== $label) { + $var = $var->withContext(['label' => $label]); + } + + $dumper->dump($var); }; VarDumper::setHandler($handler); - $handler($var); + $handler($var, $label); }); } } diff --git a/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php b/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php index 4a4090915770e..b10bd37f439e5 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php @@ -45,8 +45,11 @@ public function configure() $dumper = $this->dumper; $connection = $this->connection; - VarDumper::setHandler(static function ($var) use ($cloner, $dumper, $connection) { + VarDumper::setHandler(static function ($var, string $label = null) use ($cloner, $dumper, $connection) { $data = $cloner->cloneVar($var); + if (null !== $label) { + $data = $data->withContext(['label' => $label]); + } if (!$connection || !$connection->write($data)) { $dumper->dump($data); diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index 64b595d99287d..3bf0a09cb5594 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -269,17 +269,10 @@ public function dump(DumperInterface $dumper) { $refs = [0]; $cursor = new Cursor(); - $label = $this->context['label'] ?? ''; - - if ($cursor->attr = $this->context[SourceContextProvider::class] ?? []) { - $cursor->attr['if_links'] = true; - $cursor->hashType = -1; - $dumper->dumpScalar($cursor, 'default', $label.'^'); - $cursor->attr = ['if_links' => true]; - $dumper->dumpScalar($cursor, 'default', ' '); - $cursor->hashType = 0; - } - + $cursor->hashType = -1; + $cursor->attr = $this->context[SourceContextProvider::class] ?? []; + $dumper->dumpScalar($cursor, 'label', $this->context['label'] ?? ''); + $cursor->hashType = 0; $this->dumpItem($dumper, $cursor, $refs, $this->data[$this->position][$this->key]); } diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index c337bfed8d659..d9ce7ae4ed8fc 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -139,9 +139,8 @@ public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|n $attr = $cursor->attr; switch ($type) { - case 'default': - $style = 'default'; - break; + case 'label': $style = 'label'; break; + case 'default': $style = 'default'; break; case 'integer': $style = 'num'; @@ -468,7 +467,7 @@ protected function style(string $style, string $value, array $attr = []): string $map = static::$controlCharsMap; $startCchr = $this->colors ? "\033[m\033[{$this->styles['default']}m" : ''; - $endCchr = $this->colors ? "\033[m\033[{$this->styles[$style]}m" : ''; + $endCchr = $this->colors ? "\033[m\033[{$this->styles['label' === $style ? 'default' : $style]}m" : ''; $value = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $startCchr, $endCchr) { $s = $startCchr; $c = $c[$i = 0]; @@ -487,11 +486,11 @@ protected function style(string $style, string $value, array $attr = []): string }, $value); } - if ($this->colors) { + if ($this->colors && '' !== $value) { if ($cchrCount && "\033" === $value[0]) { $value = substr($value, \strlen($startCchr)); } else { - $value = "\033[{$this->styles[$style]}m".$value; + $value = "\033[{$this->styles['label' === $style ? 'default' : $style]}m".$value; } if ($cchrCount && str_ends_with($value, $endCchr)) { $value = substr($value, 0, -\strlen($endCchr)); @@ -510,10 +509,15 @@ protected function style(string $style, string $value, array $attr = []): string } } if (isset($attr['href'])) { + if ('label' === $style) { + $value .= '^'; + } $value = "\033]8;;{$attr['href']}\033\\{$value}\033]8;;\033\\"; } - } elseif ($attr['if_links'] ?? false) { - return ''; + } + + if ('label' === $style && '' !== $value) { + $value .= ' '; } return $value; diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 61910dcd7a9ee..34ef644ad0837 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -849,7 +849,7 @@ public function leaveHash(Cursor $cursor, int $type, string|int|null $class, boo protected function style(string $style, string $value, array $attr = []): string { - if ('' === $value) { + if ('' === $value && ('label' !== $style || !isset($attr['file']) && !isset($attr['href']))) { return ''; } @@ -903,7 +903,7 @@ protected function style(string $style, string $value, array $attr = []): string } $map = static::$controlCharsMap; - $v = "".preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) { + $v = ''.preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) { $s = $b = '\u{'.strtoupper(dechex(mb_ord($c[0]))).'}'; + return '\u{'.strtoupper(dechex(mb_ord($c[0]))).'}'; }, $v); } @@ -935,6 +935,9 @@ protected function style(string $style, string $value, array $attr = []): string $attr['href'] = $href; } if (isset($attr['href'])) { + if ('label' === $style) { + $v .= '^'; + } $target = isset($attr['file']) ? '' : ' target="_blank"'; $v = sprintf('%s', esc($this->utf8Encode($attr['href'])), $target, $v); } diff --git a/src/Symfony/Component/VarDumper/Resources/functions/dump.php b/src/Symfony/Component/VarDumper/Resources/functions/dump.php index 31613f206b880..d933bb7b10f62 100644 --- a/src/Symfony/Component/VarDumper/Resources/functions/dump.php +++ b/src/Symfony/Component/VarDumper/Resources/functions/dump.php @@ -25,7 +25,7 @@ function dump(mixed ...$vars): mixed return null; } - if (isset($vars[0]) && 1 === count($vars)) { + if (array_key_exists(0, $vars) && 1 === count($vars)) { VarDumper::dump($vars[0]); $k = 0; } else { diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php index 13d69f833195b..c31d07d2f26a5 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php @@ -69,7 +69,7 @@ public function testGet() é\\x01test\\t\\n ing """ - "bo\\u{FEFF}m" => "te\\u{FEFF}st" + "bo\\u{FEFF}m" => "te\\u{FEFF}st" "[]" => [] "res" => stream resource @{$res} %A wrapper_type: "plainfile" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy