Removed the lines with the wrongly sorted tags.

@return array The first tag token of this doc block.
3209
private function removeOldTagLines(): array
    {
        $tags = $this->getTagTokens();
        $firstTag = array_shift($tags);

        (new LineHelper($this->file))
            ->removeLines(
                $firstTag['line'],
                $this->tokens[$this->token['comment_closer']]['line']
            );

        return $firstTag;
    }
418833
private function createNewSortedTagsContent(): string
    {
        $file = $this->file;
        $eolChar = $file->getEolChar();
        $newContent = '';
        $prevTagContent = '';
        $sortedTags = $this->sortTokens($this->getTagTokens());
        $tagCounts = $this->docTagHelper->getTagCounts($sortedTags);
        $withReturn = false;

        foreach ($sortedTags as $tag) {
            $lineStartingPadding = str_pad('', $tag['column'] - 3, ' ');
            $thisTagContent = $tag['content'];
            $isReturn = $thisTagContent === '@return';

            $isGroupSwitch =
                // Did we switch the tag ...
                $prevTagContent && ($prevTagContent !== $thisTagContent) &&
                // ... but do we skip singles or are we entering the return block which should contain only 1 tag.
                (($tagCounts[$thisTagContent] !== 1) || ($isReturn && !$withReturn));

            // Insert new line between groups.
            if ($isGroupSwitch) {
                $newContent .= $lineStartingPadding . '*' . $eolChar;
            }

            // Create the new Tag.
            // WARNING We do not need a line break in the tag summary.
            $newContent .= $lineStartingPadding . '* ' . trim($thisTagContent);

            if ($tag['contents']) {
                $prevLine = $tag['line'];
                foreach ($tag['contents'] as $subToken) {
                    // If we have a line switch, we need to create the correct indentation from before ...
                    if ($withLineSwitch = $subToken['line'] > $prevLine) {
                        $newContent .= $eolChar .
                            $lineStartingPadding . '*' .
                            str_repeat(' ', $subToken['column'] - strlen($lineStartingPadding) - 2);

                        $prevLine = $subToken['line'];
                    }

                    // ... if we have no line switch, then an additional whitespace is enough.
                    $newContent .= ($withLineSwitch ? '' : ' ') . $subToken['content'];
                }
            }

            $newContent .= $eolChar;

            $prevTagContent = $thisTagContent;
            $withReturn = $isReturn;
        }

        $newContent .= $lineStartingPadding . '*/' . $eolChar;

        return $newContent;
    }
1046668
public function getTagsList()
    {
        $tags = explode("\n", str_replace("\r", "\n", trim($this->getTags())));
        $clean_tags = [];
        foreach ($tags as $tag) {
            $tag = trim($tag);
            if ($tag !== '') {
                $clean_tags[] = $tag;
            }
        }

        return $clean_tags;
    }
296739
public function getRemovedLines()
    {
        return array_values(array_filter(
            $this->lines,
            function (Line $line) {
                return $line->getType() == Line::REMOVED;
            }
        ));
    }
516439
public function deleteAll() {
        $tags = $this->read();

        $ids = [];

        foreach ($tags as $tag) {
            $ids[] = $tag['id'];
        }

        if (count($ids) > 0) {
            $this->batchDelete($ids);
        }

        return $this;
    }
1136988
protected function getTokenReplaces()
    {
        $replaces = array();

        foreach ($this->tokens as $token => $value) {
            $key              = $this->getFormatter()->untokenize($token);
            $formatter        = $this->getTokenFormatter($key);
            $replaces[$token] = $formatter::format($value);
        }

        return $replaces;
    }
985921
public function getText()
    {
        $lines = [];
        if ($this->error->has()) {
            foreach ($this->error->getList() as $error) {
                if ($error instanceof HtmlAwareErrorInterface && $error->messageContainsHtml()) {
                    $lines[] = strip_tags((string) $error);
                } else {
                    $lines[] = (string) $error;
                }
            }
        }

        return implode("\n", $lines);
    }
545201
public function _processInlineTags(&$tag, $first = FALSE)
    {
        $description = '';
        if (is_array($tag)) $tag = $tag[0];
        if (is_object($tag)) {
            if ($first) {
                $tags =& $tag->firstSentenceTags($this->_doclet);
            } else {
                $tags =& $tag->inlineTags($this->_doclet);
            }
            if ($tags) {
                foreach ($tags as $aTag) {
                    if ($aTag) {
                        $description .= $aTag->text($this->_doclet);
                    }
                }
            }

            return $this->_doclet->formatter->toFormattedText($description);
        }

        return NULL;
    }
968446
protected function _remove()
	{
    $_tagsArray = array();
		foreach ($this->_tagsArray as $key => $value) {
			if (!in_array($value['tag'], $this->getRemoveTags())) {
				$_tagsArray[$value['tag']] = $value;
			}
		}
		$this->_tagsArray = array();
		$this->_tagsArray = $_tagsArray;
		return $this->_tagsArray;
	}
