This commit is contained in:
2025-05-12 14:25:25 +02:00
parent ab2db755ef
commit 9e378ca2b7
2719 changed files with 46505 additions and 60181 deletions

View File

@@ -47,7 +47,7 @@ class Caster
*
* @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not
*/
public static function castObject(object $obj, string $class, bool $hasDebugInfo = false, string $debugClass = null): array
public static function castObject(object $obj, string $class, bool $hasDebugInfo = false, ?string $debugClass = null): array
{
if ($hasDebugInfo) {
try {

View File

@@ -24,7 +24,7 @@ class ClassStub extends ConstStub
* @param string $identifier A PHP identifier, e.g. a class, method, interface, etc. name
* @param callable $callable The callable targeted by the identifier when it is ambiguous or not a real PHP identifier
*/
public function __construct(string $identifier, callable|array|string $callable = null)
public function __construct(string $identifier, callable|array|string|null $callable = null)
{
$this->value = $identifier;
@@ -56,7 +56,7 @@ class ClassStub extends ConstStub
}
if (str_contains($identifier, "@anonymous\0")) {
$this->value = $identifier = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $identifier);
$this->value = $identifier = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $identifier);
}
if (null !== $callable && $r instanceof \ReflectionFunctionAbstract) {

View File

@@ -20,7 +20,7 @@ use Symfony\Component\VarDumper\Cloner\Stub;
*/
class ConstStub extends Stub
{
public function __construct(string $name, string|int|float $value = null)
public function __construct(string $name, string|int|float|null $value = null)
{
$this->class = $name;
$this->value = 1 < \func_num_args() ? $value : $name;

View File

@@ -27,7 +27,7 @@ class CutStub extends Stub
switch (\gettype($value)) {
case 'object':
$this->type = self::TYPE_OBJECT;
$this->class = $value::class;
$this->class = get_debug_type($value);
if ($value instanceof \Closure) {
ReflectionCaster::castClosure($value, [], $this, true, Caster::EXCLUDE_VERBOSE);

View File

@@ -23,7 +23,7 @@ use Symfony\Component\VarDumper\Cloner\Stub;
class DOMCaster
{
private const ERROR_CODES = [
\DOM_PHP_ERR => 'DOM_PHP_ERR',
0 => 'DOM_PHP_ERR',
\DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR',
\DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR',
\DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR',
@@ -156,16 +156,12 @@ class DOMCaster
'doctype' => $dom->doctype,
'implementation' => $dom->implementation,
'documentElement' => new CutStub($dom->documentElement),
'actualEncoding' => $dom->actualEncoding,
'encoding' => $dom->encoding,
'xmlEncoding' => $dom->xmlEncoding,
'standalone' => $dom->standalone,
'xmlStandalone' => $dom->xmlStandalone,
'version' => $dom->version,
'xmlVersion' => $dom->xmlVersion,
'strictErrorChecking' => $dom->strictErrorChecking,
'documentURI' => $dom->documentURI ? new LinkStub($dom->documentURI) : $dom->documentURI,
'config' => $dom->config,
'formatOutput' => $dom->formatOutput,
'validateOnParse' => $dom->validateOnParse,
'resolveExternals' => $dom->resolveExternals,
@@ -277,9 +273,6 @@ class DOMCaster
'publicId' => $dom->publicId,
'systemId' => $dom->systemId,
'notationName' => $dom->notationName,
'actualEncoding' => $dom->actualEncoding,
'encoding' => $dom->encoding,
'version' => $dom->version,
];
return $a;

View File

@@ -42,7 +42,7 @@ class ExceptionCaster
\E_USER_ERROR => 'E_USER_ERROR',
\E_USER_WARNING => 'E_USER_WARNING',
\E_USER_NOTICE => 'E_USER_NOTICE',
\E_STRICT => 'E_STRICT',
2048 => 'E_STRICT',
];
private static array $framesCache = [];
@@ -323,7 +323,7 @@ class ExceptionCaster
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message']);
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && str_contains($a[Caster::PREFIX_PROTECTED.'message'], "@anonymous\0")) {
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $a[Caster::PREFIX_PROTECTED.'message']);
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $a[Caster::PREFIX_PROTECTED.'message']);
}
if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) {

View File

@@ -97,7 +97,7 @@ final class FFICaster
return [Caster::PREFIX_VIRTUAL.'returnType' => $returnType];
}
private static function castFFIPointer(Stub $stub, CType $type, CData $data = null): array
private static function castFFIPointer(Stub $stub, CType $type, ?CData $data = null): array
{
$ptr = $type->getPointerType();
@@ -115,11 +115,21 @@ final class FFICaster
private static function castFFIStringValue(CData $data): string|CutStub
{
$result = [];
$ffi = \FFI::cdef(<<<C
size_t zend_get_page_size(void);
C);
for ($i = 0; $i < self::MAX_STRING_LENGTH; ++$i) {
$pageSize = $ffi->zend_get_page_size();
// get cdata address
$start = $ffi->cast('uintptr_t', $ffi->cast('char*', $data))->cdata;
// accessing memory in the same page as $start is safe
$max = min(self::MAX_STRING_LENGTH, ($start | ($pageSize - 1)) - $start);
for ($i = 0; $i < $max; ++$i) {
$result[$i] = $data[$i];
if ("\0" === $result[$i]) {
if ("\0" === $data[$i]) {
return implode('', $result);
}
}
@@ -132,7 +142,7 @@ final class FFICaster
return $stub;
}
private static function castFFIStructLike(CType $type, CData $data = null): array
private static function castFFIStructLike(CType $type, ?CData $data = null): array
{
$isUnion = ($type->getAttributes() & CType::ATTR_UNION) === CType::ATTR_UNION;

View File

@@ -23,7 +23,7 @@ class LinkStub extends ConstStub
private static array $vendorRoots;
private static array $composerRoots = [];
public function __construct(string $label, int $line = 0, string $href = null)
public function __construct(string $label, int $line = 0, ?string $href = null)
{
$this->value = $label;

View File

@@ -45,7 +45,7 @@ class ReflectionCaster
$a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter);
if (!str_contains($c->name, '{closure}')) {
if (!str_contains($c->name, '{closure')) {
$stub->class = isset($a[$prefix.'class']) ? $a[$prefix.'class']->value.'::'.$c->name : $c->name;
unset($a[$prefix.'class']);
}
@@ -89,13 +89,13 @@ class ReflectionCaster
// Cannot create ReflectionGenerator based on a terminated Generator
try {
$reflectionGenerator = new \ReflectionGenerator($c);
return self::castReflectionGenerator($reflectionGenerator, $a, $stub, $isNested);
} catch (\Exception) {
$a[Caster::PREFIX_VIRTUAL.'closed'] = true;
return $a;
}
return self::castReflectionGenerator($reflectionGenerator, $a, $stub, $isNested);
}
/**
@@ -128,10 +128,16 @@ class ReflectionCaster
*/
public static function castAttribute(\ReflectionAttribute $c, array $a, Stub $stub, bool $isNested)
{
self::addMap($a, $c, [
$map = [
'name' => 'getName',
'arguments' => 'getArguments',
]);
];
if (\PHP_VERSION_ID >= 80400) {
unset($map['name']);
}
self::addMap($a, $c, $map);
return $a;
}
@@ -225,7 +231,7 @@ class ReflectionCaster
if (isset($a[$prefix.'returnType'])) {
$v = $a[$prefix.'returnType'];
$v = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v;
$a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType'] instanceof \ReflectionNamedType && $a[$prefix.'returnType']->allowsNull() && 'mixed' !== $v ? '?'.$v : $v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);
$a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType'] instanceof \ReflectionNamedType && $a[$prefix.'returnType']->allowsNull() && !\in_array($v, ['mixed', 'null'], true) ? '?'.$v : $v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);
}
if (isset($a[$prefix.'class'])) {
$a[$prefix.'class'] = new ClassStub($a[$prefix.'class']);
@@ -407,7 +413,7 @@ class ReflectionCaster
if (!$type instanceof \ReflectionNamedType) {
$signature .= $type.' ';
} else {
if (!$param->isOptional() && $param->allowsNull() && 'mixed' !== $type->getName()) {
if ($param->allowsNull() && !\in_array($type->getName(), ['mixed', 'null'], true)) {
$signature .= '?';
}
$signature .= substr(strrchr('\\'.$type->getName(), '\\'), 1).' ';

View File

@@ -25,7 +25,7 @@ class TraceStub extends Stub
public $sliceLength;
public $numberingOffset;
public function __construct(array $trace, bool $keepArgs = true, int $sliceOffset = 0, int $sliceLength = null, int $numberingOffset = 0)
public function __construct(array $trace, bool $keepArgs = true, int $sliceOffset = 0, ?int $sliceLength = null, int $numberingOffset = 0)
{
$this->value = $trace;
$this->keepArgs = $keepArgs;

View File

@@ -219,7 +219,7 @@ abstract class AbstractCloner implements ClonerInterface
*
* @see addCasters
*/
public function __construct(array $casters = null)
public function __construct(?array $casters = null)
{
$this->addCasters($casters ?? static::$defaultCasters);
}

View File

@@ -0,0 +1,25 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\VarDumper\Cloner\Internal;
/**
* Flags a typed property that has no default value.
*
* This dummy object is used to distinguish a property with a default value of null
* from a property that is uninitialized by default.
*
* @internal
*/
enum NoDefault
{
case NoDefault;
}

View File

@@ -11,6 +11,8 @@
namespace Symfony\Component\VarDumper\Cloner;
use Symfony\Component\VarDumper\Cloner\Internal\NoDefault;
/**
* Represents the main properties of a PHP variable.
*
@@ -50,15 +52,20 @@ class Stub
$properties = [];
if (!isset(self::$defaultProperties[$c = static::class])) {
self::$defaultProperties[$c] = get_class_vars($c);
$reflection = new \ReflectionClass($c);
self::$defaultProperties[$c] = [];
foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) {
unset(self::$defaultProperties[$c][$k]);
foreach ($reflection->getProperties() as $p) {
if ($p->isStatic()) {
continue;
}
self::$defaultProperties[$c][$p->name] = $p->hasDefaultValue() ? $p->getDefaultValue() : ($p->hasType() ? NoDefault::NoDefault : null);
}
}
foreach (self::$defaultProperties[$c] as $k => $v) {
if ($this->$k !== $v) {
if (NoDefault::NoDefault === $v || $this->$k !== $v) {
$properties[] = $k;
}
}

View File

@@ -45,7 +45,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
* @param string|null $charset The default character encoding to use for non-UTF8 strings
* @param int $flags A bit field of static::DUMP_* constants to fine tune dumps representation
*/
public function __construct($output = null, string $charset = null, int $flags = 0)
public function __construct($output = null, ?string $charset = null, int $flags = 0)
{
$this->flags = $flags;
$this->setCharset($charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8');

View File

@@ -11,6 +11,7 @@
namespace Symfony\Component\VarDumper\Dumper;
use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter;
use Symfony\Component\VarDumper\Cloner\Cursor;
use Symfony\Component\VarDumper\Cloner\Stub;
@@ -63,7 +64,7 @@ class CliDumper extends AbstractDumper
private bool $handlesHrefGracefully;
public function __construct($output = null, string $charset = null, int $flags = 0)
public function __construct($output = null, ?string $charset = null, int $flags = 0)
{
parent::__construct($output, $charset, $flags);
@@ -82,7 +83,7 @@ class CliDumper extends AbstractDumper
]);
}
$this->displayOptions['fileLinkFormat'] = \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l';
$this->displayOptions['fileLinkFormat'] = class_exists(FileLinkFormatter::class) ? new FileLinkFormatter() : (\ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l');
}
/**
@@ -577,6 +578,10 @@ class CliDumper extends AbstractDumper
*/
protected function dumpLine(int $depth, bool $endOfValue = false)
{
if (null === $this->colors) {
$this->colors = $this->supportsColors();
}
if ($this->colors) {
$this->line = sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line);
}
@@ -616,23 +621,34 @@ class CliDumper extends AbstractDumper
}
// Follow https://no-color.org/
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
if ('' !== (($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR'))[0] ?? '')) {
return false;
}
if ('Hyper' === getenv('TERM_PROGRAM')) {
// Detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
return false;
}
if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($stream)) {
return true;
}
if (\DIRECTORY_SEPARATOR === '\\') {
return (\function_exists('sapi_windows_vt100_support')
&& @sapi_windows_vt100_support($stream))
|| false !== getenv('ANSICON')
|| 'ON' === getenv('ConEmuANSI')
|| 'xterm' === getenv('TERM');
if ('Hyper' === getenv('TERM_PROGRAM')
|| false !== getenv('COLORTERM')
|| false !== getenv('ANSICON')
|| 'ON' === getenv('ConEmuANSI')
) {
return true;
}
return stream_isatty($stream);
if ('dumb' === $term = (string) getenv('TERM')) {
return false;
}
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
}
/**

View File

@@ -31,7 +31,7 @@ final class SourceContextProvider implements ContextProviderInterface
private ?string $projectDir;
private FileLinkFormatter|LegacyFileLinkFormatter|null $fileLinkFormatter;
public function __construct(string $charset = null, string $projectDir = null, FileLinkFormatter|LegacyFileLinkFormatter $fileLinkFormatter = null, int $limit = 9)
public function __construct(?string $charset = null, ?string $projectDir = null, FileLinkFormatter|LegacyFileLinkFormatter|null $fileLinkFormatter = null, int $limit = 9)
{
$this->charset = $charset;
$this->projectDir = $projectDir;

View File

@@ -75,7 +75,7 @@ class HtmlDumper extends CliDumper
];
private array $extraDisplayOptions = [];
public function __construct($output = null, string $charset = null, int $flags = 0)
public function __construct($output = null, ?string $charset = null, int $flags = 0)
{
AbstractDumper::__construct($output, $charset, $flags);
$this->dumpId = 'sf-dump-'.mt_rand();
@@ -663,7 +663,7 @@ pre.sf-dump:after {
height: 0;
clear: both;
}
pre.sf-dump span {
pre.sf-dump .sf-dump-ellipsization {
display: inline-flex;
}
pre.sf-dump a {
@@ -681,16 +681,12 @@ pre.sf-dump img {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAHUlEQVQY02O8zAABilCaiQEN0EeA8QuUcX9g3QEAAjcC5piyhyEAAAAASUVORK5CYII=) #D3D3D3;
}
pre.sf-dump .sf-dump-ellipsis {
display: inline-block;
overflow: visible;
text-overflow: ellipsis;
max-width: 5em;
white-space: nowrap;
overflow: hidden;
vertical-align: top;
}
pre.sf-dump .sf-dump-ellipsis+.sf-dump-ellipsis {
max-width: none;
pre.sf-dump .sf-dump-ellipsis-tail {
flex-shrink: 0;
}
pre.sf-dump code {
display:inline;
@@ -863,66 +859,75 @@ EOHTML
return sprintf('<a class=sf-dump-ref href=#%s-ref%s title="%d occurrences">%s</a>', $this->dumpId, $r, 1 + $attr['count'], $v);
}
$dumpClasses = ['sf-dump-'.$style];
$dumpTitle = '';
if ('const' === $style && isset($attr['value'])) {
$style .= sprintf(' title="%s"', esc(\is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value'])));
$dumpTitle = esc(\is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value']));
} elseif ('public' === $style) {
$style .= sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property');
$dumpTitle = empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property';
} elseif ('str' === $style && 1 < $attr['length']) {
$style .= sprintf(' title="%d%s characters"', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : '');
$dumpTitle = sprintf('%d%s characters', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : '');
} elseif ('note' === $style && 0 < ($attr['depth'] ?? 0) && false !== $c = strrpos($value, '\\')) {
$style .= ' title=""';
$attr += [
'ellipsis' => \strlen($value) - $c,
'ellipsis-type' => 'note',
'ellipsis-tail' => 1,
];
} elseif ('protected' === $style) {
$style .= ' title="Protected property"';
$dumpTitle = 'Protected property';
} elseif ('meta' === $style && isset($attr['title'])) {
$style .= sprintf(' title="%s"', esc($this->utf8Encode($attr['title'])));
$dumpTitle = esc($this->utf8Encode($attr['title']));
} elseif ('private' === $style) {
$style .= sprintf(' title="Private property defined in class:&#10;`%s`"', esc($this->utf8Encode($attr['class'])));
$dumpTitle = sprintf('Private property defined in class:&#10;`%s`', esc($this->utf8Encode($attr['class'])));
}
if (isset($attr['ellipsis'])) {
$class = 'sf-dump-ellipsis';
$dumpClasses[] = 'sf-dump-ellipsization';
$ellipsisClass = 'sf-dump-ellipsis';
if (isset($attr['ellipsis-type'])) {
$class = sprintf('"%s sf-dump-ellipsis-%s"', $class, $attr['ellipsis-type']);
$ellipsisClass .= ' sf-dump-ellipsis-'.$attr['ellipsis-type'];
}
$label = esc(substr($value, -$attr['ellipsis']));
$style = str_replace(' title="', " title=\"$v\n", $style);
$v = sprintf('<span class=%s>%s</span>', $class, substr($v, 0, -\strlen($label)));
$dumpTitle = $v."\n".$dumpTitle;
$v = sprintf('<span class="%s">%s</span>', $ellipsisClass, substr($v, 0, -\strlen($label)));
if (!empty($attr['ellipsis-tail'])) {
$tail = \strlen(esc(substr($value, -$attr['ellipsis'], $attr['ellipsis-tail'])));
$v .= sprintf('<span class=%s>%s</span>%s', $class, substr($label, 0, $tail), substr($label, $tail));
$v .= sprintf('<span class="%s">%s</span><span class="sf-dump-ellipsis-tail">%s</span>', $ellipsisClass, substr($label, 0, $tail), substr($label, $tail));
} else {
$v .= $label;
$v .= sprintf('<span class="sf-dump-ellipsis-tail">%s</span>', $label);
}
}
$map = static::$controlCharsMap;
$v = "<span class=sf-dump-{$style}>".preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) {
$s = $b = '<span class="sf-dump-default';
$c = $c[$i = 0];
if ($ns = "\r" === $c[$i] || "\n" === $c[$i]) {
$s .= ' sf-dump-ns';
}
$s .= '">';
do {
if (("\r" === $c[$i] || "\n" === $c[$i]) !== $ns) {
$s .= '</span>'.$b;
if ($ns = !$ns) {
$s .= ' sf-dump-ns';
}
$s .= '">';
$v = sprintf(
'<span class=%s%s%1$s%s>%s</span>',
1 === count($dumpClasses) ? '' : '"',
implode(' ', $dumpClasses),
$dumpTitle ? ' title="'.$dumpTitle.'"' : '',
preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) {
$s = $b = '<span class="sf-dump-default';
$c = $c[$i = 0];
if ($ns = "\r" === $c[$i] || "\n" === $c[$i]) {
$s .= ' sf-dump-ns';
}
$s .= '">';
do {
if (("\r" === $c[$i] || "\n" === $c[$i]) !== $ns) {
$s .= '</span>'.$b;
if ($ns = !$ns) {
$s .= ' sf-dump-ns';
}
$s .= '">';
}
$s .= $map[$c[$i]] ?? sprintf('\x%02X', \ord($c[$i]));
} while (isset($c[++$i]));
$s .= $map[$c[$i]] ?? sprintf('\x%02X', \ord($c[$i]));
} while (isset($c[++$i]));
return $s.'</span>';
}, $v).'</span>';
return $s.'</span>';
}, $v)
);
if (!($attr['binary'] ?? false)) {
$v = preg_replace_callback(static::$unicodeCharsRx, function ($c) {

View File

@@ -30,7 +30,7 @@ class ServerDumper implements DataDumperInterface
* @param DataDumperInterface|null $wrappedDumper A wrapped instance used whenever we failed contacting the server
* @param ContextProviderInterface[] $contextProviders Context providers indexed by context name
*/
public function __construct(string $host, DataDumperInterface $wrappedDumper = null, array $contextProviders = [])
public function __construct(string $host, ?DataDumperInterface $wrappedDumper = null, array $contextProviders = [])
{
$this->connection = new Connection($host, $contextProviders);
$this->wrappedDumper = $wrappedDumper;

0
vendor/symfony/var-dumper/Resources/bin/var-dump-server vendored Normal file → Executable file
View File

View File

@@ -32,7 +32,7 @@ class DumpServer
*/
private $socket;
public function __construct(string $host, LoggerInterface $logger = null)
public function __construct(string $host, ?LoggerInterface $logger = null)
{
if (!str_contains($host, '://')) {
$host = 'tcp://'.$host;

View File

@@ -27,7 +27,7 @@ trait VarDumperTestTrait
'flags' => null,
];
protected function setUpVarDumper(array $casters, int $flags = null): void
protected function setUpVarDumper(array $casters, ?int $flags = null): void
{
$this->varDumperConfig['casters'] = $casters;
$this->varDumperConfig['flags'] = $flags;
@@ -52,7 +52,7 @@ trait VarDumperTestTrait
$this->assertStringMatchesFormat($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message);
}
protected function getDump(mixed $data, string|int $key = null, int $filter = 0): ?string
protected function getDump(mixed $data, string|int|null $key = null, int $filter = 0): ?string
{
if (null === $flags = $this->varDumperConfig['flags']) {
$flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0;

View File

@@ -52,7 +52,7 @@ class VarDumper
return (self::$handler)($var, $label);
}
public static function setHandler(callable $callable = null): ?callable
public static function setHandler(?callable $callable = null): ?callable
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/var-dumper', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
@@ -96,7 +96,7 @@ class VarDumper
$dumper = new ContextualizedDumper($dumper, [new SourceContextProvider()]);
}
self::$handler = function ($var, string $label = null) use ($cloner, $dumper) {
self::$handler = function ($var, ?string $label = null) use ($cloner, $dumper) {
$var = $cloner->cloneVar($var);
if (null !== $label) {