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 6a75bc7

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

File tree

1 file changed

+13
-7
lines changed
Filter options

1 file changed

+13
-7
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/Caster.php
+13-7Lines changed: 13 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,16 @@ 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+
$a[$k] = $v;
99+
}
100+
}
101+
96102
return $a;
97103
}
98104

0 commit comments

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