初期化

@param string $keyword_file

@throws PhpSourceParserException
514119
public function init( $keyword_file )
    {
        // キーワードファイルの読み込み
        $keywords = array();
        $fp = fopen( $keyword_file, 'r' );
        if ( !$fp ) {
            throw new PhpSourceParserException( self::ERROR_FILENOTFOUND, "Keyword file not found:$keyword_file" );
        }
        while ( !feof($fp) ) {
            $buffer = fgets( $fp, 4096 );
            $keyword = trim($buffer);
            $keywords[$keyword] = 1;
        }
        fclose( $fp );
        $this->_keywords = $keywords;
    }
899629
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens    = $phpcsFile->getTokens();
        $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);

        if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS)
        {
            $error = '"%s" is a statement not a function; no parentheses are required';
            $data  = [$tokens[$stackPtr]['content']];
            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'BracketsNotRequired', $data);

            if ($fix === true)
            {
                $end      = $phpcsFile->findEndOfStatement($nextToken);
                $ignore   = PHP_CodeSniffer_Tokens::$emptyTokens;
                $ignore[] = T_SEMICOLON;
                $closer   = $phpcsFile->findPrevious($ignore, ($end - 1), null, true);

                $phpcsFile->fixer->beginChangeset();
                $phpcsFile->fixer->replaceToken($nextToken, '');

                if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE)
                {
                    $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
                }

                if ($tokens[$closer]['code'] === T_CLOSE_PARENTHESIS)
                {
                    $phpcsFile->fixer->replaceToken($closer, '');
                }

                $phpcsFile->fixer->addContent($stackPtr, ' ');
                $phpcsFile->fixer->endChangeset();
            }
        }
    }
1077896
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
	{
		$tokens    = $phpcsFile->getTokens();
		$nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);

		if ($tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS && $tokens[($stackPtr)]['code'] !== T_ECHO)
		{
			$error = '"%s" is a statement not a function; no parentheses are required';
			$data  = array($tokens[$stackPtr]['content']);
			$fix   = $phpcsFile->addFixableError($error, $stackPtr, 'BracketsNotRequired', $data);

			if ($fix === true)
			{
				$end      = $phpcsFile->findEndOfStatement($nextToken);
				$ignore   = PHP_CodeSniffer_Tokens::$emptyTokens;
				$ignore[] = T_SEMICOLON;
				$closer   = $phpcsFile->findPrevious($ignore, ($end - 1), null, true);

				$phpcsFile->fixer->beginChangeset();
				$phpcsFile->fixer->replaceToken($nextToken, '');

				if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE)
				{
					$phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
				}

				if ($tokens[$closer]['code'] === T_CLOSE_PARENTHESIS)
				{
					$phpcsFile->fixer->replaceToken($closer, '');
				}

				$phpcsFile->fixer->addContent($stackPtr, ' ');
				$phpcsFile->fixer->endChangeset();
			}
		}

		if ($tokens[($stackPtr)]['code'] === T_ECHO
			&& $tokens[$nextToken]['code'] === T_OPEN_PARENTHESIS
			&& $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE
		)
		{
			$error = 'There must be one space between the "%s" statement and the opening parenthesis';
			$data  = array($tokens[$stackPtr]['content']);
			$fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterEcho', $data);

			if ($fix === true)
			{
				$this->requiredSpacesBeforeOpen = 1;
				$padding = str_repeat(' ', $this->requiredSpacesBeforeOpen);
				$phpcsFile->fixer->addContent($stackPtr, $padding);
			}
		}
	}
602320
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $arrayStart = DWS_Helpers_Bracket::bracketStart($phpcsFile, $stackPtr);
        $arrayEnd = DWS_Helpers_Bracket::bracketEnd($phpcsFile, $stackPtr);

        if (!in_array($arrayStart, [$stackPtr, $stackPtr + 1])) {
            $phpcsFile->addError('No whitespace allowed between the array keyword and the opening parenthesis', $stackPtr, 'SpaceAfterKeyword');
        }

        $firstMember = $phpcsFile->findNext(T_WHITESPACE, $arrayStart + 1, $arrayEnd, true);
        if ($firstMember === false && $arrayEnd - $arrayStart !== 1) {
            $phpcsFile->addError('Empty array declaration must have no space between the brackets', $stackPtr, 'SpaceInEmptyArray');
        }
    }
