Skip to content

Commit a86a419

Browse files
Merge branch '2.6' into 2.7
* 2.6: [VarDumper] Fix dumping references as properties [VarDumper] Fix toggle action to see source excerpt
2 parents 6ef1204 + 82400f8 commit a86a419

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/dump.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
{{ dump.name }}
8686
{% endif %}
8787
line {{ dump.line }}:
88-
<a onclick="Sfdump.toggle(this)">▶</a>
88+
<a onclick="var s = this.nextElementSibling; if ('sf-dump-compact' == s.className) {this.innerHTML = '&#9660;'; s.className = 'sf-dump-expanded';} else {this.innerHTML = '&#9654;'; s.className = 'sf-dump-compact';}">&#9654;</a>
8989
<span class="sf-dump-compact">
9090
{% if dump.fileExcerpt %}{{ dump.fileExcerpt|raw }}{% else %}{{ dump.file|file_excerpt(dump.line) }}{% endif %}
9191
</span>

src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,19 @@ protected function castObject(Stub $stub, $isNested)
215215
}
216216

217217
if ($classInfo[1]) {
218-
$p = $this->callCaster(function ($obj) {return $obj->__debugInfo();}, $obj, array(), null, $isNested);
218+
$a = $this->callCaster(function ($obj) {return $obj->__debugInfo();}, $obj, array(), null, $isNested);
219219
} else {
220-
$p = (array) $obj;
220+
$a = (array) $obj;
221221
}
222222

223-
$a = array();
224-
foreach ($p as $k => $p) {
225-
if (!isset($k[0]) || ("\0" !== $k[0] && !$classInfo[2]->hasProperty($k))) {
226-
$a["\0+\0".$k] = $p;
227-
} else {
228-
$a[$k] = $p;
223+
if ($a) {
224+
$p = array_keys($a);
225+
foreach ($p as $i => $k) {
226+
if (!isset($k[0]) || ("\0" !== $k[0] && !$classInfo[2]->hasProperty($k))) {
227+
$p[$i] = "\0+\0".$k;
228+
}
229229
}
230+
$a = array_combine($p, $a);
230231
}
231232

232233
foreach ($classInfo[3] as $p) {

src/Symfony/Component/VarDumper/Tests/CliDumperTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,34 @@ public function testThrowingCaster()
178178
}
179179
}
180180
181+
EOTXT
182+
,
183+
$out
184+
);
185+
}
186+
187+
public function testRefsInProperties()
188+
{
189+
$var = (object) array('foo' => 'foo');
190+
$var->bar =& $var->foo;
191+
192+
$dumper = new CliDumper();
193+
$dumper->setColors(false);
194+
$cloner = new VarCloner();
195+
196+
$out = fopen('php://memory', 'r+b');
197+
$data = $cloner->cloneVar($var);
198+
$dumper->dump($data, $out);
199+
rewind($out);
200+
$out = stream_get_contents($out);
201+
202+
$this->assertStringMatchesFormat(
203+
<<<EOTXT
204+
{#%d
205+
+"foo": &1 "foo"
206+
+"bar": &1 "foo"
207+
}
208+
181209
EOTXT
182210
,
183211
$out

0 commit comments

Comments
 (0)