<commit_before><?php

// inspired at https://github.com/phpstan/phpstan-src/commit/87897c2a4980d68efa1c46049ac2eefe767ec946#diff-e897e523125a694bd8ea69bf83374c206803c98720c46d7401b7a7cf53915a26

declare(strict_types=1);

use Symfony\Component\Finder\Finder;

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

$buildDirectory = $argv[1];

buildPreloadScript($buildDirectory);

function buildPreloadScript(string $buildDirectory): void
{
    $vendorDir = $buildDirectory . '/vendor';
    if (!is_dir($vendorDir . '/nikic/php-parser/lib/PhpParser')) {
        return;
    }

    $preloadScript = $buildDirectory . '/preload.php';
    $template = <<<'php'
<?php

declare(strict_types = 1);

%s
php;
    $root = realpath(__DIR__ . '/..');
    if ($root === false) {
        return;
    }
    $output = '';

    $finder = (new Finder())
        ->files()
        ->name('*.php')
        ->in($vendorDir . '/nikic/php-parser/lib/PhpParser');

    foreach ($finder->getIterator() as $fileInfo) {
        $realPath = $fileInfo->getRealPath();
        if ($realPath === false) {
            continue;
        }

        $path = substr($realPath, strlen($root));
        $output .= 'require_once __DIR__ . ' . var_export($path, true) . ';' . PHP_EOL;
    }

    file_put_contents($preloadScript, sprintf($template, $output));
}<commit_msg>closer variable<commit_after><?php

// inspired at https://github.com/phpstan/phpstan-src/commit/87897c2a4980d68efa1c46049ac2eefe767ec946#diff-e897e523125a694bd8ea69bf83374c206803c98720c46d7401b7a7cf53915a26

declare(strict_types=1);

use Symfony\Component\Finder\Finder;

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

$buildDirectory = $argv[1];

buildPreloadScript($buildDirectory);

function buildPreloadScript(string $buildDirectory): void
{
    $vendorDir = $buildDirectory . '/vendor';
    if (!is_dir($vendorDir . '/nikic/php-parser/lib/PhpParser')) {
        return;
    }

    $template = <<<'php'
<?php

declare(strict_types = 1);

%s
php;
    $root = realpath(__DIR__ . '/..');
    if ($root === false) {
        return;
    }

    $output = '';

    $finder = (new Finder())
        ->files()
        ->name('*.php')
        ->in($vendorDir . '/nikic/php-parser/lib/PhpParser');

    foreach ($finder->getIterator() as $fileInfo) {
        $realPath = $fileInfo->getRealPath();
        if ($realPath === false) {
            continue;
        }

        $path = substr($realPath, strlen($root));
        $output .= 'require_once __DIR__ . ' . var_export($path, true) . ';' . PHP_EOL;
    }

    file_put_contents($buildDirectory . '/preload.php', sprintf($template, $output));
}
{'fraction_non_alphanumeric': 0.16832440703902066, 'fraction_numerical': 0.056618209640397855, 'mean_word_length': 3.1376582278481013, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '3706828', 'n_tokens_mistral': 996, 'n_tokens_neox': 911, 'n_words': 139}