transplant example


        return Parser::TRIGGER_SUCCESS;
    }

    public function parse(&$var, Value &$o, int $trigger): void
    {
        if (!$var instanceof Closure) {
            return;
        }

        $object = new ClosureValue();
        $object->transplant($o);
        $o = $object;
        $object->removeRepresentation('properties');

        $closure = new ReflectionFunction($var);

        $o->filename = $closure->getFileName();
        $o->startline = $closure->getStartLine();

        foreach ($closure->getParameters() as $param) {
            $o->parameters[] = new ParameterValue($param);
        }

        
return null;
    }

    public function getSize(): ?string
    {
        return null;
    }

    public function transplant(Value $old): void
    {
        parent::transplant($old);

        if (0 === $this->depth && \preg_match('/^\\((function|fn)\\s*\\(/i', $this->access_path, $match)) {
            $this->name = \strtolower($match[1]);
        }
    }
}
public function getType(): string
    {
        if ($this->resource_type) {
            return $this->resource_type.' resource';
        }

        return 'resource';
    }

    public function transplant(Value $old): void
    {
        parent::transplant($old);

        if ($old instanceof self) {
            $this->resource_type = $old->resource_type;
        }
    }
}


        // An invalid SimpleXMLElement can gum up the works with         // warnings if we call stuff children/attributes on it.         if (!$var) {
            $o->size = null;

            return;
        }

        $x = new SimpleXMLElementValue();
        $x->transplant($o);

        $namespaces = \array_merge([null]$var->getDocNamespaces());

        // Attributes         $a = new Representation('Attributes');

        $base_obj = new Value();
        $base_obj->depth = $x->depth;

        if ($x->access_path) {
            $base_obj->access_path = '(string) '.$x->access_path;
        }
public function renderValue(Value $o): ?string
    {
        if (!($o instanceof SimpleXMLElementValue)) {
            return null;
        }

        if (!$o->isStringValue() || !empty($o->getRepresentation('attributes')->contents)) {
            return null;
        }

        $b = new BlobValue();
        $b->transplant($o);
        $b->type = 'string';

        $children = $this->renderer->renderChildren($b);
        $header = $this->renderer->renderHeader($o);
        $header = $this->renderer->renderHeaderWrapper($o(bool) \strlen($children)$header);

        return '<dl>'.$header.$children.'</dl>';
    }
}
$a->contents[] = $attribute;
            }
            $o->addRepresentation($a, 0);
        }

        // Set the children         if ($childNodes) {
            $c = new Representation('Children');

            if (1 === \count($childNodes->contents) && ($node = \reset($childNodes->contents)) && \in_array('depth_limit', $node->hints, true)) {
                $n = new InstanceValue();
                $n->transplant($node);
                $n->name = 'childNodes';
                $n->classname = 'DOMNodeList';
                $c->contents = [$n];
            } else {
                foreach ($childNodes->contents as $node) {
                    // Remove text nodes if theyre empty                     if ($node instanceof BlobValue && '#text' === $node->name && (\ctype_space($node->value->contents) || '' === $node->value->contents)) {
                        continue;
                    }

                    $c->contents[] = $node;
                }
public $filename;
    public $startline;
    public $hints = ['object'];

    public function getType(): ?string
    {
        return $this->classname;
    }

    public function transplant(Value $old): void
    {
        parent::transplant($old);

        if ($old instanceof self) {
            $this->classname = $old->classname;
            $this->spl_object_hash = $old->spl_object_hash;
            $this->spl_object_id = $old->spl_object_id;
            $this->filename = $old->filename;
            $this->startline = $old->startline;
        }
    }

    /** * @psalm-param class-string $a * @psalm-param class-string $b */
return;
            }
        }
    }

    /** * @param object &$var */
    protected function blacklistValue(&$var, Value &$o): void
    {
        $object = new InstanceValue();
        $object->transplant($o);
        $object->classname = \get_class($var);
        $object->spl_object_hash = \spl_object_hash($var);
        $object->clearRepresentations();
        $object->value = null;
        $object->size = null;
        $object->hints[] = 'blacklist';

        $o = $object;

        $this->parser->haltParse();
    }
}


    /** * Parses a string into a Kint BlobValue structure. * * @param string &$var The input variable * @param Value $o The base object */
    private function parseString(string &$var, Value $o): Value
    {
        $string = new BlobValue();
        $string->transplant($o);
        $string->encoding = BlobValue::detectEncoding($var);
        $string->size = \strlen($var);

        $rep = new Representation('Contents');
        $rep->contents = $var;
        $rep->implicit_label = true;

        $string->addRepresentation($rep);
        $string->value = $rep;

        $this->applyPlugins($var$string, self::TRIGGER_SUCCESS);

        
$rep->contents = $this->parser->parse($meta$base_obj);

        if (!\in_array('depth_limit', $rep->contents->hints, true)) {
            $rep->contents = $rep->contents->value->contents;
        }

        $o->addRepresentation($rep, 0);
        $o->value = $rep;

        $stream = new StreamValue($meta);
        $stream->transplant($o);
        $o = $stream;
    }
}

        return Parser::TRIGGER_SUCCESS;
    }

    public function parse(&$var, Value &$o, int $trigger): void
    {
        if (!$var instanceof Throwable) {
            return;
        }

        $throw = new ThrowableValue($var);
        $throw->transplant($o);
        $r = new SourceRepresentation($var->getFile()$var->getLine());
        $r->showfilename = true;
        $throw->addRepresentation($r, 0);

        $o = $throw;
    }
}
use ReflectionMethod;

class TraceFrameValue extends Value
{
    public $trace;
    public $hints = ['trace_frame'];

    public function __construct(Value $base, array $raw_frame)
    {
        parent::__construct();

        $this->transplant($base);

        if (!isset($this->value)) {
            throw new InvalidArgumentException('Tried to create TraceFrameValue from Value with no value representation');
        }

        $this->trace = [
            'function' => $raw_frame['function'],
            'line' => $raw_frame['line'] ?? null,
            'file' => $raw_frame['file'] ?? null,
            'class' => $raw_frame['class'] ?? null,
            'type' => $raw_frame['type'] ?? null,
            
public function getValueShort(): ?string
    {
        if ($rep = $this->value) {
            return '"'.$rep->contents.'"';
        }

        return null;
    }

    public function transplant(Value $old): void
    {
        parent::transplant($old);

        if ($old instanceof self) {
            $this->encoding = $old->encoding;
        }
    }

    /** * @psalm-param Encoding $encoding * * @param mixed $encoding */
    
if (!$o->value) {
            return;
        }

        $trace = $this->parser->getCleanArray($var);

        if (\count($trace) !== \count($o->value->contents) || !Utils::isTrace($trace)) {
            return;
        }

        $traceobj = new TraceValue();
        $traceobj->transplant($o);
        $rep = $traceobj->value;

        $old_trace = $rep->contents;

        Utils::normalizeAliases(self::$blacklist);
        $path_blacklist = self::normalizePaths(self::$path_blacklist);

        $rep->contents = [];

        foreach ($old_trace as $frame) {
            $index = $frame->name;

            

        return Parser::TRIGGER_SUCCESS;
    }

    public function parse(&$var, Value &$o, int $trigger): void
    {
        if (!$var instanceof DateTime) {
            return;
        }

        $object = new DateTimeValue($var);
        $object->transplant($o);

        $o = $object;
    }
}
Home | Imprint | This part of the site doesn't use cookies.