535090
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
	{
		$tokens     = $phpcsFile->getTokens();
		$singleLine = false;
		$comment    = trim($tokens[$stackPtr]['content']);

		// Hash comments are not allowed.
		if ($tokens[$stackPtr]['content']{0} === '#')
		{
			$phpcsFile->recordMetric($stackPtr, 'Inline comment style', '# ...');

			$error  = 'Perl-style Hash comments are prohibited. Use "// Comment."';
			$error .= ' or "/* comment */" instead.';
			$fix    = $phpcsFile->addFixableError($error, $stackPtr, 'WrongStyle');

			if ($fix === true)
			{
				$newComment = ltrim($tokens[$stackPtr]['content'], '# ');
				$newComment = '// ' . $newComment;
				$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
			}
		}
		elseif ($tokens[$stackPtr]['content']{0} === '/' && $tokens[$stackPtr]['content']{1} === '/')
		{
			$phpcsFile->recordMetric($stackPtr, 'Inline comment style', '// ...');
			$singleLine = true;
		}
		elseif ($tokens[$stackPtr]['content']{0} === '/' && $tokens[$stackPtr]['content']{1} === '*')
		{
			$phpcsFile->recordMetric($stackPtr, 'Inline comment style', '/* ... */');
		}

		// Always have a space between // and the start of the comment text.
		// The exception to this is if the preceding line consists of a single open bracket.
		if ($tokens[$stackPtr]['content']{0} === '/' && $tokens[$stackPtr]['content']{1} === '/' && isset($tokens[$stackPtr]['content']{2})
			&& $tokens[$stackPtr]['content']{2} !== ' ' && isset($tokens[($stackPtr - 1)]['content']{0})
			&& $tokens[($stackPtr - 1)]['content']{0} !== '}'
		)
		{
			$error = 'Missing space between the // and the start of the comment text.';
			$fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpace');

			if ($fix === true)
			{
				$newComment = ltrim($tokens[$stackPtr]['content'], '\//');
				$newComment = '// ' . $newComment;

				$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
			}
		}

		/*
		 * New lines should always start with an upper case letter, unless
		 * the line is a continuation of a complete sentence,
		 * the term is code and is case sensitive.(@todo)
		 */
		if (($singleLine === true && isset($tokens[$stackPtr]['content']{3}) && $tokens[$stackPtr]['content']{2} === ' '
			&& $tokens[$stackPtr]['content']{3} !== strtoupper($tokens[$stackPtr]['content']{3})) || (isset($comment{2}) && $comment{0} === '*'
			&& $comment{1} === ' ' && $comment{2} !== strtoupper($comment{2}))
		)
		{
			$error = 'Comment must start with a capital letter; found "%s"';
			$previous = $phpcsFile->findPrevious(T_COMMENT, $stackPtr - 1);

			if ($singleLine === true)
			{
				$data       = array($comment{3});
				$newComment = ltrim($tokens[$stackPtr]['content'], '\// ');
				$newComment = '// ' . ucfirst($newComment);
			}
			else
			{
				$data       = array($comment{2});
				$padding    = (strlen($tokens[$stackPtr]['content']) - strlen($comment));
				$padding    = str_repeat("\t", $padding - 2);
				$newComment = ltrim($comment, '* ');
				$newComment = $padding . ' * ' . ucfirst($newComment) . $phpcsFile->eolChar;
			}

			// Check for a comment on the previous line.
			if ($tokens[$previous]['line'] === $tokens[$stackPtr]['line'] - 1 && '/*' !== substr(ltrim($tokens[$previous]['content']), 0, 2))
			{
				$test = trim($tokens[$previous]['content']);

				if ('.' === $test{(strlen($test) - 1)})
				{
					$fix = $phpcsFile->addFixableError($error, $stackPtr, 'LowerCaseAfterSentenceEnd', $data);

					if ($fix === true)
					{
						$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
					}
				}
			}
			else
			{
				$fix = $phpcsFile->addFixableError($error, $stackPtr, 'LowerCaseStart', $data);

				if ($fix === true)
				{
					$phpcsFile->fixer->replaceToken($stackPtr, $newComment);
				}
			}
		}

		/*
		 * Comments should not be on the same line as the code to which they refer
		 * (which puts them after the code they reference).
		 * They should be on their own lines.
		 * @todo Add fixer
		 */
		$previous = $phpcsFile->findPrevious(T_SEMICOLON, $stackPtr);

		if (isset($tokens[$previous]['line']) && $tokens[$previous]['line'] === $tokens[$stackPtr]['line'])
		{
			$error = 'Please put your comment on a separate line *preceding* your code; found "%s"';
			$data = array($comment);
			$phpcsFile->addError($error, $stackPtr, 'SameLine', $data);
		}

		/*
		 * Always have a single blank line before a comment or block of comments.
		 * Don't allow preceding "code" - identified by a semicolon ;)
		 */
		if (isset($tokens[$previous]['line']) && $tokens[$previous]['line'] === $tokens[$stackPtr]['line'] - 1
			&& $tokens[($stackPtr - 1)]['content'] !== '}'
		)
		{
			$error = 'Please consider a blank line preceding your comment.';
			$fix = $phpcsFile->addFixableError($error, $stackPtr, 'BlankBefore');

			if ($fix === true)
			{
				$phpcsFile->fixer->addContent(($previous + 1), $phpcsFile->eolChar);
			}
		}

		/*
		 * Comment blocks that introduce large sections of code and are more than 2 lines long
		 * should use /* * / and should use * on each line with the same space/tab rules as doc
		 * blocks.
		 * If you need a large introduction consider whether this block should be separated into a
		 * method to reduce complexity and therefore providing a full docblock.
		 */
		$next = $phpcsFile->findNext(T_COMMENT, $stackPtr + 1);

		if ($singleLine === true && isset($tokens[$next]['line']) && $tokens[$next]['line'] === $tokens[$stackPtr]['line'] + 1
			&& $tokens[($stackPtr - 1)]['content'] !== '}'
		)
		{
			// The following line contains also a comment.
			$nextNext = $phpcsFile->findNext(T_COMMENT, $next + 1);

			if ($tokens[$nextNext]['line'] === $tokens[$next]['line'] + 1)
			{
				// Found 3 lines of // comments - too much.
				$error = 'Use the /* */ style for comments that span over multiple lines.';
				$phpcsFile->addError($error, $stackPtr, 'MultiLine');
			}
		}
	}
