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