8000 minor #16129 [VarDumper] Move $prev as 1st argument in ThrowingCaster… · symfony/symfony@b6ab750 · GitHub
[go: up one dir, main page]

Skip to content

Commit b6ab750

Browse files
committed
minor #16129 [VarDumper] Move $prev as 1st argument in ThrowingCasterException::__construct, removing $caster (nicolas-grekas)
This PR was merged into the 2.8 branch. Discussion ---------- [VarDumper] Move $prev as 1st argument in ThrowingCasterException::__construct, removing $caster | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 02b86b0 [VarDumper] Move $prev as 1st argument in ThrowingCasterException::__construct, removing $caster
2 parents 9c5565f + 02b86b0 commit b6ab750

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private function callCaster($callback, $obj, $a, $stub, $isNested)
292292
$a = $cast;
293293
}
294294
} catch (\Exception $e) {
295-
$a[(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').''] = new ThrowingCasterException($callback, $e);
295+
$a[(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').''] = new ThrowingCasterException($e);
296296
}
297297

298298
return $a;

src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
class ThrowingCasterException extends \Exception
1818
{
1919
/**
20-
* @param callable $caster The failing caster
21-
* @param \Exception $prev The exception thrown from the caster
20+
* @param \Exception $prev The exception thrown from the caster
2221
*/
23-
public function __construct($caster, \Exception $prev)
22+
public function __construct($prev, \Exception $e = null)
2423
{
24+
if (!$prev instanceof \Exception) {
25+
@trigger_error('Providing $caster a 1st argument when instanciating a '.__CLASS__.' is deprecated since version 2.8 and will be removed in 3.0. Provide directly the $prev exception instead.', E_USER_DEPRECATED);
26+
27+
$prev = $e;
28+
}
2529
parent::__construct('Unexpected '.get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev);
2630
}
2731
}

0 commit comments

Comments
 (0)
0