private function append(\Closure $appendTo, string $type): XmlStreamWriter
    {
        libxml_use_internal_errors(true);
        try {
            $appendTo(end($this->openElements));
        } catch (\DOMException $e) {
            throw new XmlException('Error writing "' . $type, $e);
        }

        $errors = libxml_get_errors();
        if (!empty($errors)) {
            libxml_clear_errors();
            throw new XmlException(
                    'Error writing "' . $type . '": '
                    . implode(', ', array_map(
                            function($error) { return trim($error->message); },
                            $errors
                    ))
            );
        }

        return $this;
    }
private function append(\Closure $appendTo, string $type): XmlStreamWriter
    {
        libxml_use_internal_errors(true);
        try {
            $appendTo(end($this->openElements));
        } catch (\DOMException $e) {
            throw new XmlException('Error writing "' . $type, $e);
        }

        $errors = libxml_get_errors();
        if (!empty($errors)) {
            libxml_clear_errors();
            throw new XmlException(
                    'Error writing "' . $type . '": '
                    . implode(', ', array_map(
                            function($error) { return trim($error->message); },
                            $errors
                    ))
            );
        }

        return $this;
    }
private function append ( \ Closure $ appendTo , string $ type ) : XmlStreamWriter { libxml_use_internal_errors ( true ) ; try { $ appendTo ( end ( $ this -> openElements ) ) ; } catch ( \ DOMException $ e ) { throw new XmlException ( 'Error writing "' . $ type , $ e ) ; } $ errors = libxml_get_errors ( ) ; if ( ! empty ( $ errors ) ) { libxml_clear_errors ( ) ; throw new XmlException ( 'Error writing "' . $ type . '": ' . implode ( ', ' , array_map ( function ( $ error ) { return trim ( $ error -> message ) ; } , $ errors ) ) ) ; } return $ this ; }
wraps handling on element stack

@param   \Closure  $appendTo  function to work with element stack
@param   string    $type      type of stack handling
@return  \stubbles\xml\XmlStreamWriter
@throws  \stubbles\xml\XmlException
wraps handling on element stack