This method returns html comment

@param string $text
@param bool   $addSpaces
@return string
346316
public static function comment(string $text = '', bool $addSpaces = false): string
    {
        $space = $addSpaces === true ? ' ' : '';
        return \sprintf('<!--%s%s%s-->', $space, $text, $space);
    }
159538
private function stripComments(string $content): string
    {
        $tokens = token_get_all($content);

        $content_sans_comments = array_reduce(
            $tokens,
            function ($carry, $token) {
                if (is_string($token)) {
                    // simple 1-character token
                    return $carry . $token;
                } else {
                    // token array
                    list($id, $text) = $token;
                    switch ($id) {
                        case T_COMMENT:
                        case T_DOC_COMMENT:
                            // no action on comments
                            break;
                        default:
                            // anything else -> output "as is"
                            return $carry . $text;
                            break;
                    }
                }

                return $carry;
            },
            ""
        );
        return $content_sans_comments;
    }
1289491
public static function cleanText(string $text)
    {
        $text = preg_replace('/<script[^>]*>.*?</script>/si', '', $text);
        $text = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $text);
        $text = preg_replace('/<!--.+?-->/', '', $text);
        $text = preg_replace('/{.+?}/', '', $text);
        $text = preg_replace('/&nbsp;/', ' ', $text);
        $text = preg_replace('/&amp;/', ' ', $text);
        $text = preg_replace('/&quot;/', ' ', $text);
        $text = strip_tags($text);
        $text = htmlspecialchars($text);

        return $text;
    }
412092
def comment(text)
      comment_node = ::Nokogiri::XML::Comment.new(doc, " #{text} ")
      current_element.add_child(comment_node)
    end
1334333
function applyStyle($text, $styles = [])
    {
        if (!self::$supported)
            return $text;

        if (is_string($styles))
        {
            $styles = [$styles];
        }

        $output = $text;
        foreach ($styles as $style) {
            if (isset(self::$theme[$style])) {
                $output = $this->applyStyle($output, self::$theme[$style]);
            } else {
                if (isset(self::$styles[$style])) {
                    $pre  = $this->escSequence(self::$styles[$style]);
                    $post = $this->escSequence(0);
                } else {
                    $pre = $post = '';
                }

                $output = $pre . $output . $post;
            }
        }

        return $output;
    }
643926
public function checkText($text, array $params = [])
    {
        $query = $this->mergeParams($this->getDefaultParams(), $params);

        $query['text'] = $text;

        $response = $this->sendRequest(
            'POST',
            '/services/spellservice.json/checkText',
            [
                'form_params' => $query
            ]
        );

        if (!empty($query['callback'])) {
            return (string) $response->getBody();
        }

        return $this->getDecodedBody($response->getBody());
    }
878727
public function isTextValid(string $text): bool
    {
        $parser = new Node_Container_Document();

        if ($this->configData['emoticons']['active']) {
            $parser->add_emoticons($this->configData['emoticons']['path']);
        }

        $this->errorText = '';
        $result = true;
        try {
            $parser->parse($text)
                ->detect_links()
                ->detect_emails();

            if ($this->configData['emoticons']['active']) {
                $parser->detect_emoticons();
            }

            $parser->get_html();

        } catch (\Exception $e) {
            $result = false;
            $this->errorText = $e->getMessage();
        } catch (\Throwable $e) {
            $result = false;
            $this->errorText = $e->getMessage();
        }

        return $result;
    }
158377
protected function removeHtml($text)
    {
        if (!trim($text)) {
            return '';
        }

        // Remove Styles and Scripts
        $crawler = new Crawler($text);
        $crawler->filter('style, script')->each(function (Crawler $crawler) {
            foreach ($crawler as $node) {
                $node->parentNode->removeChild($node);
            }
        });
        $text = $crawler->html();

        // Remove HTML markup
        $result = strip_tags($text);

        // Decode HTML entities
        $result = trim(html_entity_decode($result, ENT_QUOTES));

        return $result;
    }
1173272
public function comment(string $text, array $style = []): string
    {
        return $this->line($text, ['fg' => static::BLACK, 'bold' => 1] + $style);
    }
801815
public static function generate(string $text = '', ?int $charCount = null): string
    {
        $text = StripTags::strip($text);
        $text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5);
        $text = \trim(\preg_replace('/\s+/', ' ', $text));

        if ($charCount === null || \mb_strlen($text, 'UTF-8') <= $charCount) {
            return $text;
        }

        $expand = Tags::span(static::getConstant('TXT_EXPANDABLE_EXPAND'), ['class' => 'expand-link']);
        $collapse = Tags::span(static::getConstant('TXT_EXPANDABLE_COLLAPSE'), ['class' => 'collapse-link']);
        $short = Shortener::shorten($text, $charCount, true, '');
        $short = Tags::span(\sprintf($short.'...'.$expand), ['class' => 'short']);
        $full = Tags::span(\sprintf($text.$collapse), ['class' => 'full']);

        return Tags::span($short.$full, ['class' => 'expandable']);
    }
