Convert the Tag into a string (open() content() close())

@return string
197695
public function __tostring()
    {
        ob_start();
        $close = $this->_opened;
        $this->open();
        if (!in_array('start', $this->options)) {
            $this->content();
        }
        if (!$this->hasOption('start') || $close) {
            $this->close();
        }

        return ob_get_clean();
    }
867328
public function toString()
    {
        $query = '';

        if ($this->sql) {
            return $this->sql;
        }

        switch ($this->type) {
            case 'element':
                $query .= (string) $this->element;
                break;

            case 'select':
                $query .= (string) $this->select;
                $query .= (string) $this->from;

                if ($this->join) {
                    // Special case for joins
                    foreach ($this->join as $join) {
                        $query .= (string) $join;
                    }
                }

                if ($this->where) {
                    $query .= (string) $this->where;
                }

                if ($this->group) {
                    $query .= (string) $this->group;
                }

                if ($this->having) {
                    $query .= (string) $this->having;
                }

                if ($this->order) {
                    $query .= (string) $this->order;
                }

                break;

            case 'union':
                $query .= (string) $this->union;
                break;

            case 'delete':
                $query .= (string) $this->delete;
                $query .= (string) $this->from;

                if ($this->join) {
                    // Special case for joins
                    foreach ($this->join as $join) {
                        $query .= (string) $join;
                    }
                }

                if ($this->where) {
                    $query .= (string) $this->where;
                }

                break;

            case 'update':
                $query .= (string) $this->update;

                if ($this->join) {
                    // Special case for joins
                    foreach ($this->join as $join) {
                        $query .= (string) $join;
                    }
                }

                $query .= (string) $this->set;

                if ($this->where) {
                    $query .= (string) $this->where;
                }

                break;

            case 'insert':
                $query .= (string) $this->insert;

                // Set method
                if ($this->set) {
                    $query .= (string) $this->set;
                } elseif ($this->values) {
                    // Columns-Values method
                    if ($this->columns) {
                        $query .= (string) $this->columns;
                    }

                    $elements = $this->values->getElements();

                    if (!($elements[0] instanceof $this)) {
                        $query .= ' VALUES ';
                    }

                    $query .= (string) $this->values;
                }

                break;

            case 'call':
                $query .= (string) $this->call;
                break;

            case 'exec':
                $query .= (string) $this->exec;
                break;
        }

        // Process Limit
        $query = $this->processLimit($query, $this->limit, $this->offset);

        if ($this->suffix) {
            $query .= ' ' . (string) $this->suffix;
        }

        if ($this->type === 'select' && $this->alias !== null) {
            $query = sprintf('(%s) AS %s', $query, $this->alias);
        }

        return $query;
    }
1339749
public static function close()
    {
        //get the last opened tag
        $tag = self::$opened[count(self::$opened) - 1];

        //remove the last opened tag
        array_pop(self::$opened);

        return '</'.$tag.'>';
    }
1151731
public function render()
    {
        $this->tag = '<' . $this->name;

        if (count($this->attr)) {
            $this->tag .= ' ';
            foreach ($this->attr as $key => $value) {
                $this->tag .= $key . '="';
                if (is_array($value)) {
                    $this->tag .= implode(' ', $value);
                } else {
                    $this->tag .= $value != false? $value: 0;
                }
                $this->tag .= '" ';
            }
        }
        $this->tag = trim($this->tag) . '>';

        if (!in_array(strtolower($this->name), $this->elementsNoClosing)) {
            $this->tag .= $this->parseValue($this->value) . '</' . $this->name . '>';
        }

        return $this->tag;
    }
391021
public function make()
    {
        if ($this->closeMode === self::CLOSE_ONLY)
            return '</' . $this->tag . '>';

        $join = function($tag, $last = null) {
            if ($last)
                $tag[] = $last;
            return join('', $tag);
        };

        $tag = [];
        $tag[] = '<' . $this->tag;

        foreach ($this->attributes as $name => $values)
        {
            if ($values === [null])
                continue;

            $tag[] = ' ' . $this->makeAttribute($name, $values);
        }

        if ($this->closeMode === self::SELF_CLOSE)
            return $join($tag, ' />');
        else
            $tag[] = '>';

        if ($this->closeMode === self::DONT_CLOSE)
            return $join($tag);

        foreach ($this->contents as $content)
        {
            if ($content instanceof Tag)
                $tag[] = $content->make();
            else
                $tag[] = $content;
        }

        return $join($tag, '</' . $this->tag . '>');
    }
