Traverser example


    public function traverse(callable $fn$options = array())
    {
        $traverser = new \Peast\Traverser($options);
        $traverser->addFunction($fn)->traverse($this);
        return $this;
    }
    
    /** * Returns a serializable version of the node * * @return array */
    #[\ReturnTypeWillChange]     public function jsonSerialize()
    {
public function save($dom$file$options = array())
    {
        $close = true;
        if (is_resource($file)) {
            $stream = $file;
            $close = false;
        } else {
            $stream = fopen($file, 'wb');
        }
        $options = array_merge($this->defaultOptions, $options);
        $rules = new OutputRules($stream$options);
        $trav = new Traverser($dom$stream$rules$options);

        $trav->walk();
        /* * release the traverser to avoid cyclic references and allow PHP to free memory without waiting for gc_collect_cycles */
        $rules->unsetTraverser();
        if ($close) {
            fclose($stream);
        }
    }

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