|
20 | 20 | use Symfony\Component\Validator\ConstraintViolationInterface;
|
21 | 21 | use Symfony\Component\VarDumper\Caster\Caster;
|
22 | 22 | use Symfony\Component\VarDumper\Caster\ClassStub;
|
23 |
| -use Symfony\Component\VarDumper\Caster\CutStub; |
24 |
| -use Symfony\Component\VarDumper\Cloner\ClonerInterface; |
25 |
| -use Symfony\Component\VarDumper\Cloner\Data; |
26 | 23 | use Symfony\Component\VarDumper\Cloner\Stub;
|
27 |
| -use Symfony\Component\VarDumper\Cloner\VarCloner; |
28 | 24 |
|
29 | 25 | /**
|
30 | 26 | * Data collector for {@link FormInterface} instances.
|
@@ -77,11 +73,6 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
|
77 | 73 | */
|
78 | 74 | private $valueExporter;
|
79 | 75 |
|
80 |
| - /** |
81 |
| - * @var ClonerInterface |
82 |
| - */ |
83 |
| - private $cloner; |
84 |
| - |
85 | 76 | private $hasVarDumper;
|
86 | 77 |
|
87 | 78 | public function __construct(FormDataExtractorInterface $dataExtractor)
|
@@ -255,61 +246,33 @@ public function serialize()
|
255 | 246 | /**
|
256 | 247 | * {@inheritdoc}
|
257 | 248 | */
|
258 |
| - protected function cloneVar($var, $isClass = false) |
| 249 | + protected function getCasters() |
259 | 250 | {
|
260 |
| - if ($var instanceof Data) { |
261 |
| - return $var; |
262 |
| - } |
263 |
| - if (null === $this->cloner) { |
264 |
| - if ($this->hasVarDumper) { |
265 |
| - $this->cloner = new VarCloner(); |
266 |
| - $this->cloner->setMaxItems(-1); |
267 |
| - $this->cloner->addCasters(array( |
268 |
| - '*' => function ($v, array $a, Stub $s, $isNested) { |
269 |
| - foreach ($a as &$v) { |
270 |
| - if (is_object($v) && !$v instanceof \DateTimeInterface) { |
271 |
| - $v = new CutStub($v); |
272 |
| - } |
273 |
| - } |
274 |
| - |
275 |
| - return $a; |
276 |
| - }, |
277 |
| - \Exception::class => function (\Exception $e, array $a, Stub $s) { |
278 |
| - if (isset($a[$k = "\0Exception\0previous"])) { |
279 |
| - unset($a[$k]); |
280 |
| - ++$s->cut; |
281 |
| - } |
282 |
| - |
283 |
| - return $a; |
284 |
| - }, |
285 |
| - FormInterface::class => function (FormInterface $f, array $a) { |
286 |
| - return array( |
287 |
| - Caster::PREFIX_VIRTUAL.'name' => $f->getName(), |
288 |
| - Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())), |
289 |
| - ); |
290 |
| - }, |
291 |
| - ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) { |
292 |
| - return array( |
293 |
| - Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(), |
294 |
| - Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(), |
295 |
| - Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(), |
296 |
| - ); |
297 |
| - }, |
298 |
| - )); |
299 |
| - } else { |
300 |
| - @trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since version 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED); |
301 |
| - $this->cloner = false; |
302 |
| - } |
303 |
| - } |
304 |
| - if (false !== $this->cloner) { |
305 |
| - return $this->cloner->cloneVar($var, Caster::EXCLUDE_VERBOSE); |
306 |
| - } |
307 |
| - |
308 |
| - if (null === $this->valueExporter) { |
309 |
| - $this->valueExporter = new ValueExporter(); |
310 |
| - } |
| 251 | + return parent::getCasters() + array( |
| 252 | + \Exception::class => function (\Exception $e, array $a, Stub $s) { |
| 253 | + foreach (array("\0Exception\0previous", "\0Exception\0trace") as $k) { |
| 254 | + if (isset($a[$k])) { |
| 255 | + unset($a[$k]); |
| 256 | + ++$s->cut; |
| 257 | + } |
| 258 | + } |
311 | 259 |
|
312 |
| - return $this->valueExporter->exportValue($var); |
| 260 | + return $a; |
| 261 | + }, |
| 262 | + FormInterface::class => function (FormInterface $f, array $a) { |
| 263 | + return array( |
| 264 | + Caster::PREFIX_VIRTUAL.'name' => $f->getName(), |
| 265 | + Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())), |
| 266 | + ); |
| 267 | + }, |
| 268 | + ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) { |
| 269 | + return array( |
| 270 | + Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(), |
| 271 | + Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(), |
| 272 | + Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(), |
| 273 | + ); |
| 274 | + }, |
| 275 | + ); |
313 | 276 | }
|
314 | 277 |
|
315 | 278 | private function &recursiveBuildPreliminaryFormTree(FormInterface $form, array &$outputByHash)
|
|
0 commit comments