518384
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('5.4')) {
            $tokens = $phpcsFile->getTokens();
            $nextSemicolonToken = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr), null, false);
            for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
                $gotError = false;
                if ($tokens[$curToken]['type'] == 'T_STRING') {
                    // If the next non-whitespace token after the string
                    // is an opening parenthesis then it's a function call.
                    $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $curToken + 1, null, true);
                    if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
                        continue;
                    } else {
                        $gotError = true;
                    }
                }
                switch ($tokens[$curToken]['type']) {
                    case 'T_VARIABLE':
                    case 'T_FUNCTION':
                        $gotError = true;
                        break;
                }
                if ($gotError === true) {
                    $error = 'Using a variable argument on break or continue is forbidden since PHP 5.4';
                    $phpcsFile->addError($error, $stackPtr);
                }
            }
        }
    }
134844
public void consumeExpectedKeyword(String keyword) {
        if (current().matches(Token.TokenType.KEYWORD, keyword)) {
            consume();
        } else {
            addError(current(), "Unexpected token: '%s'. Expected: '%s'", current().getSource(), keyword);
        }
    }
557215
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $bracketStart = DWS_Helpers_Bracket::bracketStart($phpcsFile, $stackPtr);
        $bracketEnd = DWS_Helpers_Bracket::bracketEnd($phpcsFile, $stackPtr);

        if ($tokens[$bracketStart]['line'] === $tokens[$bracketEnd]['line']) {
            return; // Single-line expressions don't have indentation to worry about.
        }

        $beginningIndent = DWS_Helpers_WhiteSpace::indentOfLine($phpcsFile, $bracketStart);

        if ($tokens[$bracketEnd]['column'] !== $beginningIndent) {
            $data = [$beginningIndent - 1, $tokens[$bracketEnd]['column'] - 1, $tokens[$bracketEnd]['content']];
            $phpcsFile->addError('Expected indentation of %s spaces, %s found for ending bracket "%s"', $bracketEnd, 'EndIndent', $data);
        }

        $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $bracketStart + 1, $bracketEnd, true);
        if ($nextToken !== false && $tokens[$nextToken]['line'] === $tokens[$bracketStart]['line']) {
            $data = [$tokens[$bracketStart]['content']];
            $phpcsFile->addError('Expected first item after opening "%s" to be indented on a new line', $nextToken, 'OpeningIndent', $data);
        }

        $firstOnLine = $bracketStart + 1;
        for ($line = $tokens[$bracketStart]['line'] + 1; $line < $tokens[$bracketEnd]['line']; $line++) {
            while ($tokens[$firstOnLine]['line'] < $line || in_array($tokens[$firstOnLine]['code'], PHP_CodeSniffer_Tokens::$emptyTokens)) {
                if (array_key_exists('parenthesis_closer', $tokens[$firstOnLine])) {
                    $firstOnLine = $tokens[$firstOnLine]['parenthesis_closer'] + 1;
                    $line = $tokens[$firstOnLine]['line'];
                    continue 2;
                } elseif (array_key_exists('bracket_closer', $tokens[$firstOnLine])) {
                    $firstOnLine = $tokens[$firstOnLine]['bracket_closer'] + 1;
                    $line = $tokens[$firstOnLine]['line'];
                    continue 2;
                }

                $firstOnLine++;
            }

            if ($tokens[$firstOnLine]['line'] === $line && $tokens[$firstOnLine]['column'] !== $beginningIndent + 4) {
                $data = [$beginningIndent + 3, $tokens[$firstOnLine]['column'] - 1];
                $phpcsFile->addError('Expected indentation of %s spaces, %s found', $firstOnLine, 'MultiLineIndent', $data);
            }
        }
    }
