Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf0e9bf0

Browse files
committed
[VarDumper] Support ThrownExceptionInformation
1 parentf9d4393 commitf0e9bf0

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespaceSymfony\Component\VarDumper\Caster;
1313

1414
useSymfony\Component\ErrorHandler\Exception\SilencedErrorContext;
15+
useSymfony\Component\Messenger\Exception\ThrownExceptionDetails;
1516
useSymfony\Component\VarDumper\Cloner\Stub;
1617
useSymfony\Component\VarDumper\Exception\ThrowingCasterException;
1718

@@ -83,6 +84,15 @@ public static function castThrowingCasterException(ThrowingCasterException $e, a
8384
return$a;
8485
}
8586

87+
publicstaticfunctioncastThrownExceptionDetails(ThrownExceptionDetails$exceptionDetails,array$a,Stub$stub,bool$isNested,int$filter =0)
88+
{
89+
$xPrefix ="\0".ThrownExceptionDetails::class."\0";
90+
$stub->class =$exceptionDetails->getClass();
91+
unset($a[$xPrefix.'class']);
92+
93+
returnself::filterExceptionArray($exceptionDetails->getClass(),$a,$xPrefix,$filter);
94+
}
95+
8696
publicstaticfunctioncastSilencedErrorContext(SilencedErrorContext$e,array$a,Stub$stub,bool$isNested)
8797
{
8898
$sPrefix ="\0".SilencedErrorContext::class."\0";

‎src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ abstract class AbstractCloner implements ClonerInterface
9191
'Symfony\Component\VarDumper\Caster\FrameStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster','castFrameStub'],
9292
'Symfony\Component\VarDumper\Cloner\AbstractCloner' => ['Symfony\Component\VarDumper\Caster\StubCaster','cutInternals'],
9393
'Symfony\Component\ErrorHandler\Exception\SilencedErrorContext' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster','castSilencedErrorContext'],
94+
'Symfony\Component\Messenger\Exception\ThrownExceptionDetails' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster','castThrownExceptionDetails'],
9495

9596
'Imagine\Image\ImageInterface' => ['Symfony\Component\VarDumper\Caster\ImagineCaster','castImage'],
9697

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,29 @@ public function testAnonymous()
244244

245245
$this->assertDumpMatchesFormat($expectedDump,$e, Caster::EXCLUDE_VERBOSE);
246246
}
247+
248+
publicfunctiontestThrownExceptionDetails()
249+
{
250+
$e = \Symfony\Component\ErrorHandler\Exception\FlattenException::createFromThrowable($this->getTestException('foo'));
251+
$exceptionDetails = \Symfony\Component\Messenger\Exception\ThrownExceptionDetails::createFromFlattenException($e);
252+
253+
$expectedDump = <<<'EODUMP'
254+
Exception {
255+
-message: "foo"
256+
-code: 0
257+
-file: "%sExceptionCasterTest.php"
258+
-line: 28
259+
trace: {
260+
%s%eTests%eCaster%eExceptionCasterTest.php:28 {
261+
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestException($msg, &$ref = null)
262+
› {
263+
› return new \Exception(''.$msg);
264+
› }
265+
}
266+
%s%eTests%eCaster%eExceptionCasterTest.php:250 { …}
267+
%A
268+
EODUMP;
269+
270+
$this->assertDumpMatchesFormat($expectedDump,$exceptionDetails);
271+
}
247272
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp