Skips whitespaces and comments next to the current position.

@param  boolean $skipComment Skip docblocks as well.
@return string               The skipped string.
502488
public function skipWhitespaces($skipComment = false)
    {
        $skips = [T_WHITESPACE => true];

        if (!$skipComment) {
            $skips += [T_COMMENT => true, T_DOC_COMMENT => true];
        }

        $this->_current++;
        return $this->_skip($skips);
    }
579560
public static function cleanComment($comment, $glueSeparator = ',', $uniqueValues = true)
    {
        if (!is_scalar($comment) && !is_array($comment)) {
            return '';
        }
        return trim(str_replace('*/', '*[:slash:]', is_scalar($comment) ? $comment : implode($glueSeparator, $uniqueValues ? array_unique($comment) : $comment)));
    }
225592
def _skip_spaces_and_peek(self):
        
        while 1:
            # skipping spaces
            self.skip_chars(self.end, lambda x: x in self.spaces)
            c = self.peek()
            if not self.params.allow_comments:
                return c
            if c != '/':
                return c
            d = self.peek(1)
            if d == '/':
                self.skip_to(self.pos + 2)
                self._skip_singleline_comment()
            elif d == '*':
                self.skip_to(self.pos + 2)
                self._skip_multiline_comment()
            else:
                return c
108972
protected function multipleLineComment()
    {
        $this->get();
        $comment = '';
        while (true) {
            $get = $this->get();
            if ($get === '*') {
                if ($this->peek() === '/') {
                    $this->get();
                    if (strpos($comment, '!') === 0) {
                        return "\n/*!".substr($comment, 1)."*/\n";
                    }
                    if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
                        return '/*'.$comment.'*/';
                    }
                    return ' ';
                }
            } elseif ($get === null) {
                throw new \Exception('Unterminated comment at byte: '.$this->inputIndex.': /*'.$comment);
            }
            $comment .= $get;
        }
        return;
    }
1112197
public function getComment()
    {
        if ($this->comment === null) {
            $match = [];
            preg_match(self::$REGEX_COMMENT, $this->output, $match);
            $this->comment = array_key_exists(2, $match) ? trim($match[2]) : '';
        }

        return $this->comment;
    }
1118384
public function uncomment($comment = '#')
    {
        $commentLength = strlen($comment);
        foreach( $this->lines as &$line ) {
            if( 0 === strpos($line, $comment) ) {
                $line = substr( $line, $commentLength );
            }
        }
        return $this;
    }
311561
protected function getComment($asPhpComment = true)
    {
        $comment = $this->parameters->get('comment');
        // strip hints for mysql-exporter in comments (starting with {d:keyword}
        // or {doctrine:keyword} and ending with {/d:keyword}
        if ($comment = trim(preg_replace(sprintf('/\{(%s):([^\}]+)\}(.+?)\{\/\1:\2\}/si', $this->getFormatter()->getCommentTagPrefix()), '', $comment))) {
            if ($asPhpComment) {
                $comment = implode("\n", Comment::wrap($comment."\n", ' * %s'));
            }

            return $comment;
        }
    }
639518
protected function scanComment()
    {
        if (preg_match('/^ *\/\/(-)?([^\n]*)/', $this->input, $matches)) {
            $this->consume($matches[0]);
            $token         = $this->token('comment', isset($matches[2]) ? $matches[2] : '');
            $token->buffer = '-' !== $matches[1];

            return $token;
        }
    }
57109
protected function parseBlockCommentTags(array &$blockCommentLines)
    {
        $tags = array();
        $currentTagName = $currentTagContent = null;
        foreach ($blockCommentLines as $index => $blockCommentLine) {
            $isTagLine = preg_match(
                '~^@(\w+)(?:\s+(.*))?\s*$~',
                $blockCommentLine,
                $matches
            );
            $isEmptyLine = '' === trim($blockCommentLine);

            if (
                ($isTagLine || $isEmptyLine) &&
                null !== $currentTagName
            ) {
                if ('' === $currentTagContent) {
                    $currentTagContent = null;
                }
                $tags[] = new Element\DocumentationTag(
                    $currentTagName,
                    $currentTagContent
                );

                $currentTagName = $currentTagContent = null;
            }

            if ($isTagLine) {
                $currentTagName = $matches[1];
                $currentTagContent = '';
                if (array_key_exists(2, $matches)) {
                    $currentTagContent = $matches[2];
                }
            } elseif (!$isEmptyLine) {
                $currentTagContent .= ' ' . ltrim($blockCommentLine);
            }

            if (null !== $currentTagName || count($tags) > 0) {
                unset($blockCommentLines[$index]);
            }
        }
        if (null !== $currentTagName) {
            if ('' === $currentTagContent) {
                $currentTagContent = null;
            }
            $tags[] = new Element\DocumentationTag(
                $currentTagName,
                $currentTagContent
            );
        }

        return $tags;
    }
930347
protected function processOneLineComments($startIndex)
	{
		$thirdCommentString = substr($this->input, $this->index, 1);

		// kill rest of line
		$this->getNext("\n");

		if ($thirdCommentString === '@')
		{
			$endPoint = $this->index - $startIndex;
			unset($this->c);
			$char = "\n" . substr($this->input, $startIndex, $endPoint);
		}
		else
		{
			// first one is contents of $this->c
			$this->getChar();
			$char = $this->getChar();
		}

		return $char;
	}
364103
def CleanComments(line, quote=False):
    
    if line.find('#') == -1 and line.find('"') == -1:
        if quote:
            return '', quote
        else:
            return line, quote
    # else have to check for comment
    prior = []
    prev = ''
    for char in line:
        try:
            if char == '"':
                if prev != '\\':
                    quote = not quote
                    prior.append(char)
                continue
            elif char == '#' and not quote:
                break
            if not quote:
                prior.append(char)
        finally:
            prev = char

    # rstrip removes trailing space between end of command and the comment # start

    return ''.join(prior).rstrip(), quote
805008
private final boolean skip_whitespace(CommentStrategy commentStrategy) throws IOException
    {
        boolean any_whitespace = false;
        int c;

        loop: for (;;) {
            c = read_char();
            switch (c) {
            case -1:
                break loop;
            case ' ':
            case '\t':
            // new line normalization and counting is handled in read_char
            case CharacterSequence.CHAR_SEQ_NEWLINE_SEQUENCE_1:
            case CharacterSequence.CHAR_SEQ_NEWLINE_SEQUENCE_2:
            case CharacterSequence.CHAR_SEQ_NEWLINE_SEQUENCE_3:
            case CharacterSequence.CHAR_SEQ_ESCAPED_NEWLINE_SEQUENCE_1:
            case CharacterSequence.CHAR_SEQ_ESCAPED_NEWLINE_SEQUENCE_2:
            case CharacterSequence.CHAR_SEQ_ESCAPED_NEWLINE_SEQUENCE_3:
                any_whitespace = true;
                break;
            case '/':
                if (!commentStrategy.onComment(this))
                {
                    break loop;
                }
                any_whitespace = true;
                break;
            default:
                break loop;
            }
        }
        unread_char(c);
        return any_whitespace;
    }
388728
public static function formatExampleComment($example)
    {
        // Remove possible code tag
        $example = self::stripCodeTags($example);

        if( preg_match('/(\n       )/', $example) ) {
            $example = preg_replace('/(\n       )/', "\n", $example);
        }
        elseif( preg_match('/(\n    )/', $example) ) {
            $example = preg_replace('/(\n    )/', "\n", $example);
        } else {
            $example = preg_replace('/(\n   )/', "\n", $example);
        }
        $type = '';

        // A very naive analysis of the programming language used in the comment
        if( strpos($example, '<?php') !== false ) {
            $type = 'php';
        }
        elseif( strpos($example, 'var ') !== false && strpos($example, '</') === false ) {
            $type = 'js';
        }

        return sprintf("```%s\n%s\n```", $type, trim($example));
    }
1099386
protected function skip($srcPath, $skipPath)
    {
        $len = strlen($srcPath);

        for ($i = 0; $i < $len; $i++) {
            if (!isset($skipPath[$i]) || $skipPath[$i] != $srcPath[$i]) {
                break;
            }
        }

        return substr($srcPath, $i);
    }
1163944
protected function skipWhitespace()
	{
		while (++$this->i < $this->cnt && $this->tokens[$this->i][0] === T_WHITESPACE);
	}
739664
protected function cleanInput($comment)
    {
        $comment = trim(
            preg_replace(
                '#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u',
                '$1',
                $comment
            )
        );

        // reg ex above is not able to remove */ from a single line docblock
        if (substr($comment, -2) == '*/') {
            $comment = trim(substr($comment, 0, -2));
        }

        // normalize strings
        $comment = str_replace(array("\r\n", "\r"), "\n", $comment);

        return $comment;
    }
48088
private static function getDocLinesFromComment($docComment) {
		if (strpos($docComment, "/**") === 0) {
			$docComment = substr($docComment, 3);
		}
		
		// Let's remove all the \r...
		$docComment = str_replace("\r", "", $docComment);
			
		$commentLines = explode("\n", $docComment);
		$commentLinesWithoutStars = array();
		
		// For each line, let's remove the first spaces, and the first *
		foreach ($commentLines as $commentLine) {
			$length = strlen($commentLine);
			for ($i=0; $i<$length; $i++) {
				if ($commentLine{$i} != ' ' && $commentLine{$i} != '*' && $commentLine{$i} != "\t") {
					break;
				}
			}
			$commentLinesWithoutStars[] = substr($commentLine, $i);
		}
		
		// Let's remove the trailing /:
		$lastComment = $commentLinesWithoutStars[count($commentLinesWithoutStars)-1];
		$commentLinesWithoutStars[count($commentLinesWithoutStars)-1] = substr($lastComment, 0, strlen($lastComment)-1);
		
		if ($commentLinesWithoutStars[count($commentLinesWithoutStars)-1] == "")
			array_pop($commentLinesWithoutStars);
			
		if (isset($commentLinesWithoutStars[0]) && $commentLinesWithoutStars[0] == "") {
			$commentLinesWithoutStars = array_slice($commentLinesWithoutStars, 1);
		}
		
		return $commentLinesWithoutStars;
	}