Merge branch '2.6' into 2.7
* 2.6: [VarDumper] Fix dumping references as properties [VarDumper] Fix toggle action to see source excerpt
This commit is contained in:
commit
a86a41940a
@ -85,7 +85,7 @@
|
||||
{{ dump.name }}
|
||||
{% endif %}
|
||||
line {{ dump.line }}:
|
||||
<a onclick="Sfdump.toggle(this)">▶</a>
|
||||
<a onclick="var s = this.nextElementSibling; if ('sf-dump-compact' == s.className) {this.innerHTML = '▼'; s.className = 'sf-dump-expanded';} else {this.innerHTML = '▶'; s.className = 'sf-dump-compact';}">▶</a>
|
||||
<span class="sf-dump-compact">
|
||||
{% if dump.fileExcerpt %}{{ dump.fileExcerpt|raw }}{% else %}{{ dump.file|file_excerpt(dump.line) }}{% endif %}
|
||||
</span>
|
||||
|
@ -215,19 +215,20 @@ abstract class AbstractCloner implements ClonerInterface
|
||||
}
|
||||
|
||||
if ($classInfo[1]) {
|
||||
$p = $this->callCaster(function ($obj) {return $obj->__debugInfo();}, $obj, array(), null, $isNested);
|
||||
$a = $this->callCaster(function ($obj) {return $obj->__debugInfo();}, $obj, array(), null, $isNested);
|
||||
} else {
|
||||
$p = (array) $obj;
|
||||
$a = (array) $obj;
|
||||
}
|
||||
|
||||
$a = array();
|
||||
foreach ($p as $k => $p) {
|
||||
if ($a) {
|
||||
$p = array_keys($a);
|
||||
foreach ($p as $i => $k) {
|
||||
if (!isset($k[0]) || ("\0" !== $k[0] && !$classInfo[2]->hasProperty($k))) {
|
||||
$a["\0+\0".$k] = $p;
|
||||
} else {
|
||||
$a[$k] = $p;
|
||||
$p[$i] = "\0+\0".$k;
|
||||
}
|
||||
}
|
||||
$a = array_combine($p, $a);
|
||||
}
|
||||
|
||||
foreach ($classInfo[3] as $p) {
|
||||
if (!empty($this->casters[$p = strtolower($p)])) {
|
||||
|
@ -178,6 +178,34 @@ EOTXT
|
||||
}
|
||||
}
|
||||
|
||||
EOTXT
|
||||
,
|
||||
$out
|
||||
);
|
||||
}
|
||||
|
||||
public function testRefsInProperties()
|
||||
{
|
||||
$var = (object) array('foo' => 'foo');
|
||||
$var->bar =& $var->foo;
|
||||
|
||||
$dumper = new CliDumper();
|
||||
$dumper->setColors(false);
|
||||
$cloner = new VarCloner();
|
||||
|
||||
$out = fopen('php://memory', 'r+b');
|
||||
$data = $cloner->cloneVar($var);
|
||||
$dumper->dump($data, $out);
|
||||
rewind($out);
|
||||
$out = stream_get_contents($out);
|
||||
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
{#%d
|
||||
+"foo": &1 "foo"
|
||||
+"bar": &1 "foo"
|
||||
}
|
||||
|
||||
EOTXT
|
||||
,
|
||||
$out
|
||||
|
Reference in New Issue
Block a user