From 981cae63d9777b877aa9f96907c7995ec020fbf9 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 12 Jun 2026 02:14:18 +0900 Subject: feat(php-shim): implement runtime functions to run --version Replace todo!() stubs reached on the `composer --version` path so the command runs without panicking and exits cleanly: - introspection (function_exists, class_exists, extension_loaded, defined) via white-lists modeling a standard Linux PHP CLI - type casts: php_to_string/strval, php_truthy/boolval, substr, byte_at, explode, strtr_array - config/env: error_reporting, ini_get, date_default_timezone_*, server_get/server_contains_key, php_uname("s") - IO: turn PhpResource into an enum (Stdin/Stdout/Stderr/File) and implement fwrite/fflush/stream_isatty/php_fopen resource helpers - shutdown/exit: register_shutdown_function + run_shutdown_functions, exit, error_get_last - preg_match_all_offset_capture via the regex crate; the formatter pattern drops PCRE possessive quantifiers (original kept in a comment with a TODO) proc_open reports unavailable for now (TODO(phase-c)); terminal-size and tty detection fall back to defaults. sprintf calls on this path are rewritten with format!(). OutputFormatterStyleInterface gains clone_box to return shared styles. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/main.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'crates/shirabe') diff --git a/crates/shirabe/src/main.rs b/crates/shirabe/src/main.rs index ad35201..6281ddd 100644 --- a/crates/shirabe/src/main.rs +++ b/crates/shirabe/src/main.rs @@ -2,7 +2,7 @@ use shirabe::console::Application; use shirabe::util::Platform; -use shirabe_php_shim::realpath; +use shirabe_php_shim::{realpath, run_shutdown_functions}; fn main() { // TODO(php-runtime): the full initialization process in composer/bin/composer should be ported @@ -15,11 +15,10 @@ fn main() { // run the command application let mut application = Application::new("Composer".to_string(), String::new()); - match application.run(None, None) { - Ok(_) => {} - Err(e) => { - eprintln!("{}", e); - std::process::exit(1); - } + let result = application.run(None, None); + run_shutdown_functions(); + if let Err(e) = result { + eprintln!("{}", e); + std::process::exit(1); } } -- cgit v1.3.1