From 27e02b6c8968f89cf601ef597fcefa6a9627718e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 29 Jun 2026 02:27:44 +0900 Subject: feat(console): implement output instanceof downcasts in process/progress helpers Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/symfony/console/helper/process_helper.rs | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 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 10fff08..28e2329 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 @@ -4,6 +4,7 @@ use crate::symfony::console::helper::debug_formatter_helper::DebugFormatterHelpe use crate::symfony::console::helper::helper::Helper; use crate::symfony::console::helper::helper_interface::HelperInterface; use crate::symfony::console::helper::helper_set::HelperSet; +use crate::symfony::console::output::ConsoleOutputInterface; use crate::symfony::console::output::output_interface::{self, OutputInterface}; use crate::symfony::process::exception::process_failed_exception::ProcessFailedException; use crate::symfony::process::process::Process; @@ -50,11 +51,15 @@ impl ProcessHelper { // component being absent; in this port the component is always available. // PHP: `if ($output instanceof ConsoleOutputInterface) { $output = - // $output->getErrorOutput(); }`. Downcasting a shared `dyn - // OutputInterface` to `dyn ConsoleOutputInterface` is unresolved; - // deferred to Phase C. - let output: Rc> = - todo!("$output instanceof ConsoleOutputInterface redirect to error output"); + // $output->getErrorOutput(); }`. ConsoleOutput is the only OutputInterface + // implementor that also implements ConsoleOutputInterface, so the check + // reduces to a downcast to the concrete type. + let output: Rc> = { + let redirected = shirabe_php_shim::AsAny::as_any(&*output.borrow()) + .downcast_ref::() + .map(|console| console.get_error_output()); + redirected.unwrap_or(output) + }; let formatter: Rc> = self .get_helper_set() @@ -220,15 +225,18 @@ impl ProcessHelper { &self, output: Rc>, process: &Process, - // TODO: remove allow(unused_mut) once todo!() is resolved. - #[allow(unused_mut)] mut callback: Option>, + mut callback: Option>, ) -> Box { // PHP: `if ($output instanceof ConsoleOutputInterface) { $output = - // $output->getErrorOutput(); }`. Downcasting a shared `dyn - // OutputInterface` to `dyn ConsoleOutputInterface` is unresolved; - // deferred to Phase C. - let output: Rc> = - todo!("$output instanceof ConsoleOutputInterface redirect to error output"); + // $output->getErrorOutput(); }`. ConsoleOutput is the only OutputInterface + // implementor that also implements ConsoleOutputInterface, so the check + // reduces to a downcast to the concrete type. + let output: Rc> = { + let redirected = shirabe_php_shim::AsAny::as_any(&*output.borrow()) + .downcast_ref::() + .map(|console| console.get_error_output()); + redirected.unwrap_or(output) + }; let formatter: Rc> = self .get_helper_set() -- cgit v1.3.1