X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fhttp-kernel%2FDataCollector%2FDataCollector.php;h=6d1a822e47a9008c1394c96cac6383b06a77ed8f;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=3808852dfaafb6e650ab6d3c56aa89529ef2d0f6;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/vendor/symfony/http-kernel/DataCollector/DataCollector.php b/vendor/symfony/http-kernel/DataCollector/DataCollector.php index 3808852df..6d1a822e4 100644 --- a/vendor/symfony/http-kernel/DataCollector/DataCollector.php +++ b/vendor/symfony/http-kernel/DataCollector/DataCollector.php @@ -12,9 +12,7 @@ namespace Symfony\Component\HttpKernel\DataCollector; use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; -use Symfony\Component\VarDumper\Caster\ClassStub; -use Symfony\Component\VarDumper\Caster\LinkStub; -use Symfony\Component\VarDumper\Caster\StubCaster; +use Symfony\Component\VarDumper\Caster\CutStub; use Symfony\Component\VarDumper\Cloner\ClonerInterface; use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\VarDumper\Cloner\Stub; @@ -42,8 +40,6 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable */ private $cloner; - private static $stubsCache = array(); - public function serialize() { return serialize($this->data); @@ -66,17 +62,16 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable */ protected function cloneVar($var) { + if ($var instanceof Data) { + return $var; + } if (null === $this->cloner) { - if (class_exists(ClassStub::class)) { + if (class_exists(CutStub::class)) { $this->cloner = new VarCloner(); - $this->cloner->setMaxItems(250); - $this->cloner->addCasters(array( - Stub::class => function (Stub $v, array $a, Stub $s, $isNested) { - return $isNested ? $a : StubCaster::castStub($v, $a, $s, true); - }, - )); + $this->cloner->setMaxItems(-1); + $this->cloner->addCasters($this->getCasters()); } else { - @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); + @trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since Symfony 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED); $this->cloner = false; } } @@ -88,7 +83,7 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable return $this->valueExporter->exportValue($var); } - return $this->cloner->cloneVar($this->decorateVar($var)); + return $this->cloner->cloneVar($var); } /** @@ -98,11 +93,11 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable * * @return string The string representation of the variable * - * @deprecated Deprecated since version 3.2, to be removed in 4.0. Use cloneVar() instead. + * @deprecated since version 3.2, to be removed in 4.0. Use cloneVar() instead. */ protected function varToString($var) { - @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use cloneVar() instead.', __METHOD__), E_USER_DEPRECATED); + @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use cloneVar() instead.', __METHOD__), E_USER_DEPRECATED); if (null === $this->valueExporter) { $this->valueExporter = new ValueExporter(); @@ -111,35 +106,23 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable return $this->valueExporter->exportValue($var); } - private function decorateVar($var) + /** + * @return callable[] The casters to add to the cloner + */ + protected function getCasters() { - if (is_array($var)) { - if (isset($var[0], $var[1]) && is_callable($var)) { - return ClassStub::wrapCallable($var); - } - foreach ($var as $k => $v) { - if ($v !== $d = $this->decorateVar($v)) { - $var[$k] = $d; + return array( + '*' => 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 $var; - } - if (is_string($var)) { - if (isset(self::$stubsCache[$var])) { - return self::$stubsCache[$var]; - } - if (false !== strpos($var, '\\')) { - $c = (false !== $i = strpos($var, '::')) ? substr($var, 0, $i) : $var; - if (class_exists($c, false) || interface_exists($c, false) || trait_exists($c, false)) { - return self::$stubsCache[$var] = new ClassStub($var); - } - } - if (false !== strpos($var, DIRECTORY_SEPARATOR) && false === strpos($var, '://') && false === strpos($var, "\0") && @is_file($var)) { - return self::$stubsCache[$var] = new LinkStub($var); - } - } - return $var; + return $a; + }, + ); } }