Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a9d0038

Browse filesBrowse files
[VarDumper] fix dumping objects that implement __debugInfo()
1 parent a0b6d3d commit a9d0038
Copy full SHA for a9d0038

File tree

1 file changed

+14
-7
lines changed
Filter options

1 file changed

+14
-7
lines changed

‎src/Symfony/Component/VarDumper/Caster/Caster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/Caster.php
+14-7Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,9 @@ public static function castObject($obj, $class, $hasDebugInfo = false)
5353
$hasDebugInfo = $class->hasMethod('__debugInfo');
5454
$class = $class->name;
5555
}
56-
if ($hasDebugInfo) {
57-
$a = $obj->__debugInfo();
58-
} elseif ($obj instanceof \Closure) {
59-
$a = [];
60-
} else {
61-
$a = (array) $obj;
62-
}
56+
57+
$a = $obj instanceof \Closure ? [] : (array) $obj;
58+
6359
if ($obj instanceof \__PHP_Incomplete_Class) {
6460
return $a;
6561
}
@@ -93,6 +89,17 @@ public static function castObject($obj, $class, $hasDebugInfo = false)
9389
}
9490
}
9591

92+
if ($hasDebugInfo && \is_array($debugInfo = $obj->__debugInfo())) {
93+
foreach ($debugInfo as $k => $v) {
94+
if (!isset($k[0]) || "\0" !== $k[0]) {
95+
$k = self::PREFIX_VIRTUAL.$k;
96+
}
97+
98+
unset($a[$k]);
99+
$a[$k] = $v;
100+
}
101+
}
102+
96103
return $a;
97104
}
98105

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.