|
19 | 19 | use Symfony\Component\Validator\ConstraintViolationInterface;
|
20 | 20 | use Symfony\Component\VarDumper\Caster\Caster;
|
21 | 21 | use Symfony\Component\VarDumper\Caster\ClassStub;
|
22 |
| -use Symfony\Component\VarDumper\Caster\CutStub; |
23 |
| -use Symfony\Component\VarDumper\Cloner\ClonerInterface; |
24 |
| -use Symfony\Component\VarDumper\Cloner\Data; |
25 | 22 | use Symfony\Component\VarDumper\Cloner\Stub;
|
26 |
| -use Symfony\Component\VarDumper\Cloner\VarCloner; |
27 | 23 |
|
28 | 24 | /**
|
29 | 25 | * Data collector for {@link FormInterface} instances.
|
@@ -71,11 +67,6 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
|
71 | 67 | */
|
72 | 68 | private $formsByView;
|
73 | 69 |
|
74 |
| - /** |
75 |
| - * @var ClonerInterface |
76 |
| - */ |
77 |
| - private $cloner; |
78 |
| - |
79 | 70 | public function __construct(FormDataExtractorInterface $dataExtractor)
|
80 | 71 | {
|
81 | 72 | if (!class_exists(ClassStub::class)) {
|
@@ -248,49 +239,33 @@ public function serialize()
|
248 | 239 | /**
|
249 | 240 | * {@inheritdoc}
|
250 | 241 | */
|
251 |
| - protected function cloneVar($var, $isClass = false) |
| 242 | + protected function getCasters() |
252 | 243 | {
|
253 |
| - if ($var instanceof Data) { |
254 |
| - return $var; |
255 |
| - } |
256 |
| - if (null === $this->cloner) { |
257 |
| - $this->cloner = new VarCloner(); |
258 |
| - $this->cloner->setMaxItems(-1); |
259 |
| - $this->cloner->addCasters(array( |
260 |
| - '*' => function ($v, array $a, Stub $s, $isNested) { |
261 |
| - foreach ($a as &$v) { |
262 |
| - if (is_object($v) && !$v instanceof \DateTimeInterface) { |
263 |
| - $v = new CutStub($v); |
264 |
| - } |
265 |
| - } |
266 |
| - |
267 |
| - return $a; |
268 |
| - }, |
269 |
| - \Exception::class => function (\Exception $e, array $a, Stub $s) { |
270 |
| - if (isset($a[$k = "\0Exception\0previous"])) { |
| 244 | + return parent::getCasters() + array( |
| 245 | + \Exception::class => function (\Exception $e, array $a, Stub $s) { |
| 246 | + foreach (array("\0Exception\0previous", "\0Exception\0trace") as $k) { |
| 247 | + if (isset($a[$k])) { |
271 | 248 | unset($a[$k]);
|
272 | 249 | ++$s->cut;
|
273 | 250 | }
|
274 |
| - |
275 |
| - return $a; |
276 |
| - }, |
277 |
| - FormInterface::class => function (FormInterface $f, array $a) { |
278 |
| - return array( |
279 |
| - Caster::PREFIX_VIRTUAL.'name' => $f->getName(), |
280 |
| - Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())), |
281 |
| - ); |
282 |
| - }, |
283 |
| - ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) { |
284 |
| - return array( |
285 |
| - Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(), |
286 |
| - Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(), |
287 |
| - Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(), |
288 |
| - ); |
289 |
| - }, |
290 |
| - )); |
291 |
| - } |
292 |
| - |
293 |
| - return $this->cloner->cloneVar($var, Caster::EXCLUDE_VERBOSE); |
| 251 | + } |
| 252 | + |
| 253 | + return $a; |
| 254 | + }, |
| 255 | + FormInterface::class => function (FormInterface $f, array $a) { |
| 256 | + return array( |
| 257 | + Caster::PREFIX_VIRTUAL.'name' => $f->getName(), |
| 258 | + Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())), |
| 259 | + ); |
| 260 | + }, |
| 261 | + ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) { |
| 262 | + return array( |
| 263 | + Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(), |
| 264 | + Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(), |
| 265 | + Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(), |
| 266 | + ); |
| 267 | + }, |
| 268 | + ); |
294 | 269 | }
|
295 | 270 |
|
296 | 271 | private function &recursiveBuildPreliminaryFormTree(FormInterface $form, array &$outputByHash)
|
|
0 commit comments