4144
public function toString() {
		// List of void elements from HTML5, section 8.1.2 as of 2016-09-19
		static $voidElements = [
			'area',
			'base',
			'br',
			'col',
			'embed',
			'hr',
			'img',
			'input',
			'keygen',
			'link',
			'meta',
			'param',
			'source',
			'track',
			'wbr',
		];

		$attributes = '';
		foreach ( $this->getGeneratedAttributes() as $key => $value ) {
			if ( !preg_match( '/^[0-9a-zA-Z-]+$/', $key ) ) {
				throw new Exception( 'Attribute name must consist of only ASCII letters, numbers and dash' );
			}

			// Note that this is not a complete list of HTML attributes that need this validation.
			// We only check for the ones that are generated by built-in OOUI PHP elements.
			if ( $key === 'href' || $key === 'action' ) {
				if ( !self::isSafeUrl( $value ) ) {
					// We can't tell for sure whether this URL is safe (although it might be). The only safe
					// URLs that we can't check for is relative ones, so just prefix with './'. This should
					// change nothing for relative URLs, and it will neutralize sneaky 'javascript:' URLs.
					$value = './' . $value;
				}
			}

			// Use single-quotes around the attribute value in HTML, because
			// some of the values might be JSON strings
			// 1. Encode both single and double quotes (and other special chars)
			$value = htmlspecialchars( $value, ENT_QUOTES );
			// 2. Decode double quotes, for readability.
			$value = str_replace( '&quot;', '"', $value );
			// 3. Wrap attribute value in single quotes in the HTML.
			$attributes .= ' ' . $key . "='" . $value . "'";
		}

		// Content
		$content = '';
		foreach ( $this->content as $part ) {
			if ( is_string( $part ) ) {
				$content .= htmlspecialchars( $part );
			} elseif ( $part instanceof Tag || $part instanceof HtmlSnippet ) {
				$content .= (string)$part;
			}
		}

		if ( !preg_match( '/^[0-9a-zA-Z]+$/', $this->tag ) ) {
			throw new Exception( 'Tag name must consist of only ASCII letters and numbers' );
		}

		// Tag
		if ( !$content && in_array( $this->tag, $voidElements ) ) {
			return '<' . $this->tag . $attributes . ' />';
		} else {
			return '<' . $this->tag . $attributes . '>' . $content . '</' . $this->tag . '>';
		}
	}