1071727
function keyword_add($keyword, $usr_id = 0) {
        $usr_id = $usr_id ? $usr_id : Me::id();
        $keyword = $this->keyword_prepare($keyword);
        $len = mb_strlen($keyword);
        if ($len > 0 && $len < 31) {
            $kwd = ORM::factory('Meerkat_Keyword')->get_or_create(
                    array(
                        'value' => $keyword
                    )
            );
            $ret[] = $keyword;
            ORM::factory('Meerkat_Object_Keyword')->get_or_create(array(
                'keyword_id' => $kwd->pk(),
                'usr_id' => $usr_id,
                'meerkat_id' => $this->pk(),
            ));
        } else {
            return false;
        }
        return $kwd->value;
    }
1144128
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('5.5')) {
            $tokens = $phpcsFile->getTokens();

            if ($tokens[$stackPtr]['content'] == "preg_replace") {
                $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true);

                if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
                    return;
                }

                $firstParam = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($openBracket + 1), null, true);

                /**
                 * If argument is not a string, then skip test (e.g. if variable passed in).
                 */
                if ($tokens[$firstParam]['code'] !== T_CONSTANT_ENCAPSED_STRING) {
                    return;
                }

                /**
                 * Regex is a T_CONSTANT_ENCAPSED_STRING, so we need to remove the quotes
                 */
                $regex = "";
                while (isset($tokens[$firstParam]) && $tokens[$firstParam]['code'] != T_COMMA) {
                    if ($tokens[$firstParam]['code'] == T_CONSTANT_ENCAPSED_STRING) {
                        $regex .= $tokens[$firstParam]['content'];
                    }
                    $firstParam++;
                }

                $regex = substr($regex, 1, -1);

                $regexFirstChar = substr($regex, 0, 1);
                $regexEndPos = strrpos($regex, $regexFirstChar);

                $modifiers = substr($regex, $regexEndPos + 1);

                if (strpos($modifiers, "e") !== false) {
                    $error = 'preg_replace() - /e modifier is deprecated in PHP 5.5';
                    $phpcsFile->addError($error, $stackPtr);
                }
            }
        }


    }
