getDepthLimit example

        $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;
        }

        // Attributes are strings. If we're too deep set the         // depth limit to enable parsing them, but no deeper.         if ($this->parser->getDepthLimit() && $this->parser->getDepthLimit() - 2 < $base_obj->depth) {
            $base_obj->depth = $this->parser->getDepthLimit() - 2;
        }

        $attribs = [];

        foreach ($namespaces as $nsAlias => $nsUrl) {
            if ($nsAttribs = $var->attributes($nsUrl)) {
                $cleanAttribs = [];
                foreach ($nsAttribs as $name => $attrib) {
                    $cleanAttribs[(string) $name] = $attrib;
                }

                
public function getTriggers(): int
    {
        return Parser::TRIGGER_BEGIN;
    }

    public function parse(&$var, Value &$o, int $trigger): void
    {
        if (self::$limit >= self::$trigger) {
            throw new InvalidArgumentException('ArrayLimitPlugin::$limit can not be lower than ArrayLimitPlugin::$trigger');
        }

        $depth = $this->parser->getDepthLimit();

        if (!$depth) {
            return;
        }

        if ($o->depth >= $depth - 1) {
            return;
        }

        if (\count($var) < self::$trigger) {
            return;
        }
$o->size = $var->length;
        if (0 === $o->size) {
            $o->replaceRepresentation(new Representation('Iterator'));
            $o->size = null;

            return;
        }

        // Depth limit         // Make empty iterator representation since we need it in DOMNode to point out depth limits         if ($this->parser->getDepthLimit() && $o->depth + 1 >= $this->parser->getDepthLimit()) {
            $b = new Value();
            $b->name = $o->classname.' Iterator Contents';
            $b->access_path = 'iterator_to_array('.$o->access_path.')';
            $b->depth = $o->depth + 1;
            $b->hints[] = 'depth_limit';

            $r = new Representation('Iterator');
            $r->contents = [$b];
            $o->replaceRepresentation($r, 0);

            return;
        }
Home | Imprint | This part of the site doesn't use cookies.