protected function hasTargetInList(File $phpcsFile, $start, $closer)
    {
        $tokens = $phpcsFile->getTokens();

        for ($i = ($start + 1); $i < $closer; $i++) {
            if (isset($this->allTargets[$tokens[$i]['code']]) === false) {
                continue;
            }

            if (isset($this->targetsInList[$tokens[$i]['code']]) === true) {
                return $i;
            }

            // Skip past nested list constructs.
            if ($tokens[$i]['code'] === \T_LIST) {
                $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
                if ($nextNonEmpty !== false
                    && $tokens[$nextNonEmpty]['code'] === \T_OPEN_PARENTHESIS
                    && isset($tokens[$nextNonEmpty]['parenthesis_closer']) === true
                ) {
                    $i = $tokens[$nextNonEmpty]['parenthesis_closer'];
                }
            } elseif ($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
                && isset($tokens[$i]['bracket_closer'])
            ) {
                $i = $tokens[$i]['bracket_closer'];
            }
        }

        return false;
    }
protected function hasTargetInList(File $phpcsFile, $start, $closer)
    {
        $tokens = $phpcsFile->getTokens();

        for ($i = ($start + 1); $i < $closer; $i++) {
            if (isset($this->allTargets[$tokens[$i]['code']]) === false) {
                continue;
            }

            if (isset($this->targetsInList[$tokens[$i]['code']]) === true) {
                return $i;
            }

            // Skip past nested list constructs.
            if ($tokens[$i]['code'] === \T_LIST) {
                $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
                if ($nextNonEmpty !== false
                    && $tokens[$nextNonEmpty]['code'] === \T_OPEN_PARENTHESIS
                    && isset($tokens[$nextNonEmpty]['parenthesis_closer']) === true
                ) {
                    $i = $tokens[$nextNonEmpty]['parenthesis_closer'];
                }
            } elseif ($tokens[$i]['code'] === \T_OPEN_SHORT_ARRAY
                && isset($tokens[$i]['bracket_closer'])
            ) {
                $i = $tokens[$i]['bracket_closer'];
            }
        }

        return false;
    }
protected function hasTargetInList ( File $ phpcsFile , $ start , $ closer ) { $ tokens = $ phpcsFile -> getTokens ( ) ; for ( $ i = ( $ start + 1 ) ; $ i < $ closer ; $ i ++ ) { if ( isset ( $ this -> allTargets [ $ tokens [ $ i ] [ 'code' ] ] ) === false ) { continue ; } if ( isset ( $ this -> targetsInList [ $ tokens [ $ i ] [ 'code' ] ] ) === true ) { return $ i ; } // Skip past nested list constructs. if ( $ tokens [ $ i ] [ 'code' ] === \ T_LIST ) { $ nextNonEmpty = $ phpcsFile -> findNext ( Tokens :: $ emptyTokens , ( $ i + 1 ) , null , true ) ; if ( $ nextNonEmpty !== false && $ tokens [ $ nextNonEmpty ] [ 'code' ] === \ T_OPEN_PARENTHESIS && isset ( $ tokens [ $ nextNonEmpty ] [ 'parenthesis_closer' ] ) === true ) { $ i = $ tokens [ $ nextNonEmpty ] [ 'parenthesis_closer' ] ; } } elseif ( $ tokens [ $ i ] [ 'code' ] === \ T_OPEN_SHORT_ARRAY && isset ( $ tokens [ $ i ] [ 'bracket_closer' ] ) ) { $ i = $ tokens [ $ i ] [ 'bracket_closer' ] ; } } return false ; }
Check whether a certain target token exists within a list construct.

Skips past nested list constructs, so these can be examined based on their own token.

@param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
@param int                   $start     The position of the list open token or a token
within the list to start (resume) the examination from.
@param int                   $closer    The position of the list close token.

@return int|bool Stack pointer to the target token if encountered. False otherwise.
Check whether a certain target token exists within a list construct .