1262604
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        if ($this->supportsAbove('5.3')) {
            $tokens = $phpcsFile->getTokens();

            // Find all the functions in this class or interface

            // Use the scope closer to limit the sniffing within the scope of
            // this class or interface
            $classScopeCloser = (isset($tokens[$stackPtr]['scope_closer']))
                ? $tokens[$stackPtr]['scope_closer']
                : $stackPtr + 1;

            $functionPtr = $stackPtr;

            while ($functionToken = $phpcsFile->findNext(T_FUNCTION, $functionPtr, $classScopeCloser)) {

                // Get the scope closer for this function in order to know how
                // to advance to the next function.
                // If no body of function (e.g. for interfaces), there is
                // no closing curly brace; advance the pointer differently
                $scopeCloser = isset($tokens[$functionToken]['scope_closer'])
                    ? $tokens[$functionToken]['scope_closer']
                    : $functionToken + 1;

                $scopeToken = false;
                $staticToken = false;

                $nameToken = $phpcsFile->findNext(T_WHITESPACE, $functionToken + 1, $classScopeCloser, true);
                if (in_array($tokens[$nameToken]['content'], $this->magicMethods) === false) {
                    $functionPtr = $scopeCloser;
                    continue;
                }

                // What is the token before the function token?
                $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, $functionToken - 1, null, true);
                if (in_array($tokens[$prevToken]['code'], array(T_PUBLIC, T_PROTECTED, T_PRIVATE))) {
                    $scopeToken = $prevToken;
                } elseif ($tokens[$prevToken]['code'] == T_STATIC) {
                    $staticToken = $prevToken;
                } else {
                    // no scope or static modifiers, this function is okay
                    $functionPtr = $scopeCloser;
                    continue;
                }

                // What is the token before that one?
                $prevPrevToken = $phpcsFile->findPrevious(T_WHITESPACE, $prevToken - 1, null, true);
                if (in_array($tokens[$prevPrevToken]['code'], array(T_PUBLIC, T_PROTECTED, T_PRIVATE))) {
                    $scopeToken = $prevPrevToken;
                } elseif ($tokens[$prevPrevToken]['code'] == T_STATIC) {
                    $staticToken = $prevPrevToken;
                }

                $isPublic = ($scopeToken !== false && $tokens[$scopeToken]['type'] != 'T_PUBLIC') ? false : true;
                $isStatic = ($staticToken === false) ? false : true;

                if ($isPublic && !$isStatic) {
                    $functionPtr = $scopeCloser;
                    continue;
                }

                // Summarize what the problems are
                if (!$isPublic && $isStatic) {
                    $error = sprintf(
                        "Magic methods must be public and cannot be static (since PHP 5.3)! Found static %s function %s",
                        $tokens[$scopeToken]['content'],
                        $tokens[$nameToken]['content']
                    );
                    $phpcsFile->addError($error, $functionToken);
                } else {
                    if (!$isPublic) {
                        $error = sprintf(
                            "Magic methods must be public (since PHP 5.3)! Found %s function %s",
                            $tokens[$scopeToken]['content'],
                            $tokens[$nameToken]['content']
                        );
                        $phpcsFile->addError($error, $functionToken);
                    }

                    if ($isStatic) {
                        $error = sprintf(
                            "Magic methods cannot be static (since PHP 5.3)! Found static function %s",
                            $tokens[$nameToken]['content']
                        );
                        $phpcsFile->addError($error, $functionToken);
                    }
                }

                // Advance to next function
                $functionPtr = $scopeCloser;
            }
        }

    }
1372768
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        // We are only interested in the first token in a multi-line string.
        if ($tokens[$stackPtr]['code'] === $tokens[$stackPtr - 1]['code']) {
            return;
        }

        $workingString = $tokens[$stackPtr]['content'];
        for ($i = $stackPtr + 1; $tokens[$i]['code'] === $tokens[$stackPtr]['code']; ++$i) {
            $workingString .= $tokens[$i]['content'];
        }

        // Check if it's a double quoted string.
        if (strpos($workingString, '"') === false) {
            return;
        }

        $allowedStrings = ['\0', '\n', '\r', '\f', '\t', '\v', '\x', '\''];

        foreach ($allowedStrings as $testChar) {
            if (strpos($workingString, $testChar) !== false) {
                return;
            }
        }

        $phpcsFile->addError("String {$workingString} does not require double quotes; use single quotes instead", $stackPtr, 'NotRequired');
    }
