extensions/felixfbecker.php-intellisense-0.0.12/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php
/**
     * Processes the function tokens within the class.
     *
     * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
     * @param int                  $stackPtr  The position where the token was found.
     * @param int                  $currScope The current scope opener token.
     *
     * @return void
     */
Processes the function tokens within the class.
@param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
@param int                  $stackPtr  The position where the token was found.
@param int                  $currScope The current scope opener token.

@return void
Processes the function tokens within the class . @param PHP_CodeSniffer_File $phpcsFile The file where this token was found . @param int $stackPtr The position where the token was found . @param int $currScope The current scope opener token . @return void
protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
    {
        $previousThrow = $phpcsFile->findPrevious(T_THROW, ($stackPtr - 1), $currScope);
        if ($previousThrow !== false) {
            return;
        }
        $tokens = $phpcsFile->getTokens();
        $find   = Tokens::$methodPrefixes;
        $find[] = T_WHITESPACE;
        $commentEnd = $phpcsFile->findPrevious($find, ($currScope - 1), null, true);
        if ($tokens[$commentEnd]['code'] === T_COMMENT) {
            return;
        }
        if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
            && $tokens[$commentEnd]['code'] !== T_COMMENT
        ) {
            return;
        }
        $currScopeEnd = $tokens[$currScope]['scope_closer'];
        $throwTokens = array();
        $currPos     = $stackPtr;
        $foundThrows = false;
        while ($currPos < $currScopeEnd && $currPos !== false) {
            if ($phpcsFile->hasCondition($currPos, T_CLOSURE) === false) {
                $foundThrows = true;
                $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($currPos + 1), null, true);
                if ($tokens[$nextToken]['code'] === T_NEW) {
                    $currException = $phpcsFile->findNext(
                        array(
                         T_NS_SEPARATOR,
                         T_STRING,
                        ),
                        $currPos,
                        $currScopeEnd,
                        false,
                        null,
                        true
                    );
                    if ($currException !== false) {
                        $endException = $phpcsFile->findNext(
                            array(
                             T_NS_SEPARATOR,
                             T_STRING,
                            ),
                            ($currException + 1),
                            $currScopeEnd,
                            true,
                            null,
                            true
                        );
                        if ($endException === false) {
                            $throwTokens[] = $tokens[$currException]['content'];
                        } else {
                            $throwTokens[] = $phpcsFile->getTokensAsString($currException, ($endException - $currException));
                        }
                    }
                }
            }
            $currPos = $phpcsFile->findNext(T_THROW, ($currPos + 1), $currScopeEnd);
        }
        if ($foundThrows === false) {
            return;
        }
        $throwTokens = array_unique($throwTokens);
        $throwTags    = array();
        $commentStart = $tokens[$commentEnd]['comment_opener'];
        foreach ($tokens[$commentStart]['comment_tags'] as $tag) {
            if ($tokens[$tag]['content'] !== '@throws') {
                continue;
            }
            if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) {
                $exception = $tokens[($tag + 2)]['content'];
                $space     = strpos($exception, ' ');
                if ($space !== false) {
                    $exception = substr($exception, 0, $space);
                }
                $throwTags[$exception] = true;
            }
        }
        if (empty($throwTags) === true) {
            $error = 'Missing @throws tag in function comment';
            $phpcsFile->addError($error, $commentEnd, 'Missing');
            return;
        } else if (empty($throwTokens) === true) {
            return;
        }
        $tokenCount = count($throwTokens);
        $tagCount   = count($throwTags);
        if ($tokenCount !== $tagCount) {
            $error = 'Expected %s @throws tag(s) in function comment; %s found';
            $data  = array(
                      $tokenCount,
                      $tagCount,
                     );
            $phpcsFile->addError($error, $commentEnd, 'WrongNumber', $data);
            return;
        }
        foreach ($throwTokens as $throw) {
            if (isset($throwTags[$throw]) === false) {
                $error = 'Missing @throws tag for "%s" exception';
                $data  = array($throw);
                $phpcsFile->addError($error, $commentEnd, 'Missing', $data);
            }
        }
    }