372187
public function tagged()
    {
        $out = '';

        // call stream filters.
        foreach ($this->streamFilters as $f) {
            $this->tokens = call_user_func($f[1], $this->tokens);
        }
        foreach ($this->tokens as $t) {
            $type = $t[0];

            // speed is roughly 10% faster if we process the filters inside this
            // loop instead of separately.
            if (isset($this->filters[$type])) {
                foreach ($this->filters[$type] as $filter) {
                    $t = call_user_func($filter[1], $t);
                }
            }
            list($type, $string, $esc) = $t;

            if (!$esc) {
                $string = Utils::escapeString($string);
            }
            if ($type !== null) {
                $out .= Utils::tagBlock($type, $string);
            } else {
                $out .= $string;
            }
        }
        return $out;
    }
418818
public function tags()
    {
        $result = $this->execute('list', array('--xml' => true, $this->getUrl() . '/' . $this->basePaths['tags']));

        $tags = array();
        foreach ($result as $fileinfo) {
            $tags[] = new Reference($fileinfo->getFilename(), Reference::TAG, $fileinfo->getCommit()->getRevision());
        }

        return $tags;
    }
256013
public function get_related_tags() {
        $manual = $this->get_manual_related_tags();
        $automatic = $this->get_correlated_tags();
        $relatedtags = array_merge($manual, $automatic);

        // Remove duplicated tags (multiple instances of the same tag).
        $seen = array();
        foreach ($relatedtags as $instance => $tag) {
            if (isset($seen[$tag->id])) {
                unset($relatedtags[$instance]);
            } else {
                $seen[$tag->id] = 1;
            }
        }

        return $relatedtags;
    }
486869
public function parseLines()
    {
        $text = [];

        while (($line = $this->nextLine()) !== false) {
            $line = rtrim($line);

            // Skip empty lines
            if ($line == "") {
                $text[] = null;
                continue;
            }

            // Look at start of line to detect valid blocktypes
            $blockTypes = [];
            $marker = $line[0];
            if (isset($this->blockTypes[$marker])) {
                foreach ($this->blockTypes[$marker] as $blockType) {
                    $blockTypes[] = $blockType;
                }
            }

            // Check if line is matching a detected blocktype
            foreach ($blockTypes as $blockType) {
                if ($this->{"block".$blockType}($line)) {
                    continue;
                }
            }
        }

        $text = implode("\n", $this->lines);

        return [
            "text" => $text,
            "frontmatter" => $this->frontmatter,
        ];
    }
91258
private function getAnnotations()
    {
        $tokens = array();

        while (null !== $this->lexer->lookahead) {

            // start at the @ symbol
            if (DocLexer::T_AT !== $this->lexer->lookahead['type']) {
                $this->lexer->moveNext();

                continue;
            }

            // something about being preceded by a non-catchable pattern
            $position = $this->lexer->token['position']
                + strlen($this->lexer->token['value']);

            if ((null !== $this->lexer->token)
                && ($this->lexer->lookahead['position'] === $position)) {
                $this->lexer->moveNext();

                continue;
            }

            // make sure we get a valid annotation name
            if ((null === ($glimpse = $this->lexer->glimpse()))
                || ((DocLexer::T_NAMESPACE_SEPARATOR !== $glimpse['type'])
                    && !in_array($glimpse['type'], self::$classIdentifiers))) {
                $this->lexer->moveNext();

                continue;
            }

            // find them all and merge them to the list
            if (null !== ($token = $this->getAnnotation())) {
                $tokens = array_merge($tokens, $token);
            }
        }

        return $tokens;
    }
1092562
public function tags()
    {
        if (null === $this->tags) {
            $retval = $this->execute('ls-remote', array('--tags' => true, $this->getUrl()));

            if ('' === trim($retval)) {
                return $this->tags = array();
            }

            $list = explode("\n", rtrim($retval));

            $tags = array();
            foreach ($list as $line) {
                list ($hash, $ref) = explode("\t", $line);
                $tags[] = new Reference(str_replace('refs/tags/', '', $ref), Reference::TAG, $hash);
            }

            $this->tags = $tags;
        }

        return $this->tags;
    }
94862
public function getIndexDefinition()
    {
        return [
            'tag_keywords' => new Search\FieldType\MultipleStringField(),
            'parent_tag_ids' => new Search\FieldType\MultipleIntegerField(),
            'tag_ids' => new Search\FieldType\MultipleIntegerField(),
            'tag_text' => new Search\FieldType\TextField(),
            'fulltext' => new Search\FieldType\FullTextField(),
        ];
    }
569572
private function loadTagTokens(): array
    {
        $barrier = 0;
        $tokens = $this->docTagHelper->getTagTokens();

        $tokens = array_filter($tokens, function (array $token) use (&$barrier): bool {
            $allowed = true;

            if ($barrier) {
                if ($allowed = $token['column'] <= $barrier) {
                    $barrier = 0;
                }
            }

            if ($allowed && array_key_exists('contents', $token)) {
                $barrier = $token['column'];
            }

            return $allowed;
        });

        return $tokens;
    }