1067244
public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $ignore = array(T_PUBLIC, T_PRIVATE, T_PROTECTED, T_VAR, T_STATIC, T_WHITESPACE);
        $commentEnd = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
        if ($commentEnd === false
            || ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
            && $tokens[$commentEnd]['code'] !== T_COMMENT)
        ) {
            $phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing');
            return;
        }

        if ($tokens[$commentEnd]['code'] === T_COMMENT) {
            $phpcsFile->addError('You must use "/**" style comments for a member variable comment', $stackPtr, 'WrongStyle');
            return;
        }

        $commentStart = $tokens[$commentEnd]['comment_opener'];

        $foundVar = null;
        foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
            if ($tokens[$tag]['content'] === '@var') {
                if ($foundVar !== null) {
                    $error = 'Only one @var tag is allowed in a member variable comment';
                    $phpcsFile->addError($error, $tag, 'DuplicateVar');
                } else {
                    $foundVar = $tag;
                }
            } else if ($tokens[$tag]['content'] === '@see') {
                // Make sure the tag isn't empty.
                $string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd);
                if ($string === false || $tokens[$string]['line'] !== $tokens[$tag]['line']) {
                    $error = 'Content missing for @see tag in member variable comment';
                    $phpcsFile->addError($error, $tag, 'EmptySees');
                }
            } else {
                $error = '%s tag is not allowed in member variable comment';
                $data  = array($tokens[$tag]['content']);
                $phpcsFile->addWarning($error, $tag, 'TagNotAllowed', $data);
            }
        }

        // The @var tag is the only one we require.
        if ($foundVar === null) {
            $error = 'Missing @var tag in member variable comment';
            $phpcsFile->addError($error, $commentEnd, 'MissingVar');
            return;
        }

        $firstTag = $tokens[$commentStart]['comment_tags'][0];
        if ($foundVar !== null && $tokens[$firstTag]['content'] !== '@var') {
            $error = 'The @var tag must be the first tag in a member variable comment';
            $phpcsFile->addError($error, $foundVar, 'VarOrder');
        }

        // Make sure the tag isn't empty and has the correct padding.
        $string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $foundVar, $commentEnd);
        if ($string === false || $tokens[$string]['line'] !== $tokens[$foundVar]['line']) {
            $error = 'Content missing for @var tag in member variable comment';
            $phpcsFile->addError($error, $foundVar, 'EmptyVar');
            return;
        }
    }
460954
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $isString = false;

        // For string tokens we only care if the string is a reserved word used
        // as a function. This only happens in older versions of PHP where the
        // token doesn't exist yet for that keyword.
        if ($tokens[$stackPtr]['code'] == T_STRING
            && (!in_array($tokens[$stackPtr]['content'], array_keys($this->targetedStringTokens)))
        ) {
            return;
        }

        if ($tokens[$stackPtr]['code'] == T_STRING) {
            $isString = true;
        }

        // Make sure this is a function call.
        $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
        if ($next === false) {
            // Not a function call.
            return;
        }

        if ($tokens[$next]['code'] == T_OPEN_PARENTHESIS) {
            $prev = $phpcsFile->findPrevious(array(T_WHITESPACE, T_COMMENT), ($stackPtr - 1), null, true);

            // This sniff isn't concerned about function declaration
            if ($tokens[$prev]['code'] == T_FUNCTION) {
                return;
            }

            // For the word catch, it is valid to have an open parenthesis
            // after it, but only if it is preceded by a right curly brace
            if ($tokens[$stackPtr]['code'] == T_CATCH) {
                if ($prev !== false) {
                    if ($tokens[$prev]['code'] == T_CLOSE_CURLY_BRACKET) {
                        // Ok, it's fine
                        return;
                    }
                }
            }

            $content = $tokens[$stackPtr]['content'];
            $tokenCode = $tokens[$stackPtr]['code'];
            if ($isString) {
                $version = $this->targetedStringTokens[$content];
            } else {
                $version = $this->targetedTokens[$tokenCode];
            }

            if ($this->supportsAbove($version)) {
                $error = sprintf(
                    "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)",
                    $content,
                    $version,
                    $tokens[$stackPtr]['type']
                );
                $phpcsFile->addError($error, $stackPtr);
            }
        }
    }
1263266
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
	{
		$tokens = $phpcsFile->getTokens();
		$className = $phpcsFile->findNext(T_STRING, $stackPtr);
		$name      = trim($tokens[$className]['content']);
		$errorData = array(ucfirst($tokens[$stackPtr]['content']));
		$classProperties = $phpcsFile->getClassProperties($stackPtr);

		$startsWithAbstract = substr($name, 0, 8) == 'Abstract';

		if ($classProperties['is_abstract'] && !$startsWithAbstract) {
			$error = '%s name must begin with "Abstract"';
			$phpcsFile->addError($error, $stackPtr, 'StartWithAbstract', $errorData);
		}

		if (!$classProperties['is_abstract'] && $startsWithAbstract) {
			$error = '%s name must not begin with "Abstract"';
			$phpcsFile->addError($error, $stackPtr, 'StartNotWithAbstract', $errorData);
		}
	}
