protected function getLeadingCommentOrSelf(File $phpcsFile, $stackPtr)
    {
        $prevTokens = array($stackPtr);
        $tokens     = $phpcsFile->getTokens();

        do {
            $prev    = end($prevTokens);
            $newPrev = $phpcsFile->findPrevious(
                T_WHITESPACE,
                ($prev - 1),
                null,
                true
            );

            if ($tokens[$newPrev]['code'] === T_COMMENT
                && $tokens[$newPrev]['line'] === ($tokens[$prev]['line'] - 1)
            ) {
                $prevTokens[] = $newPrev;
            } else {
                break;
            }
        } while (true);

        return end($prevTokens);
    }