Skip to content

Commit

Permalink
bug #35010 [VarDumper] ignore failing __debugInfo() (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

[VarDumper] ignore failing __debugInfo()

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34993
| License       | MIT
| Doc PR        | -

Commits
-------

eb2eb76 [VarDumper] ignore failing __debugInfo()
  • Loading branch information
nicolas-grekas committed Dec 18, 2019
2 parents b47f1af + eb2eb76 commit e85acdd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Symfony/Component/VarDumper/Caster/Caster.php
Expand Up @@ -54,6 +54,15 @@ public static function castObject($obj, $class, $hasDebugInfo = false)
$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) {
Expand Down Expand Up @@ -89,7 +98,7 @@ public static function castObject($obj, $class, $hasDebugInfo = false)
}
}

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;
Expand Down

0 comments on commit e85acdd

Please sign in to comment.