916552
public function parse($param_str) {
        $file = new File(trim($param_str), $this->getScope()->getFile()->getAbsoluteFile()->getParent());
        if (!$file->exists()) {
            throw new ResourceNotFoundException($param_str, $this->getScope(), $this->getOccursPos(), "The Requirement File Not Exists");
        }
        if (is_null($require_resource = $this->getParentProject()->getResourceByFile($file))) {
            throw new \Chigi\Chiji\Exception\ProjectMemberNotFoundException("ERROR: UNREGISTERED Resource File: " + $file->getAbsolutePath());
        }
        if ($this->getScope() instanceof RequiresMapInterface) {
            $this->getScope()->getRequires()->addResource($require_resource);
        }
    }
145362
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {

        $this->currentFile = $phpcsFile;

        $tokens = $phpcsFile->getTokens();
        $type = strtolower($tokens[$stackPtr]['content']);
        $errorData = array($type);
        $find = array(T_ABSTRACT, T_WHITESPACE, T_FINAL,);

        // Extract the class comment docblock.
        $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);

        if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) {
            $error = 'You must use "/**" style comments for a %s comment';
            $phpcsFile->addError($error, $stackPtr, 'WrongStyle', $errorData);
            return;
        } else if ($commentEnd === false || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT) {
            $phpcsFile->addError('Missing %s doc comment', $stackPtr, 'Missing', $errorData);
            return;
        }

        $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1);
        $commentNext = $phpcsFile->findPrevious(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar);

        // Distinguish file and class comment.
        $prevClassToken = $phpcsFile->findPrevious(T_CLASS, ($stackPtr - 1));
        if ($prevClassToken === false) {
            // This is the first class token in this file, need extra checks.
            $prevNonComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($commentStart - 1), null, true);
            if ($prevNonComment !== false) {
                $prevComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($prevNonComment - 1));
                if ($prevComment === false) {
                    // There is only 1 doc comment between open tag and class token.
                    $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false,
                        $phpcsFile->eolChar);
                    if ($newlineToken !== false) {
                        $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($newlineToken + 1), $stackPtr, false,
                            $phpcsFile->eolChar);

                        if ($newlineToken !== false) {
                            // Blank line between the class and the doc block.
                            // The doc block is most likely a file comment.
                            $error = 'Missing %s doc comment';
                            $phpcsFile->addError($error, ($stackPtr + 1), 'Missing', $errorData);
                            return;
                        }
                    }//end if
                }//end if
            }//end if
        }//end if

        $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1));

        // Parse the class comment.docblock.
        try {
            $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile);
            $this->commentParser->parse();
        } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
            $line = ($e->getLineWithinComment() + $commentStart);
            $phpcsFile->addError($e->getMessage(), $line, 'FailedParse');
            return;
        }

        $comment = $this->commentParser->getComment();
        if (is_null($comment) === true) {
            $error = 'Doc comment is empty for %s';
            $phpcsFile->addError($error, $commentStart, 'Empty', $errorData);
            return;
        }

        // No extra newline before short description.
        $short = $comment->getShortComment();
        $newlineCount = 0;
        $newlineSpan = strspn($short, $phpcsFile->eolChar);
        if ($short !== '' && $newlineSpan > 0) {
            $error = 'Extra newline(s) found before %s comment short description';
            $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort', $errorData);
        }

        $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1);

        // Exactly one blank line between short and long description.
        $long = $comment->getLongComment();
        if (empty($long) === false) {
            $between = $comment->getWhiteSpaceBetween();
            $newlineBetween = substr_count($between, $phpcsFile->eolChar);
            if ($newlineBetween !== 2) {
                $error = 'There must be exactly one blank line between descriptions in %s comments';
                $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingAfterShort', $errorData);
            }

            $newlineCount += $newlineBetween;
        }

        // Exactly one blank line before tags.
        $tags = $this->commentParser->getTagOrders();
        if (count($tags) > 1) {
            $newlineSpan = $comment->getNewlineAfter();
            if ($newlineSpan !== 2) {
                $error = 'There must be exactly one blank line before the tags in %s comments';
                if ($long !== '') {
                    $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1);
                }

                $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags', $errorData);
                $short = rtrim($short, $phpcsFile->eolChar . ' ');
            }
        }

        // Check each tag.
        $this->processTags($commentStart, $commentEnd);

    }