From c644aa4df0dfcd58e3f0a1372611921678ed6c6d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 23 Jun 2026 02:26:56 +0900 Subject: refactor(console): close HelperSet to a fixed set of four helpers Replace the dynamic, string-keyed HelperSet (set/has/get/get_iterator, HelperSetKey, deprecated set_command/get_command) with a closed set of FormatterHelper, DebugFormatterHelper, ProcessHelper and QuestionHelper instantiated by an argument-less constructor and exposed through typed getters (get_formatter/get_debug_formatter/get_process/get_question). The typed getters let ProcessHelper, QuestionHelper::write_error and InitCommand::interact drop their downcast/placeholder todo!() stubs. Dynamic registration of plugin-provided helpers is intentionally dropped for now and tracked via TODO(plugin) comments. Co-Authored-By: Claude Opus 4.8 --- .../src/symfony/console/helper/process_helper.rs | 38 ++++++---------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs') diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs index e62b9ac..f141bee 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs @@ -57,12 +57,11 @@ impl ProcessHelper { let output: Rc> = todo!("$output instanceof ConsoleOutputInterface redirect to error output"); - let formatter: Rc> = self + let formatter: Rc> = self .get_helper_set() .unwrap() .borrow() - .get("debug_formatter") - .unwrap(); + .get_debug_formatter(); // Normalize $cmd: a single Process becomes a one-element array. let mut cmd = match cmd { @@ -234,12 +233,11 @@ impl ProcessHelper { let output: Rc> = todo!("$output instanceof ConsoleOutputInterface redirect to error output"); - let formatter: Rc> = self + let formatter: Rc> = self .get_helper_set() .unwrap() .borrow() - .get("debug_formatter") - .unwrap(); + .get_debug_formatter(); let object_hash = shirabe_php_shim::spl_object_hash_process(process); @@ -268,46 +266,30 @@ impl ProcessHelper { shirabe_php_shim::str_replace("<", "\\<", str) } - /// PHP fetches `debug_formatter` from the HelperSet as a `HelperInterface` and - /// dynamically dispatches `start`/`stop`/`progress`, which are concrete - /// `DebugFormatterHelper` methods not present on the interface. Resolving the - /// dynamic helper handle back to the concrete `DebugFormatterHelper` is a - /// downcast that requires a Phase C decision (e.g. an `as_any` on - /// `HelperInterface`); deferred here. - fn debug_formatter( - _formatter: &Rc>, - ) -> Rc> { - todo!("downcast HelperInterface handle to DebugFormatterHelper (Phase C)") - } - fn formatter_start( - formatter: &Rc>, + formatter: &Rc>, id: &str, message: &str, ) -> String { - Self::debug_formatter(formatter) - .borrow_mut() - .start(id, message, "RUN") + formatter.borrow_mut().start(id, message, "RUN") } fn formatter_stop( - formatter: &Rc>, + formatter: &Rc>, id: &str, message: &str, successful: bool, ) -> String { - Self::debug_formatter(formatter) - .borrow_mut() - .stop(id, message, successful, "RES") + formatter.borrow_mut().stop(id, message, successful, "RES") } fn formatter_progress( - formatter: &Rc>, + formatter: &Rc>, id: &str, buffer: &str, error: bool, ) -> String { - Self::debug_formatter(formatter) + formatter .borrow_mut() .progress(id, buffer, error, "OUT", "ERR") } -- cgit v1.3.1