123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- namespace Symfony\Component\HttpKernel\DataCollector;
- use Symfony\Component\VarDumper\Caster\CutStub;
- use Symfony\Component\VarDumper\Caster\ReflectionCaster;
- use Symfony\Component\VarDumper\Cloner\ClonerInterface;
- use Symfony\Component\VarDumper\Cloner\Data;
- use Symfony\Component\VarDumper\Cloner\Stub;
- use Symfony\Component\VarDumper\Cloner\VarCloner;
- abstract class DataCollector implements DataCollectorInterface
- {
-
- protected $data = [];
-
- private $cloner;
-
- protected function cloneVar($var)
- {
- if ($var instanceof Data) {
- return $var;
- }
- if (null === $this->cloner) {
- $this->cloner = new VarCloner();
- $this->cloner->setMaxItems(-1);
- $this->cloner->addCasters($this->getCasters());
- }
- return $this->cloner->cloneVar($var);
- }
-
- protected function getCasters()
- {
- $casters = [
- '*' => function ($v, array $a, Stub $s, $isNested) {
- if (!$v instanceof Stub) {
- foreach ($a as $k => $v) {
- if (\is_object($v) && !$v instanceof \DateTimeInterface && !$v instanceof Stub) {
- $a[$k] = new CutStub($v);
- }
- }
- }
- return $a;
- },
- ] + ReflectionCaster::UNSET_CLOSURE_FILE_INFO;
- return $casters;
- }
-
- public function __sleep()
- {
- return ['data'];
- }
- public function __wakeup()
- {
- }
-
- final protected function serialize()
- {
- }
-
- final protected function unserialize($data)
- {
- }
- }
|