Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75f8547

Browse files
committed
bug #48359 [VarDumper] Ignore \Error in __debugInfo() (fancyweb)
This PR was merged into the 5.4 branch. Discussion ---------- [VarDumper] Ignore \Error in __debugInfo() | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - `__debugInfo()` can throw `\TypeError` (the test case is from a real vendor doing that 😅) Commits ------- cc5ab14 [VarDumper] Ignore \Error in __debugInfo()
2 parents 3b75e0a + cc5ab14 commit 75f8547

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function castObject(object $obj, string $class, bool $hasDebugInfo
4747
if ($hasDebugInfo) {
4848
try {
4949
$debugInfo = $obj->__debugInfo();
50-
} catch (\Exception $e) {
50+
} catch (\Throwable $e) {
5151
// ignore failing __debugInfo()
5252
$hasDebugInfo = false;
5353
}

src/Symfony/Component/VarDumper/Tests/Caster/CasterTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,14 @@ public function testAnonymousClass()
175175
, $c
176176
);
177177
}
178+
179+
public function testTypeErrorInDebugInfo()
180+
{
181+
$this->assertDumpMatchesFormat('class@anonymous {}', new class() {
182+
public function __debugInfo(): array
183+
{
184+
return ['class' => \get_class(null)];
185+
}
186+
});
187+
}
178188
}

0 commit comments

Comments
 (0)