protected function validDirectScope(File $phpcsFile, $stackPtr, $validScopes)
    {
        $tokens = $phpcsFile->getTokens();

        if (empty($tokens[$stackPtr]['conditions']) === true) {
            return false;
        }

        /*
         * Check only the direct wrapping scope of the token.
         */
        $conditions = array_keys($tokens[$stackPtr]['conditions']);
        $ptr        = array_pop($conditions);

        if (isset($tokens[$ptr]) === false) {
            return false;
        }

        if (isset($validScopes[$tokens[$ptr]['type']]) === true) {
            return $ptr;
        }

        return false;
    }
protected function validDirectScope(File $phpcsFile, $stackPtr, $validScopes)
    {
        $tokens = $phpcsFile->getTokens();

        if (empty($tokens[$stackPtr]['conditions']) === true) {
            return false;
        }

        /*
         * Check only the direct wrapping scope of the token.
         */
        $conditions = array_keys($tokens[$stackPtr]['conditions']);
        $ptr        = array_pop($conditions);

        if (isset($tokens[$ptr]) === false) {
            return false;
        }

        if (isset($validScopes[$tokens[$ptr]['type']]) === true) {
            return $ptr;
        }

        return false;
    }
protected function validDirectScope ( File $ phpcsFile , $ stackPtr , $ validScopes ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( empty ( $ tokens [ $ stackPtr ] [ 'conditions' ] ) === true ) { return false ; } /*
         * Check only the direct wrapping scope of the token.
         */ $ conditions = array_keys ( $ tokens [ $ stackPtr ] [ 'conditions' ] ) ; $ ptr = array_pop ( $ conditions ) ; if ( isset ( $ tokens [ $ ptr ] ) === false ) { return false ; } if ( isset ( $ validScopes [ $ tokens [ $ ptr ] [ 'type' ] ] ) === true ) { return $ ptr ; } return false ; }
Check whether the direct wrapping scope of a token is within a limited set of
acceptable tokens.

Used to check, for instance, if a T_CONST is a class constant.

@param \PHP_CodeSniffer_File $phpcsFile   Instance of phpcsFile.
@param int                   $stackPtr    The position in the stack of the
T_CONST token to verify.
@param array                 $validScopes Array of token types.
Keys should be the token types in string
format to allow for newer token types.
Value is irrelevant.

@return int|bool StackPtr to the scope if valid, false otherwise.
Check whether the direct wrapping scope of a token is within a limited set of acceptable tokens .