1288462
protected function tagName() {
        $tok = $this->scanner->current();
        if (!ctype_alpha($tok)) {
            return false;
        }

        // We know this is at least one char.
        $name = strtolower($this->scanner->charsWhile(":_-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
        $attributes = array();
        $selfClose = false;

        // Handle attribute parse exceptions here so that we can
        // react by trying to build a sensible parse tree.
        try {
            do {
                $this->scanner->whitespace();
                $this->attribute($attributes);
            } while (!$this->isTagEnd($selfClose));
        } catch (HTML5_Parser_Exception $e) {
            $selfClose = false;
        }

        $mode = $this->events->startTag($name, $attributes, $selfClose);
        // Should we do this? What does this buy that selfClose doesn't?
        if ($selfClose) {
            $this->events->endTag($name);
        } elseif (is_int($mode)) {
            // fprintf(STDOUT, "Event response says move into mode %d for tag %s", $mode, $name);
            $this->setTextMode($mode, $name);
        }

        $this->scanner->next();

        return true;
    }
681302
public function toString()
    {
        $result = '';

        if (!empty($this->scheme)) {
            $result.= $this->scheme . ':';
        }

        if (!empty($this->authority)) {
            $result.= '//' . $this->authority;
        }

        $result.= $this->path;

        if (!empty($this->query)) {
            $result.= '?' . $this->query;
        }

        if (!empty($this->fragment)) {
            $result.= '#' . $this->fragment;
        }

        return $result;
    }
577577
protected function tagOpen() {
        if ($this->scanner->current() != '<') {
            return false;
        }

        // Any buffered text data can go out now.
        $this->flushBuffer();

        $this->scanner->next();

        return $this->markupDeclaration() || $this->endTag() || $this->processingInstruction() || $this->tagName() ||
                /*  This always returns false. */
                $this->parseError("Illegal tag opening") || $this->characterData();
    }
875253
public function ToString()
	{
		$sb = array_reduce( $this->ToList(), function( $carry, /** @var XPath2Item $item */ $item )
		{
			$carry[] = $item->ToString();
			return $carry;
		}, array() );
		$s = implode( ", ", $sb );
		return $s;

		$sb = array();
		foreach ( $this->ToList() as $node )
		{
			$sb[] = is_object( $node ) ? $node->ToString() : $node;
		}

		$s = implode( ", ", $sb );

		return empty( $s)
			? "<empty>"
			: $s;
	}
444394
public function getBogusContent()
    {
        $generator = $this->documentGenerator->getInlineGenerator('textline');
        $generator->addRawContent($this->beginTag);
        $m = count($this->contents) - 1;
        $s = count($this->separators);
        foreach ($this->contents as $k => $v) {
            if ($this->attribute[$k] == '$$') {
                foreach ($this->generator->getChildGenerators() as $child) {
                    $generator->addContent($child);
                }
            } else {
                $generator->addRawContent($v);
            }
            if ($k < $m) {
                if ($k < $s) {
                    $generator->addRawContent($this->separators[$k]);
                } else {
                    $generator->addRawContent(end($this->separators));
                }
            }
        }

        return $generator;
    }
287141
private function compileOpenTag( $encoding = 'UTF-8' ): string
    {

        $html       = "<" . $this->tag;
        $attributes = $this->compileAttributes( $encoding );

        if ( ! empty( $attributes ) ) {
            $html .= " $attributes";
        }

        // if we do have content, then let's carry on.
        if ( $this->hasContent() ) {
            $html .= '>';
        } else {
            // but if we do not have content, it must be a self-closed tag
            $html .= ' />';
        }

        return $html;
    }
2766
public function getIndexableContent()
    {
        $content = self::cleanContent($this->content);
        $content = html_entity_decode($content, ENT_QUOTES, 'UTF-8');
        // after entity decoding we might have tags again
        $content = strip_tags($content);
        $content = trim($content);

        return $content;
    }
592036
protected function outputOpeningTag()
    {
        echo '<', htmlspecialchars($this->_tag);
        foreach ($this->_attributes as $name => $value) {
            echo ' ', htmlspecialchars($name), '="', htmlspecialchars($value), '"';
        }
        echo '>';
        if ($this->_tag == 'html' || $this->_tag == 'head' || $this->_tag == 'body') {
            echo "\n";
        }
    }
595836
public function getStart(): string
    {
        $str = '<' . $this->tag . ' ';
        foreach ($this->attrs as $key => $value) {
            $str .= $key . '="' . $value . '" ';
        }
        $str .= '>';

        return $str;
    }
1358174
public function toHtml()
    {
        if ($this->numPages <= 1) {
            return '';
        }

        $html = '<ul class="pagination">';
        if ($this->getPrevUrl()) {
            $html .= '<li><a href="' . htmlspecialchars($this->getPrevUrl()) . '">&laquo; '. $this->previousText .'</a></li>';
        }

        foreach ($this->getPages() as $page) {
            if ($page['url']) {
                $html .= '<li' . ($page['isCurrent'] ? ' class="active"' : '') . '><a href="' . htmlspecialchars($page['url']) . '">' . htmlspecialchars($page['num']) . '</a></li>';
            } else {
                $html .= '<li class="disabled"><span>' . htmlspecialchars($page['num']) . '</span></li>';
            }
        }

        if ($this->getNextUrl()) {
            $html .= '<li><a href="' . htmlspecialchars($this->getNextUrl()) . '">'. $this->nextText .' &raquo;</a></li>';
        }
        $html .= '</ul>';

        return $html;
    }
202366
public function openTag()
    {
        return '<form'.
               ' method="'.esc_attr($this->cfg->method).'"'.

               ($this->action
                    ? ' action="'.esc_url($this->s::restActionUrl($this->action)).'"'
                    : ' action="'.esc_url($this->cfg->action_url).'"'
               ).// NOTE: The `action` can also be empty.

               ' enctype="multipart/form-data"'.
               ' accept-charset="utf-8"'.
               ' autocomplete="off"'.
               '>';
    }