private function findClosingParenthesis(File $phpcsFile, array $tokens, $start)
    {
        // Start with one open and zero closes since the start will include an open
        $openCount = 1;
        $closeCount = 0;

        // Iterate until close and open count matches
        $pointer = $start + 1;
        while ($openCount > $closeCount) {
            $tokenPtr = $phpcsFile->findNext([T_CLOSE_PARENTHESIS, T_OPEN_PARENTHESIS], $pointer);

            // If token isn't found, return
            if (!\is_int($tokenPtr)) {
                return false;
            }

            // Increment pointer
            $pointer = $tokenPtr + 1;

            // Increment counters
            switch ($tokens[$tokenPtr]['code']) {
                case T_CLOSE_PARENTHESIS:
                    ++$closeCount;
                    break;

                case T_OPEN_PARENTHESIS:
                    ++$openCount;
                    break;
            }

            // If counts match, return
            if ($openCount === $closeCount) {
                return $pointer;
            }
        }
    }
private function findClosingParenthesis(File $phpcsFile, array $tokens, $start)
    {
        // Start with one open and zero closes since the start will include an open
        $openCount = 1;
        $closeCount = 0;

        // Iterate until close and open count matches
        $pointer = $start + 1;
        while ($openCount > $closeCount) {
            $tokenPtr = $phpcsFile->findNext([T_CLOSE_PARENTHESIS, T_OPEN_PARENTHESIS], $pointer);

            // If token isn't found, return
            if (!\is_int($tokenPtr)) {
                return false;
            }

            // Increment pointer
            $pointer = $tokenPtr + 1;

            // Increment counters
            switch ($tokens[$tokenPtr]['code']) {
                case T_CLOSE_PARENTHESIS:
                    ++$closeCount;
                    break;

                case T_OPEN_PARENTHESIS:
                    ++$openCount;
                    break;
            }

            // If counts match, return
            if ($openCount === $closeCount) {
                return $pointer;
            }
        }
    }
private function findClosingParenthesis ( File $ phpcsFile , array $ tokens , $ start ) { // Start with one open and zero closes since the start will include an open $ openCount = 1 ; $ closeCount = 0 ; // Iterate until close and open count matches $ pointer = $ start + 1 ; while ( $ openCount > $ closeCount ) { $ tokenPtr = $ phpcsFile -> findNext ( [ T_CLOSE_PARENTHESIS , T_OPEN_PARENTHESIS ] , $ pointer ) ; // If token isn't found, return if ( ! \ is_int ( $ tokenPtr ) ) { return false ; } // Increment pointer $ pointer = $ tokenPtr + 1 ; // Increment counters switch ( $ tokens [ $ tokenPtr ] [ 'code' ] ) { case T_CLOSE_PARENTHESIS : ++ $ closeCount ; break ; case T_OPEN_PARENTHESIS : ++ $ openCount ; break ; } // If counts match, return if ( $ openCount === $ closeCount ) { return $ pointer ; } } }
Find matching closing parenthesis for an opening parenthesis

@param \PHP_CodeSniffer\Files\File $phpcsFile The file being checked
@param array $tokens The tokens found in file
@param int $start The position in the token stack to start searching from

@return int|bool
Find matching closing parenthesis for an opening parenthesis