<commit_before><?php

$environmentSource = __DIR__ . '/../vendor/nette/tester/src/Framework/Environment.php';

$source = file_get_contents($environmentSource);

if (strpos($source, '/* patched */') === false) {

	$source = preg_replace('~namespace Tester;~i', "namespace Tester; \n/* patched */", $source);
	$source = preg_replace(
		'~register_shutdown_function\(function \(\) use \(\$error\) {~',
		'register_shutdown_function(function () use ($error) {  if (!$error) { return; } ',
		$source
	);

	file_put_contents($environmentSource, $source);

}<commit_msg>Fix for old nette/tester on php 8.1<commit_after><?php

$environmentSource = __DIR__ . '/../vendor/nette/tester/src/Framework/Environment.php';

$source = file_get_contents($environmentSource);

if (strpos($source, '/* patched */') === false) {

	$source = preg_replace('~namespace Tester;~i', "namespace Tester; \n/* patched */", $source);
	$source = preg_replace(
		'~register_shutdown_function\(function \(\) use \(\$error\) {~',
		'register_shutdown_function(function () use ($error) {  if (!$error) { return; } ',
		$source
	);

	file_put_contents($environmentSource, $source);

}


$patchFiles = __DIR__ . '/fixed-tester/src/Framework/*';
$targetDir = __DIR__ . '/../vendor/nette/tester/src/Framework';
foreach (glob($patchFiles) as $patch) {
	copy($patch, $targetDir . '/' . basename($patch));
}
{'fraction_non_alphanumeric': 0.20073260073260074, 'fraction_numerical': 0.0014652014652014652, 'mean_word_length': 4.939130434782609, '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': '5597095', 'n_tokens_mistral': 479, 'n_tokens_neox': 466, 'n_words': 83}