|
19 | 19 | use Symfony\Component\Validator\Validator\TraceableValidator;
|
20 | 20 | use Symfony\Component\VarDumper\Caster\Caster;
|
21 | 21 | use Symfony\Component\VarDumper\Caster\ClassStub;
|
22 |
| -use Symfony\Component\VarDumper\Cloner\Data; |
23 |
| -use Symfony\Component\VarDumper\Cloner\VarCloner; |
| 22 | +use Symfony\Component\VarDumper\Cloner\Stub; |
24 | 23 |
|
25 | 24 | /**
|
26 | 25 | * @author Maxime Steinhausser <[email protected]>
|
27 | 26 | */
|
28 | 27 | class ValidatorDataCollector extends DataCollector implements LateDataCollectorInterface
|
29 | 28 | {
|
30 | 29 | private $validator;
|
31 |
| - private $cloner; |
32 | 30 |
|
33 | 31 | public function __construct(TraceableValidator $validator)
|
34 | 32 | {
|
@@ -77,29 +75,26 @@ public function getName()
|
77 | 75 | return 'validator';
|
78 | 76 | }
|
79 | 77 |
|
80 |
| - /** |
81 |
| - * {@inheritdoc} |
82 |
| - */ |
83 |
| - protected function cloneVar($var) |
| 78 | + protected function getCasters() |
84 | 79 | {
|
85 |
| - if ($var instanceof Data) { |
86 |
| - return $var; |
87 |
| - } |
| 80 | + return parent::getCasters() + array( |
| 81 | + \Exception::class => function (\Exception $e, array $a, Stub $s) { |
| 82 | + foreach (array("\0Exception\0previous", "\0Exception\0trace") as $k) { |
| 83 | + if (isset($a[$k])) { |
| 84 | + unset($a[$k]); |
| 85 | + ++$s->cut; |
| 86 | + } |
| 87 | + } |
88 | 88 |
|
89 |
| - if (null === $this->cloner) { |
90 |
| - $this->cloner = new VarCloner(); |
91 |
| - $this->cloner->setMaxItems(-1); |
92 |
| - $this->cloner->addCasters(array( |
93 |
| - FormInterface::class => function (FormInterface $f, array $a) { |
94 |
| - return array( |
95 |
| - Caster::PREFIX_VIRTUAL.'name' => $f->getName(), |
96 |
| - Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())), |
97 |
| - Caster::PREFIX_VIRTUAL.'data' => $f->getData(), |
98 |
| - ); |
99 |
| - }, |
100 |
| - )); |
101 |
| - } |
102 |
| - |
103 |
| - return $this->cloner->cloneVar($var, Caster::EXCLUDE_VERBOSE); |
| 89 | + return $a; |
| 90 | + }, |
| 91 | + FormInterface::class => function (FormInterface $f, array $a) { |
| 92 | + return array( |
| 93 | + Caster::PREFIX_VIRTUAL.'name' => $f->getName(), |
| 94 | + Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())), |
| 95 | + Caster::PREFIX_VIRTUAL.'data' => $f->getData(), |
| 96 | + ); |
| 97 | + }, |
| 98 | + ); |
104 | 99 | }
|
105 | 100 | }
|
0 commit comments