protected function functionHasReturnStatement(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $continueSearch = null)
    {
        $tokens = $phpcsFile->getTokens();
        $sFunctionToken = $tokens[$stackPtr];

        $returnStatement = false;
        if (isset($sFunctionToken['scope_closer']) and isset($sFunctionToken['scope_opener'])) {
            $startSearch = $continueSearch !== null ? $continueSearch : $sFunctionToken['scope_opener'];
            $returnStatement =
                $phpcsFile->findNext(T_RETURN, $startSearch, $sFunctionToken['scope_closer'])
                || $phpcsFile->findNext(T_YIELD,  $startSearch, $sFunctionToken['scope_closer']);
        }

        if ($returnStatement !== false) {
            if ($phpcsFile->hasCondition($returnStatement, T_CLOSURE)) {
                return $this->functionHasReturnStatement($phpcsFile, $stackPtr, $returnStatement+1);
            } else {
                return true;
            }
        }

        return false;
    }