diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-23 02:26:56 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-23 02:26:56 +0900 |
| commit | c644aa4df0dfcd58e3f0a1372611921678ed6c6d (patch) | |
| tree | 715f6b41884c2632047a7f310674293aa30c80fa /crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs | |
| parent | 421d98d9a52dd036acd5632f9049f4503c9add18 (diff) | |
| download | php-shirabe-c644aa4df0dfcd58e3f0a1372611921678ed6c6d.tar.gz php-shirabe-c644aa4df0dfcd58e3f0a1372611921678ed6c6d.tar.zst php-shirabe-c644aa4df0dfcd58e3f0a1372611921678ed6c6d.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs')
| -rw-r--r-- | crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs | 38 |
1 files changed, 10 insertions, 28 deletions
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<RefCell<dyn OutputInterface>> = todo!("$output instanceof ConsoleOutputInterface redirect to error output"); - let formatter: Rc<RefCell<dyn HelperInterface>> = self + let formatter: Rc<RefCell<DebugFormatterHelper>> = 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<RefCell<dyn OutputInterface>> = todo!("$output instanceof ConsoleOutputInterface redirect to error output"); - let formatter: Rc<RefCell<dyn HelperInterface>> = self + let formatter: Rc<RefCell<DebugFormatterHelper>> = 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<RefCell<dyn HelperInterface>>, - ) -> Rc<RefCell<DebugFormatterHelper>> { - todo!("downcast HelperInterface handle to DebugFormatterHelper (Phase C)") - } - fn formatter_start( - formatter: &Rc<RefCell<dyn HelperInterface>>, + formatter: &Rc<RefCell<DebugFormatterHelper>>, 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<RefCell<dyn HelperInterface>>, + formatter: &Rc<RefCell<DebugFormatterHelper>>, 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<RefCell<dyn HelperInterface>>, + formatter: &Rc<RefCell<DebugFormatterHelper>>, id: &str, buffer: &str, error: bool, ) -> String { - Self::debug_formatter(formatter) + formatter .borrow_mut() .progress(id, buffer, error, "OUT", "ERR") } |
