<commit_before><?php

class PHPUnit_Util_Filter
{
    public static function getFilteredStackTrace(Exception $e, $asString = true)
    {
        $stackTrace = $asString ? '' : array();

        $trace = $e->getPrevious() ? $e->getPrevious()->getTrace() : $e->getTrace();

        foreach ($trace as $step) {
            if (! isset($step['file'])) {
                continue;
            }
            if (self::classIsFiltered($step)) {
                continue;
            }
            if (self::fileIsFiltered($step)) {
                continue;
            }

            if (! $asString) {
                $stackTrace[] = $step;
                continue;
            }

            $stackTrace .= $step['file'] . ':' . $step['line'] . "\n";
        }

        return $stackTrace;
    }

    protected static function classIsFiltered($step)
    {
        if (! isset($step['class'])) {
            return false;
        }

        $className = $step['class'];

        if (strpos($className, 'Symfony\Component\Console') === 0) {
            return true;
        }

        if (strpos($className, 'Codeception\Command\\') === 0) {
            return true;
        }

        return false;
    }

    protected static function fileIsFiltered($step)
    {
        if (! isset($step['file'])) {
            return false;
        }

        if (strpos($step['file'], 'codecept.phar/') !== false) {
            return true;
        }

        if (strpos($step['file'], 'vendor' . DIRECTORY_SEPARATOR . 'phpunit') !== false) {
            return true;
        }

        if (strpos($step['file'], 'vendor' . DIRECTORY_SEPARATOR . 'codeception') !== false) {
            return true;
        }

        if (strpos($step['file'], 'src' . DIRECTORY_SEPARATOR . 'Codeception' . DIRECTORY_SEPARATOR) !== false) {
            return true;
        }

        return false;
    }
}
<commit_msg>filtered stack traces should leave Codeception Module references<commit_after><?php

class PHPUnit_Util_Filter
{
    public static function getFilteredStackTrace(Exception $e, $asString = true)
    {
        $stackTrace = $asString ? '' : array();

        $trace = $e->getPrevious() ? $e->getPrevious()->getTrace() : $e->getTrace();

        foreach ($trace as $step) {
            if (! isset($step['file'])) {
                continue;
            }
            if (self::classIsFiltered($step)) {
                continue;
            }
            if (self::fileIsFiltered($step)) {
                continue;
            }

            if (! $asString) {
                $stackTrace[] = $step;
                continue;
            }

            $stackTrace .= $step['file'] . ':' . $step['line'] . "\n";
        }

        return $stackTrace;
    }

    protected static function classIsFiltered($step)
    {
        if (! isset($step['class'])) {
            return false;
        }

        $className = $step['class'];

        if (strpos($className, 'Symfony\Component\Console') === 0) {
            return true;
        }

        if (strpos($className, 'Codeception\Command\\') === 0) {
            return true;
        }

        return false;
    }

    protected static function fileIsFiltered($step)
    {
        if (! isset($step['file'])) {
            return false;
        }

        if (strpos($step['file'], 'codecept.phar/') !== false) {
            return true;
        }

        if (strpos($step['file'], 'vendor' . DIRECTORY_SEPARATOR . 'phpunit') !== false) {
            return true;
        }

        if (strpos($step['file'], 'vendor' . DIRECTORY_SEPARATOR . 'codeception') !== false) {
            return true;
        }

        if (strpos($step['file'], 'src' . DIRECTORY_SEPARATOR . 'Codeception' . DIRECTORY_SEPARATOR . 'Module') !== false) {
            return false; // don`t filter modules
        }

        if (strpos($step['file'], 'src' . DIRECTORY_SEPARATOR . 'Codeception' . DIRECTORY_SEPARATOR) !== false) {
            return true;
        }

        return false;
    }
}

{'fraction_non_alphanumeric': 0.15290596158643052, 'fraction_numerical': 0.0009977550511349464, 'mean_word_length': 1.652116402116402, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2756998', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1121, 'n_words': 232}