977860
public function escape($text, $extra = false)
	{
		$this->connect();

		$result = mysqli_real_escape_string($this->getConnection(), $text);

		if ($extra)
		{
			$result = addcslashes($result, '%_');
		}

		return $result;
	}
95084
protected function isTypeComment($commentText)
    {
        return strpos($commentText, self::TYPE_TAG) !== false || strpos($commentText, '@type') !== false;
    }
1314793
public static function add(string $text, string $tag): string
    {
        return self::wrap($text, $tag);
    }
1044805
public function getIntentByText($text, Context $context = null, array $extraParams = [])
    {
        return $this->messageApi->extractMeaning($text, $context, $extraParams);
    }
86490
public function escape($text, $extra = false)
    {
        if (is_int($text) || is_float($text)) {
            return $text;
        }

        $text = str_replace("'", "''", $text);

        return addcslashes($text, "\000\n\r\\\032");
    }
51159
public function sentence(string $text = null): Sentence
    {
        $sentence = Sentence::factory();
        if ($text !== null) {
            $sentence->text($text);
        }

        /** @var ContainerElement $this */
        return $this->addElement($sentence);
    }
541862
public static function resumeHtml($text, $nbCaracter, $readMoreText = '')
    {
        if (is_numeric($nbCaracter)) {
            $lengthBeforeWithoutHtml = strlen(trim(strip_tags($text)));
            $htmlSplitMask = '#</?([a-zA-Z1-6]+)(?: +[a-zA-Z]+="[^"]*")*( ?/)?>#';
            $htmlMatchMask = '#<(?:/([a-zA-Z1-6]+)|([a-zA-Z1-6]+)(?: +[a-zA-Z]+="[^"]*")*( ?/)?)>#';
            $text                   .= ' ';
            $textPieces = preg_split($htmlSplitMask, $text, -1, PREG_SPLIT_OFFSET_CAPTURE | PREG_SPLIT_NO_EMPTY);
            $pieceNumber = count($textPieces);

            if ($pieceNumber == 1) {
                $text        .= ' ';
                $lenghtBefore = strlen($text);
                $text = substr($text, 0, strpos($text, ' ', $lenghtBefore > $nbCaracter ? $nbCaracter : $lenghtBefore));

                if ($readMoreText != '' && $lenghtBefore > $nbCaracter) {
                    $text .= $readMoreText;
                }
            } else {
                $length = 0;
                $indexLastPiece = $pieceNumber - 1;
                $position = $textPieces[$indexLastPiece][1] + strlen($textPieces[$indexLastPiece][0]) - 1;
                $indexPiece = $indexLastPiece;
                $searchSpace = true;

                foreach ($textPieces as $index => $bout) {
                    $length += strlen($bout[0]);
                    if ($length >= $nbCaracter) {
                        $positionEndPiece = $bout[1] + strlen($bout[0]) - 1;
                        $position = $positionEndPiece - ($length - $nbCaracter);
                        if (($positionSpace = strpos($bout[0], ' ', $position - $bout[1])) !== false) {
                            $position = $bout[1] + $positionSpace;
                            $searchSpace = false;
                        }
                        if ($index != $indexLastPiece) {
                            $indexPiece = $index + 1;
                        }
                        break;
                    }
                }

                if ($searchSpace === true) {
                    for ($i = $indexPiece; $i <= $indexLastPiece; ++$i) {
                        $position = $textPieces[$i][1];
                        if (($positionSpace = strpos($textPieces[$i][0], ' ')) !== false) {
                            $position += $positionSpace;
                            break;
                        }
                    }
                }

                $text = substr($text, 0, $position);
                preg_match_all($htmlMatchMask, $text, $return, PREG_OFFSET_CAPTURE);
                $tagPieces = array();

                foreach ($return[0] as $index => $tag) {
                    if (isset($return[3][$index][0])) {
                        continue;
                    }
                    if ($return[0][$index][0][1] != '/') {
                        array_unshift($tagPieces, $return[2][$index][0]);
                    } else {
                        array_shift($tagPieces);
                    }
                }

                if (!empty($tagPieces)) {
                    foreach ($tagPieces as $tag) {
                        $text .= '</'.$tag.'>';
                    }
                }

                if ($readMoreText != '' && $lengthBeforeWithoutHtml > $nbCaracter) {
                    $text   .= 'SuspensionPoint';
                    $pattern = '#((</[^>]*>[\n\t\r ]*)?(</[^>]*>[\n\t\r ]*)?(</[^>]*>[\n\t\r ]*)?(</[^>]*>[\n\t\r ]*)?(</[^>]*>)[\n\t\r ]*SuspensionPoint)#i';
                    $text = preg_replace($pattern, $readMoreText.'${2}${3}${4}${5}${6}', $text);
                }
            }
        }

        return $text;
    }