protected function getScopeCloser(File $phpcsFile, $stackPtr)
    {
        $tokens      = $phpcsFile->getTokens();
        $scopeCloser = $tokens[$stackPtr]['scope_closer'];

        if ($tokens[$stackPtr]['code'] !== T_DO) {
            return $scopeCloser;
        }

        $trailingContent = $phpcsFile->findNext(
            Tokens::$emptyTokens,
            ($scopeCloser + 1),
            null,
            true
        );

        if ($tokens[$trailingContent]['code'] === T_WHILE) {
            return ($tokens[$trailingContent]['parenthesis_closer'] + 1);
        }

        // @codeCoverageIgnoreStart
        $phpcsFile->addError('Expected "while" not found after "do"', $stackPtr, 'InvalidDo');

        return $scopeCloser;
        // @codeCoverageIgnoreEnd
    }