|
|
|
|
@ -14,10 +14,12 @@ if ($debugging_AKA_non_production_mode) { |
|
|
|
|
$print_new_line = true; |
|
|
|
|
$show_filename_comments = true; |
|
|
|
|
$skip_mocking_data_arrays = false; |
|
|
|
|
$skip_extras_folder = false; |
|
|
|
|
} else { |
|
|
|
|
$print_new_line = false; |
|
|
|
|
$show_filename_comments = false; |
|
|
|
|
$skip_mocking_data_arrays = true; |
|
|
|
|
$skip_extras_folder = true; |
|
|
|
|
} |
|
|
|
|
$make_one_file = true; |
|
|
|
|
|
|
|
|
|
@ -43,8 +45,10 @@ function single_file(): void { |
|
|
|
|
foreach($bootstap_files as $bs) { |
|
|
|
|
$core_files[] = $bs; |
|
|
|
|
} |
|
|
|
|
rsearch($core_files, "classes", "/^.*\.(php)$/"); |
|
|
|
|
$rsearch = rsearch($core_files, "classes", "/^.*\.(php)$/"); |
|
|
|
|
compile($core_files, "tts.php", true); // true = Append mode |
|
|
|
|
get_classes($rsearch['arrays'], "tts_arrays"); |
|
|
|
|
get_classes($rsearch['extras'], "tts_extras"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function multi_files(): void { |
|
|
|
|
@ -69,9 +73,56 @@ function multi_files(): void { |
|
|
|
|
foreach($bootstap_files as $bs) { |
|
|
|
|
$core_files[] = $bs; |
|
|
|
|
} |
|
|
|
|
rsearch($core_files, "classes", "/^.*\.(php)$/"); |
|
|
|
|
$rsearch = rsearch($core_files, "classes", "/^.*\.(php)$/"); |
|
|
|
|
compile($core_files, "tts_core.php", false, "namespace tts;"); |
|
|
|
|
get_classes($rsearch['arrays'], "tts_arrays"); |
|
|
|
|
get_classes($rsearch['extras'], "tts_extras"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function grab_class_name(string $input): false | string { |
|
|
|
|
$e = explode(" ", $input); |
|
|
|
|
$class = $e[0] ?? false; |
|
|
|
|
if ($class === false) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$reversedParts = explode('/', strrev($class), 2); |
|
|
|
|
$ret = strrev($reversedParts[0]); |
|
|
|
|
if (! empty($ret)) { |
|
|
|
|
return $ret; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function get_classes(array $file_list, string $file_name): void { |
|
|
|
|
$classes = []; |
|
|
|
|
foreach($file_list as $file) { |
|
|
|
|
$read = fopen($file, 'r'); |
|
|
|
|
if ( $read === false || ! is_resource($read) ) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
while (($line = fgets($read)) !== false) { |
|
|
|
|
if (!str_contains($line, "class ")) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$ex = explode("class ", $line); |
|
|
|
|
$class_part = $ex[1] ?? false; |
|
|
|
|
if ($class_part === false) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$class_name = grab_class_name($class_part); |
|
|
|
|
if ($class_name === false) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$classes[] = $class_name; |
|
|
|
|
} |
|
|
|
|
fclose($read); |
|
|
|
|
} |
|
|
|
|
$append = fopen(__DIR__ . "/dist/tts.php", "a"); |
|
|
|
|
|
|
|
|
|
fwrite($append, "\$$file_name = \"". base64_encode(json_encode($classes)) . "\";"); |
|
|
|
|
fclose($append); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* Remove already included BS files, pop them...out of the array |
|
|
|
|
*/ |
|
|
|
|
@ -83,14 +134,28 @@ function pop_bs(array & $files, array $files_to_pop): void { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function rsearch(array & $file_list, string $folder, string $pattern): void { |
|
|
|
|
function rsearch(array & $file_list, string $folder, string $pattern): array { |
|
|
|
|
$dir = new RecursiveDirectoryIterator($folder); |
|
|
|
|
$ite = new RecursiveIteratorIterator($dir); |
|
|
|
|
$files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH); |
|
|
|
|
|
|
|
|
|
$arrays = []; |
|
|
|
|
$extras = []; |
|
|
|
|
|
|
|
|
|
foreach($files as $file) { |
|
|
|
|
if (str_contains($file[0], "/obsolete/")) { |
|
|
|
|
continue; // Skip Obsolete stuff |
|
|
|
|
} |
|
|
|
|
if (( |
|
|
|
|
$GLOBALS['skip_extras_folder'] || |
|
|
|
|
$GLOBALS['make_one_file'] === false |
|
|
|
|
) && |
|
|
|
|
str_contains($file[0], "/extras/") |
|
|
|
|
) { |
|
|
|
|
$extras[] = $file[0]; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// If we are making Multiple files, skip now and later make new file for arrays |
|
|
|
|
if (( |
|
|
|
|
$GLOBALS['skip_mocking_data_arrays'] || |
|
|
|
|
@ -103,9 +168,13 @@ function rsearch(array & $file_list, string $folder, string $pattern): void { |
|
|
|
|
} |
|
|
|
|
$file_list[] = $file[0]; |
|
|
|
|
} |
|
|
|
|
if ($GLOBALS['skip_extras_folder'] || $GLOBALS['make_one_file'] === false) { |
|
|
|
|
compile($extras, "tts_extras.php", false, "namespace tts;"); |
|
|
|
|
} |
|
|
|
|
if ($GLOBALS['skip_mocking_data_arrays'] || $GLOBALS['make_one_file'] === false) { |
|
|
|
|
compile($arrays, "tts_arrays.php", false, "namespace tts;"); |
|
|
|
|
} |
|
|
|
|
return ['extras' => $extras, 'arrays' => $arrays]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function remove_comments(string & $str): void { |
|
|
|
|
|