mirror of
https://github.com/symfony/var-dumper.git
synced 2026-03-23 23:42:22 +01:00
PHP CS Fixer: enable static_lambda for VarDumper
This commit is contained in:
committed by
Nicolas Grekas
parent
3aeea6769f
commit
49cf224653
@@ -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]++/', static 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) {
|
||||
|
||||
@@ -301,7 +301,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]++/', static 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'])) {
|
||||
|
||||
@@ -90,7 +90,7 @@ class ServerDumpCommand extends Command
|
||||
$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) {
|
||||
$this->server->listen(static function (Data $data, array $context, int $clientId) use ($descriptor, $io) {
|
||||
$descriptor->describe($io, $data, $context, $clientId);
|
||||
});
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ class CliDumper extends AbstractDumper
|
||||
$map = static::$controlCharsMap;
|
||||
$startCchr = $this->colors ? "\033[m\033[{$this->styles['default']}m" : '';
|
||||
$endCchr = $this->colors ? "\033[m\033[{$this->styles[$style]}m" : '';
|
||||
$value = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $startCchr, $endCchr) {
|
||||
$value = preg_replace_callback(static::$controlCharsRx, static function ($c) use ($map, $startCchr, $endCchr) {
|
||||
$s = $startCchr;
|
||||
$c = $c[$i = 0];
|
||||
do {
|
||||
@@ -470,7 +470,7 @@ class CliDumper extends AbstractDumper
|
||||
}, $value, -1, $cchrCount);
|
||||
|
||||
if (!($attr['binary'] ?? false)) {
|
||||
$value = preg_replace_callback(static::$unicodeCharsRx, function ($c) use (&$cchrCount, $startCchr, $endCchr) {
|
||||
$value = preg_replace_callback(static::$unicodeCharsRx, static function ($c) use (&$cchrCount, $startCchr, $endCchr) {
|
||||
++$cchrCount;
|
||||
|
||||
return $startCchr.'\u{'.strtoupper(dechex(mb_ord($c[0]))).'}'.$endCchr;
|
||||
|
||||
@@ -109,7 +109,7 @@ final class SourceContextProvider implements ContextProviderInterface
|
||||
{
|
||||
$html = '';
|
||||
|
||||
$dumper = new HtmlDumper(function ($line) use (&$html) { $html .= $line; }, $this->charset);
|
||||
$dumper = new HtmlDumper(static function ($line) use (&$html) { $html .= $line; }, $this->charset);
|
||||
$dumper->setDumpHeader('');
|
||||
$dumper->setDumpBoundaries('', '');
|
||||
|
||||
|
||||
@@ -883,7 +883,7 @@ class HtmlDumper extends CliDumper
|
||||
1 === \count($dumpClasses) ? '' : '"',
|
||||
implode(' ', $dumpClasses),
|
||||
$dumpTitle ? ' title="'.$dumpTitle.'"' : '',
|
||||
preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) {
|
||||
preg_replace_callback(static::$controlCharsRx, static function ($c) use ($map) {
|
||||
$s = $b = '<span class="sf-dump-default';
|
||||
$c = $c[$i = 0];
|
||||
if ($ns = "\r" === $c[$i] || "\n" === $c[$i]) {
|
||||
@@ -907,7 +907,7 @@ class HtmlDumper extends CliDumper
|
||||
);
|
||||
|
||||
if (!($attr['binary'] ?? false)) {
|
||||
$v = preg_replace_callback(static::$unicodeCharsRx, function ($c) {
|
||||
$v = preg_replace_callback(static::$unicodeCharsRx, static function ($c) {
|
||||
return '<span class=sf-dump-default>\u{'.strtoupper(dechex(mb_ord($c[0]))).'}</span>';
|
||||
}, $v);
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ class RdKafkaCasterTest extends TestCase
|
||||
public function testDumpConf()
|
||||
{
|
||||
$conf = new Conf();
|
||||
$conf->setErrorCb(function ($kafka, $err, $reason) {});
|
||||
$conf->setDrMsgCb(function () {});
|
||||
$conf->setRebalanceCb(function () {});
|
||||
$conf->setErrorCb(static function ($kafka, $err, $reason) {});
|
||||
$conf->setDrMsgCb(static function () {});
|
||||
$conf->setRebalanceCb(static function () {});
|
||||
|
||||
// BC with earlier version of extension rdkafka
|
||||
foreach (['setLogCb', 'setOffsetCommitCb', 'setStatsCb', 'setConsumeCb'] as $method) {
|
||||
if (method_exists($conf, $method)) {
|
||||
$conf->{$method}(function () {});
|
||||
$conf->{$method}(static function () {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class ReflectionCasterTest extends TestCase
|
||||
public function testClosureCaster()
|
||||
{
|
||||
$a = $b = 123;
|
||||
$var = function ($x) use ($a, &$b) { var_dump($a, $b); };
|
||||
$var = static function ($x) use ($a, &$b) { var_dump($a, $b); };
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<'EOTXT'
|
||||
@@ -131,9 +131,11 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testClosureCasterExcludingVerbosity()
|
||||
{
|
||||
$var = function &($a = 5) {};
|
||||
$var = function &($a = 123) {
|
||||
\assert(null !== $this);
|
||||
};
|
||||
|
||||
$this->assertDumpEquals('Closure&($a = 5) { …5}', $var, Caster::EXCLUDE_VERBOSE);
|
||||
$this->assertDumpEquals('Closure&($a = 123) { …5}', $var, Caster::EXCLUDE_VERBOSE);
|
||||
}
|
||||
|
||||
public function testReflectionParameter()
|
||||
@@ -155,7 +157,7 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testReflectionParameterScalar()
|
||||
{
|
||||
$f = function (int $a) {};
|
||||
$f = static function (int $a) {};
|
||||
$var = new \ReflectionParameter($f, 0);
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
@@ -172,7 +174,7 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testReflectionParameterMixed()
|
||||
{
|
||||
$f = function (mixed $a) {};
|
||||
$f = static function (mixed $a) {};
|
||||
$var = new \ReflectionParameter($f, 0);
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
@@ -190,7 +192,7 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testReflectionParameterUnion()
|
||||
{
|
||||
$f = function (int|float $a) {};
|
||||
$f = static function (int|float $a) {};
|
||||
$var = new \ReflectionParameter($f, 0);
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
@@ -207,7 +209,7 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testReflectionParameterNullableUnion()
|
||||
{
|
||||
$f = function (int|float|null $a) {};
|
||||
$f = static function (int|float|null $a) {};
|
||||
$var = new \ReflectionParameter($f, 0);
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
@@ -225,7 +227,7 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testReflectionParameterIntersection()
|
||||
{
|
||||
$f = function (\Traversable&\Countable $a) {};
|
||||
$f = static function (\Traversable&\Countable $a) {};
|
||||
$var = new \ReflectionParameter($f, 0);
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
@@ -370,7 +372,9 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testReturnType()
|
||||
{
|
||||
$f = function (): int {};
|
||||
$f = function (): int {
|
||||
\assert(null !== $this);
|
||||
};
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
@@ -388,7 +392,9 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testMixedReturnType()
|
||||
{
|
||||
$f = function (): mixed {};
|
||||
$f = function (): mixed {
|
||||
\assert(null !== $this);
|
||||
};
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
@@ -423,7 +429,9 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testUnionReturnType()
|
||||
{
|
||||
$f = function (): int|float {};
|
||||
$f = function (): int|float {
|
||||
\assert(null !== $this);
|
||||
};
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
@@ -441,7 +449,9 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testNullableUnionReturnType()
|
||||
{
|
||||
$f = function (): int|float|null {};
|
||||
$f = function (): int|float|null {
|
||||
\assert(null !== $this);
|
||||
};
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
@@ -537,7 +547,9 @@ class ReflectionCasterTest extends TestCase
|
||||
|
||||
public function testNewInInitializer()
|
||||
{
|
||||
$f = function ($a = new \stdClass()) {};
|
||||
$f = function ($a = new \stdClass()) {
|
||||
\assert(null !== $this);
|
||||
};
|
||||
|
||||
$this->assertDumpMatchesFormat(
|
||||
<<<EOTXT
|
||||
|
||||
@@ -35,13 +35,13 @@ class VarClonerTest extends TestCase
|
||||
};
|
||||
|
||||
AbstractCloner::addDefaultCasters([
|
||||
$o1::class => function ($obj, $array) {
|
||||
$o1::class => static function ($obj, $array) {
|
||||
$array['p1'] = 123;
|
||||
|
||||
return $array;
|
||||
},
|
||||
// Test we can override the default casters
|
||||
\DateTimeInterface::class => function (\DateTimeInterface $obj, $array, Stub $stub, bool $isNested, int $filter) {
|
||||
\DateTimeInterface::class => static function (\DateTimeInterface $obj, $array, Stub $stub, bool $isNested, int $filter) {
|
||||
$array = DateCaster::castDateTime($obj, $array, $stub, $isNested, $filter);
|
||||
$array['foo'] = 'bar';
|
||||
|
||||
@@ -50,7 +50,7 @@ class VarClonerTest extends TestCase
|
||||
]);
|
||||
$cloner = new VarCloner();
|
||||
$cloner->addCasters([
|
||||
$o2::class => function ($obj, $array) {
|
||||
$o2::class => static function ($obj, $array) {
|
||||
$array['p2'] = 456;
|
||||
|
||||
return $array;
|
||||
@@ -461,8 +461,8 @@ class VarClonerTest extends TestCase
|
||||
public function testCaster()
|
||||
{
|
||||
$cloner = new VarCloner([
|
||||
'*' => fn ($obj, $array) => ['foo' => 123],
|
||||
__CLASS__ => function ($obj, $array) {
|
||||
'*' => static fn ($obj, $array) => ['foo' => 123],
|
||||
__CLASS__ => static function ($obj, $array) {
|
||||
++$array['foo'];
|
||||
|
||||
return $array;
|
||||
|
||||
@@ -43,7 +43,7 @@ class CliDescriptorTest extends TestCase
|
||||
{
|
||||
$output = new BufferedOutput();
|
||||
$output->setDecorated($decorated);
|
||||
$descriptor = new CliDescriptor(new CliDumper(fn ($s) => $s));
|
||||
$descriptor = new CliDescriptor(new CliDumper(static fn ($s) => $s));
|
||||
|
||||
$descriptor->describe($output, new Data([[123]]), $context + ['timestamp' => 1544804268.3668], 1);
|
||||
|
||||
|
||||
@@ -40,12 +40,12 @@ class CliDumperTest extends TestCase
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
$cloner->addCasters([
|
||||
':stream' => function ($res, $a) {
|
||||
':stream' => static function ($res, $a) {
|
||||
unset($a['uri'], $a['wrapper_data']);
|
||||
|
||||
return $a;
|
||||
},
|
||||
'Symfony\Component\VarDumper\Tests\Fixture\DumbFoo' => function ($foo, $a) {
|
||||
'Symfony\Component\VarDumper\Tests\Fixture\DumbFoo' => static function ($foo, $a) {
|
||||
$a['foo'] = new CutStub($a['foo']);
|
||||
|
||||
return $a;
|
||||
@@ -324,7 +324,7 @@ class CliDumperTest extends TestCase
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
$cloner->addCasters([
|
||||
':stream' => function ($res, $a) {
|
||||
':stream' => static function ($res, $a) {
|
||||
unset($a['wrapper_data']);
|
||||
|
||||
return $a;
|
||||
@@ -450,7 +450,7 @@ class CliDumperTest extends TestCase
|
||||
}
|
||||
|
||||
$out = '';
|
||||
$dumper = new CliDumper(function ($line, $depth) use (&$out) {
|
||||
$dumper = new CliDumper(static function ($line, $depth) use (&$out) {
|
||||
if ($depth >= 0) {
|
||||
$out .= str_repeat(' ', $depth).$line."\n";
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class FunctionsTest extends TestCase
|
||||
{
|
||||
$cloner = new VarCloner();
|
||||
$dumper = new CliDumper('php://output');
|
||||
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
|
||||
VarDumper::setHandler(static function ($var) use ($cloner, $dumper) {
|
||||
$dumper->dump($cloner->cloneVar($var));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class HtmlDumperTest extends TestCase
|
||||
$dumper->setDumpBoundaries('<bar>', '</bar>');
|
||||
$cloner = new VarCloner();
|
||||
$cloner->addCasters([
|
||||
':stream' => function ($res, $a) {
|
||||
':stream' => static function ($res, $a) {
|
||||
unset($a['uri'], $a['wrapper_data']);
|
||||
|
||||
return $a;
|
||||
|
||||
@@ -89,7 +89,7 @@ class VarDumper
|
||||
$dumper = new ContextualizedDumper($dumper, [new SourceContextProvider()]);
|
||||
}
|
||||
|
||||
self::$handler = function ($var, ?string $label = null) use ($cloner, $dumper) {
|
||||
self::$handler = static function ($var, ?string $label = null) use ($cloner, $dumper) {
|
||||
$var = $cloner->cloneVar($var);
|
||||
|
||||
if (null !== $label) {
|
||||
|
||||
Reference in New Issue
Block a user