Skip to content
Permalink
Browse files

minor #30295 [VarDumper] dump Closures' parameters once: in their sig…

…natures (nicolas-grekas)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[VarDumper] dump Closures' parameters once: in their signatures

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | not really
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Now that closures are dumped with their signature, dumping parameters is noisy duplicate info.

Commits
-------

f3659b6 [VarDumper] dump Closures' parameters once: in their signatures
  • Loading branch information...
nicolas-grekas committed Feb 19, 2019
2 parents 98693be + f3659b6 commit e7430f46330b06403506733434e6a8e87f287256
@@ -52,18 +52,7 @@ public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested,
return [];
}
if (isset($a[$prefix.'parameters'])) {
foreach ($a[$prefix.'parameters']->value as &$v) {
$param = $v;
$v = new EnumStub([]);
foreach (static::castParameter($param, [], $stub, true) as $k => $param) {
if ("\0" === $k[0]) {
$v->value[substr($k, 3)] = $param;
}
}
unset($v->value['position'], $v->value['isVariadic'], $v->value['byReference'], $v);
}
}
unset($a[$prefix.'parameters']);
if ($f = $c->getFileName()) {
$a[$prefix.'file'] = new LinkStub($f, $c->getStartLine());
@@ -70,10 +70,7 @@ public function testClosureCaster()
$this->assertDumpMatchesFormat(
<<<'EOTXT'
Closure($x) {
%Aparameters: {
$x: {}
}
use: {
%Ause: {
$a: 123
$b: & 123
}
@@ -81,13 +81,6 @@ public function testGet()
"closure" => Closure(\$a, PDO &\$b = null) {#%d
class: "Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest"
this: Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest {#%d …}
parameters: {
\$a: {}
&\$b: {
typeHint: "PDO"
default: null
}
}
file: "%s%eTests%eFixtures%edumb-var.php"
line: "{$var['line']} to {$var['line']}"
}
@@ -85,13 +85,6 @@ public function testGet()
<span class=sf-dump-meta>class</span>: "<span class=sf-dump-str title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest
55 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Dumper</span><span class=sf-dump-ellipsis>\</span>HtmlDumperTest</span>"
<span class=sf-dump-meta>this</span>: <abbr title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest" class=sf-dump-note>HtmlDumperTest</abbr> {<a class=sf-dump-ref>#%d</a> &%s;}
<span class=sf-dump-meta>parameters</span>: {<samp>
<span class=sf-dump-meta>\$a</span>: {}
<span class=sf-dump-meta>&amp;\$b</span>: {<samp>
<span class=sf-dump-meta>typeHint</span>: "<span class=sf-dump-str title="3 characters">PDO</span>"
<span class=sf-dump-meta>default</span>: <span class=sf-dump-const>null</span>
</samp>}
</samp>}
<span class=sf-dump-meta>file</span>: "<span class=sf-dump-str title="{$var['file']}
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eFixtures%edumb-var.php</span>"
<span class=sf-dump-meta>line</span>: "<span class=sf-dump-str title="%d characters">{$var['line']} to {$var['line']}</span>"

0 comments on commit e7430f4

Please sign in to comment.
You can’t perform that action at this time.