<commit_before><?php
/**
 * Build phar
 */
$srcRoot   = __DIR__ . '/src';
$buildRoot = __DIR__ . '/build';

$phar = new Phar( $buildRoot . '/phpfmt.phar',
	FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, 'myapp.phar' );

$phar['phpfmt.php'] = file_get_contents( $srcRoot . '/phpfmt.php' );

$phar->setStub( $phar->createDefaultStub( 'phpfmt.php' ) );

/**
 * Generate READNE
 */
$readme_src = file_get_contents( __DIR__ . '/README.src.md' );
$readme_out = __DIR__ . '/README.md';

$testEnv = true;
require $srcRoot . '/phpfmt.php';

$usage = '';
foreach ( getOptions( false ) as $k => $v ) {
	$usage .= '| ' . $k . ' | ' . $v . " |\n";
}

$cmd    = sprintf( 'php %s/phpfmt.php --list-simple', $srcRoot );
$passes = explode( PHP_EOL, trim( `$cmd` ) );
$passes = implode( PHP_EOL,
	array_map( function ( $v ) {
		return ' * ' . $v;
	}, $passes )
 );

file_put_contents( $readme_out,
	strtr( $readme_src, [
		'%USAGE%' => $usage,
		'%PASSES%' => $passes,
	] )
 );
<commit_msg>Pass version number as command argument<commit_after><?php
/**
 * Variables
 */
$srcRoot   = __DIR__ . '/src';
$buildRoot = __DIR__ . '/build';

/**
 * Bump version
 */

if ( ! isset( $argv[1] ) ) {
	die( 'Provide a version number as argument' . PHP_EOL );
}

$version = $argv[1];

$file = file_get_contents( $srcRoot . '/phpfmt.php' );

file_put_contents( $srcRoot . '/phpfmt.php', preg_replace( "/define\( 'VERSION'\, '(.*?)' \)\;/", "define( 'VERSION', '$version' );", $file ) );

/**
 * Build PHAR
 */

$phar = new Phar( $buildRoot . '/phpfmt.phar',
	FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, 'myapp.phar' );

$phar['phpfmt.php'] = file_get_contents( $srcRoot . '/phpfmt.php' );

$phar->setStub( $phar->createDefaultStub( 'phpfmt.php' ) );

/**
 * Generate READNE
 */
$readme_src = file_get_contents( __DIR__ . '/README.src.md' );
$readme_out = __DIR__ . '/README.md';

$testEnv = true;
require $srcRoot . '/phpfmt.php';

$usage = '';
foreach ( getOptions( false ) as $k => $v ) {
	$usage .= '| ' . $k . ' | ' . $v . " |\n";
}

$cmd    = sprintf( 'php %s/phpfmt.php --list-simple', $srcRoot );
$passes = explode( PHP_EOL, trim( `$cmd` ) );
$passes = implode( PHP_EOL,
	array_map( function ( $v ) {
		return ' * ' . $v;
	}, $passes )
 );

file_put_contents( $readme_out,
	strtr( $readme_src, [
		'%USAGE%' => $usage,
		'%PASSES%' => $passes,
	] )
 );

{'fraction_non_alphanumeric': 0.2221294363256785, 'fraction_numerical': 0.0008350730688935282, 'mean_word_length': 3.598848368522073, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '6659695', 'n_tokens_mistral': 995, 'n_tokens_neox': 989, 'n_words': 189}