<commit_before><?php
declare(strict_types = 1);

require __DIR__ . '/../vendor/autoload.php';

// detect PHPStan
if (!isset($_ENV['IS_PHPSTAN'])) {
    $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    $_ENV['IS_PHPSTAN'] = (bool) preg_match('~[/\\\\]phpstan(?:\.phar)?$~', end($trace)['file'] ?? '');
}


// configure environment
if (!$_ENV['IS_PHPSTAN']) {
    Tester\Environment::setup();
    date_default_timezone_set('Europe/Prague');
}


// create temporary directory
define('TEMP_DIR', __DIR__ . '/temp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid()));
if (!$_ENV['IS_PHPSTAN']) {
    @mkdir(dirname(TEMP_DIR)); // @ - directory may already exist
    Tester\Helpers::purge(TEMP_DIR);
    ini_set('session.save_path', TEMP_DIR);
}
<commit_msg>Fix PHPStan detection<commit_after><?php
declare(strict_types = 1);

require __DIR__ . '/../vendor/autoload.php';

// detect PHPStan
if (getenv('IS_PHPSTAN') !== false) {
    $_ENV['IS_PHPSTAN'] = in_array(strtolower(getenv('IS_PHPSTAN')), ['1', 'true', 'yes', 'on'], true);
} else {
    $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    $_ENV['IS_PHPSTAN'] = (bool) preg_match('~[/\\\\]phpstan(?:\.phar)?$~', end($trace)['file'] ?? '');
}


// configure environment
if (!$_ENV['IS_PHPSTAN']) {
    Tester\Environment::setup();
    date_default_timezone_set('Europe/Prague');
}


// create temporary directory
define('TEMP_DIR', __DIR__ . '/temp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid()));
if (!$_ENV['IS_PHPSTAN']) {
    @mkdir(dirname(TEMP_DIR)); // @ - directory may already exist
    Tester\Helpers::purge(TEMP_DIR);
    ini_set('session.save_path', TEMP_DIR);
}

{'fraction_non_alphanumeric': 0.22176470588235295, 'fraction_numerical': 0.0029411764705882353, 'mean_word_length': 5.163043478260869, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2088028', 'n_tokens_mistral': 623, 'n_tokens_neox': 611, 'n_words': 93}