<commit_before><?php

$phpzm = dirname(__DIR__, 2);

$versions = [];
$packages = [];
foreach (new DirectoryIterator($phpzm) as $file) {
    if ($file->isDot()) {
        continue;
    }
    $filename = $file->getPathname() . '/composer.json';
    $composer = json_decode(file_get_contents($filename));

    $package = 'phpzm/' . $file->getFilename();

    $versions[$package] = $composer->version;
    $packages[$package] = [
        'filename' => $filename,
        'composer' => $composer
    ];
}

foreach ($packages as $package => $project) {
    echo $package, PHP_EOL;
    $requires = (array)$project['composer']->require;
    foreach ($requires as $key => $value) {
        if (isset($versions[$key])) {
            echo '    ', $key , ' [', $versions[$key], ' = ', substr($value, 2), '] ', PHP_EOL;
            /** @noinspection PhpVariableVariableInspection */
            $requires[$key] = '>=' . $versions[$key];
        }
    }
    if ($project['composer']->require !== $requires) {
        touch(file_exists($file->getPathname() . '/.dirty'));
    }
    $project['composer']->require = $requires;

    $json = json_encode($project['composer'], JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
    file_put_contents($project['filename'], preg_replace('/^(  +?)\\1(?=[^ ])/m', '$1', $json));

    echo PHP_EOL;
}
<commit_msg>Automatized update<commit_after><?php

$phpzm = dirname(__DIR__, 2);

$versions = [];
$packages = [];
foreach (new DirectoryIterator($phpzm) as $file) {
    if ($file->isDot()) {
        continue;
    }
    $filename = $file->getPathname() . '/composer.json';
    $composer = json_decode(file_get_contents($filename));

    $package = 'phpzm/' . $file->getFilename();

    $versions[$package] = $composer->version;
    $packages[$package] = [
        'filename' => $filename,
        'composer' => $composer
    ];
}

foreach ($packages as $package => $project) {
    echo $package, PHP_EOL;
    $requires = (array)$project['composer']->require;
    foreach ($requires as $key => $value) {
        if (isset($versions[$key])) {
            echo '    ', $key , ' [', substr($value, 2), ' => ', $versions[$key], '] ', PHP_EOL;
            /** @noinspection PhpVariableVariableInspection */
            $requires[$key] = '>=' . $versions[$key];
        }
    }
    if ($project['composer']->require !== $requires) {
        touch(file_exists($file->getPathname() . '/.dirty'));
    }
    $project['composer']->require = $requires;

    $json = json_encode($project['composer'], JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
    file_put_contents($project['filename'], preg_replace('/^(  +?)\\1(?=[^ ])/m', '$1', $json));

    echo PHP_EOL;
}

{'fraction_non_alphanumeric': 0.21042760690172543, 'fraction_numerical': 0.003000750187546887, 'mean_word_length': 3.2333333333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '6793372', 'n_tokens_mistral': 902, 'n_tokens_neox': 869, 'n_words': 149}