castStub() public static méthode

public static castStub ( Symfony\Component\VarDumper\Cloner\Stub $c, array $a, Symfony\Component\VarDumper\Cloner\Stub $stub, $isNested )
$c Symfony\Component\VarDumper\Cloner\Stub
$a array
$stub Symfony\Component\VarDumper\Cloner\Stub
Exemple #1
0
    /**
     * Converts the variable into a serializable Data instance.
     *
     * This array can be displayed in the template using
     * the VarDumper component.
     *
     * @param mixed $var
     *
     * @return Data
     */
    protected function cloneVar($var)
    {
        if (null === $this->cloner) {
            if (class_exists(ClassStub::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);
                    },
                ));
            } 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);
                $this->cloner = false;
            }
        }
        if (false === $this->cloner) {
            if (null === $this->valueExporter) {
                $this->valueExporter = new ValueExporter();
            }

            return $this->valueExporter->exportValue($var);
        }

        return $this->cloner->cloneVar($this->decorateVar($var));
    }
 /**
  * Converts the variable into a serializable Data instance.
  *
  * @param mixed $var
  *
  * @return Data
  */
 private function cloneVar($var)
 {
     if (null === $this->cloner) {
         $this->cloner = new VarCloner();
         $this->cloner->addCasters(array(Stub::class => function (Stub $v, array $a, Stub $s, $isNested) {
             return $isNested ? $a : StubCaster::castStub($v, $a, $s, true);
         }, \Exception::class => function (\Exception $e, array $a, Stub $s) {
             if (isset($a[$k = "Exceptionprevious"])) {
                 unset($a[$k]);
                 ++$s->cut;
             }
             return $a;
         }, FormInterface::class => function (FormInterface $f, array $a) {
             return array(Caster::PREFIX_VIRTUAL . 'name' => $f->getName(), Caster::PREFIX_VIRTUAL . 'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())));
         }, ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) {
             return array(Caster::PREFIX_VIRTUAL . 'root' => $v->getRoot(), Caster::PREFIX_VIRTUAL . 'path' => $v->getPropertyPath(), Caster::PREFIX_VIRTUAL . 'value' => $v->getInvalidValue());
         }));
     }
     return $this->cloner->cloneVar($var);
 }