.php: a class with a static register() method), so * groups are written and checked apart. */ final class Templates { /** @var array opcode name => template */ public static array $op = []; /** @var array expression element code (opernames) => template */ public static array $oper = []; /** @var array store target code (storenames) => template */ public static array $store = []; /** @var array add target code (addnames) => template */ public static array $add = []; private static bool $loaded = false; /** @var list only these groups (file names without .php; tools/run.php --compiled-only=), empty = all */ public static array $only = []; public static function load(): void { if (self::$loaded) { return; } self::$loaded = true; foreach (glob(__DIR__ . '/Templates/*.php') ?: [] as $file) { $group = basename($file, '.php'); if (self::$only !== [] && !in_array($group, self::$only, true)) { continue; } $class = __NAMESPACE__ . '\\Templates\\' . $group; try { if (class_exists($class) && method_exists($class, 'register')) { $class::register(); } } catch (\Throwable $e) { error_log("ALIS compiler: templates $group skipped: " . $e->getMessage()); // a file being written } } } }