8000 [VarDumper] Support ThrownExceptionInformation · symfony/symfony@578efd2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 578efd2

Browse files
committed
[VarDumper] Support ThrownExceptionInformation
1 parent 2454cdf commit 578efd2

File tree

8 files changed

+41
-4
lines changed

8 files changed

+41
-4
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ install:
4848
- php composer.phar global require --no-progress --no-scripts --no-plugins symfony/flex
4949
- git config --global user.email ""
5050
- git config --global user.name "Symfony"
51-
- FOR /F "tokens=* USEBACKQ" %%F IN (`bash -c "grep branch-version composer.json | grep -o '[0-9.]*'"`) DO (SET SYMFONY_VERSION=%%F)
51+
- FOR /F "tokens=* USEBACKQ" %%F IN (`bash -c "grep branch-version composer.json | grep -o '[0-9.x]*'"`) DO (SET SYMFONY_VERSION=%%F)
5252
- php .github/build-packages.php "HEAD^" %SYMFONY_VERSION% src\Symfony\Bridge\PhpUnit src\Symfony\Contracts
5353
- SET "SYMFONY_REQUIRE=>=%SYMFONY_VERSION%"
5454
- SET COMPOSER_ROOT_VERSION=%SYMFONY_VERSION%.x-dev

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
run: |
115115
COMPOSER_HOME="$(composer config home)"
116116
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
117-
echo "COMPOSER_ROOT_VERSION=$(grep branch-version composer.json | grep -o '[0-9.]*').x-dev" >> $GITHUB_ENV
117+
echo "COMPOSER_ROOT_VERSION=$(grep branch-version composer.json | grep -o '[0-9.x]*').x-dev" >> $GITHUB_ENV
118118
119119
- name: Determine composer cache directory
120120
id: composer-cache

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ install:
199199
git config --global user.email ""
200200
git config --global user.name "Symfony"
201201
202-
export SYMFONY_VERSION=$(grep branch-version composer.json | grep -o '[0-9.]*')
202+
export SYMFONY_VERSION=$(grep branch-version composer.json | grep -o '[0-9.x]*')
203203
204204
if [[ ! $deps ]]; then
205205
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit src/Symfony/Contracts

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,6 @@
175175
],
176176
"minimum-stability": "dev",
177177
"extra": {
178-
"branch-version": "5.2"
178+
"branch-version": "5.x"
179179
}
180180
}

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
namespace Symfony\Component\VarDumper\Caster;
1313

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

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

87+
public static function castThrownExceptionDetails(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+
return self::filterExceptionArray($exceptionDetails->getClass(), $a, $xPrefix, $filter);
94+
}
95+
8696
public static function castSilencedErrorContext(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+
public function testThrownExceptionDetails()
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
}

src/Symfony/Component/VarDumper/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"require-dev": {
2424
"ext-iconv": "*",
2525
"symfony/console": "^4.4|^5.0",
26+
"symfony/error-handler": "^5.3",
2627
"symfony/process": "^4.4|^5.0",
2728
"twig/twig": "^2.4|^3.0"
2829
},

0 commit comments

Comments
 (0)
0