protected function processTokenWithinScope ( File $ phpcsFile , $ stackPtr , $ currScope ) { $ previousThrow = $ phpcsFile -> findPrevious ( T_THROW , ( $ stackPtr - 1 ) , $ currScope ) ; if ( $ previousThrow !== false ) { return ; } $ tokens = $ phpcsFile -> getTokens ( ) ; $ find = Tokens :: $ methodPrefixes ; $ find [ ] = T_WHITESPACE ; $ commentEnd = $ phpcsFile -> findPrevious ( $ find , ( $ currScope - 1 ) , null , true ) ; if ( $ tokens [ $ commentEnd ] [ 'code' ] === T_COMMENT ) { return ; } if ( $ tokens [ $ commentEnd ] [ 'code' ] !== T_DOC_COMMENT_CLOSE_TAG && $ tokens [ $ commentEnd ] [ 'code' ] !== T_COMMENT ) { return ; } $ currScopeEnd = $ tokens [ $ currScope ] [ 'scope_closer' ] ; $ throwTokens = array ( ) ; $ currPos = $ stackPtr ; $ foundThrows = false ; while ( $ currPos < $ currScopeEnd && $ currPos !== false ) { if ( $ phpcsFile -> hasCondition ( $ currPos , T_CLOSURE ) === false ) { $ foundThrows = true ; $ nextToken = $ phpcsFile -> findNext ( T_WHITESPACE , ( $ currPos + 1 ) , null , true ) ; if ( $ tokens [ $ nextToken ] [ 'code' ] === T_NEW ) { $ currException = $ phpcsFile -> findNext ( array ( T_NS_SEPARATOR , T_STRING , ) , $ currPos , $ currScopeEnd , false , null , true ) ; if ( $ currException !== false ) { $ endException = $ phpcsFile -> findNext ( array ( T_NS_SEPARATOR , T_STRING , ) , ( $ currException + 1 ) , $ currScopeEnd , true , null , true ) ; if ( $ endException === false ) { $ throwTokens [ ] = $ tokens [ $ currException ] [ 'content' ] ; } else { $ throwTokens [ ] = $ phpcsFile -> getTokensAsString ( $ currException , ( $ endException - $ currException ) ) ; } } } } $ currPos = $ phpcsFile -> findNext ( T_THROW , ( $ currPos + 1 ) , $ currScopeEnd ) ; } if ( $ foundThrows === false ) { return ; } $ throwTokens = array_unique ( $ throwTokens ) ; $ throwTags = array ( ) ; $ commentStart = $ tokens [ $ commentEnd ] [ 'comment_opener' ] ; foreach ( $ tokens [ $ commentStart ] [ 'comment_tags' ] as $ tag ) { if ( $ tokens [ $ tag ] [ 'content' ] !== '@throws' ) { continue ; } if ( $ tokens [ ( $ tag + 2 ) ] [ 'code' ] === T_DOC_COMMENT_STRING ) { $ exception = $ tokens [ ( $ tag + 2 ) ] [ 'content' ] ; $ space = strpos ( $ exception , ' ' ) ; if ( $ space !== false ) { $ exception = substr ( $ exception , 0 , $ space ) ; } $ throwTags [ $ exception ] = true ; } } if ( empty ( $ throwTags ) === true ) { $ error = 'Missing @throws tag in function comment' ; $ phpcsFile -> addError ( $ error , $ commentEnd , 'Missing' ) ; return ; } else if ( empty ( $ throwTokens ) === true ) { return ; } $ tokenCount = count ( $ throwTokens ) ; $ tagCount = count ( $ throwTags ) ; if ( $ tokenCount !== $ tagCount ) { $ error = 'Expected %s @throws tag(s) in function comment; %s found' ; $ data = array ( $ tokenCount , $ tagCount , ) ; $ phpcsFile -> addError ( $ error , $ commentEnd , 'WrongNumber' , $ data ) ; return ; } foreach ( $ throwTokens as $ throw ) { if ( isset ( $ throwTags [ $ throw ] ) === false ) { $ error = 'Missing @throws tag for "%s" exception' ; $ data = array ( $ throw ) ; $ phpcsFile -> addError ( $ error , $ commentEnd , 'Missing' , $ data ) ; } } }
Processes the function tokens within the class.
Processes the function tokens within the class .
// Is this the first throw token within the current function scope?
 // If so, we have to validate other throw tokens within the same scope. // Function is using the wrong type of comment. // Function doesn't have a doc comment. // Find all the exception type token within the current scope. /*
                    If we can't find a NEW, we are probably throwing
                    a variable, so we ignore it, but they still need to
                    provide at least one @throws tag, even through we
                    don't know the exception class.
                */ //end if //end if //end if //end while // Only need one @throws tag for each type of exception thrown. // If token count is zero, it means that only variables are being // thrown, so we need at least one @throws tag (checked above). // Nothing more to do. // Make sure @throws tag count matches throw token count.