[VarDumper] ignore failing __debugInfo()

This commit is contained in:
Nicolas Grekas 2019-12-17 16:56:06 +01:00
parent ae9c41cb16
commit eb2eb76d0e

View File

@ -54,6 +54,15 @@ class Caster
$class = $class->name;
}
if ($hasDebugInfo) {
try {
$debugInfo = $obj->__debugInfo();
} catch (\Exception $e) {
// ignore failing __debugInfo()
$hasDebugInfo = false;
}
}
$a = $obj instanceof \Closure ? [] : (array) $obj;
if ($obj instanceof \__PHP_Incomplete_Class) {
@ -89,7 +98,7 @@ class Caster
}
}
if ($hasDebugInfo && \is_array($debugInfo = $obj->__debugInfo())) {
if ($hasDebugInfo && \is_array($debugInfo)) {
foreach ($debugInfo as $k => $v) {
if (!isset($k[0]) || "\0" !== $k[0]) {
$k = self::PREFIX_VIRTUAL.$k;