aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-29 02:27:44 +0900
committernsfisis <nsfisis@gmail.com>2026-06-29 02:28:08 +0900
commit27e02b6c8968f89cf601ef597fcefa6a9627718e (patch)
tree4b7d8c00a2a46b94425fd4b4afc976b75d285c07 /crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs
parent3b28fc65f5de7c6ad69bee48b2d1f52dd9b30972 (diff)
downloadphp-shirabe-27e02b6c8968f89cf601ef597fcefa6a9627718e.tar.gz
php-shirabe-27e02b6c8968f89cf601ef597fcefa6a9627718e.tar.zst
php-shirabe-27e02b6c8968f89cf601ef597fcefa6a9627718e.zip
feat(console): implement output instanceof downcasts in process/progress helpers
Co-Authored-By: Claude Opus 4.8 (1M context) <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.rs32
1 files changed, 20 insertions, 12 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 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<RefCell<dyn OutputInterface>> =
- 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<RefCell<dyn OutputInterface>> = {
+ let redirected = shirabe_php_shim::AsAny::as_any(&*output.borrow())
+ .downcast_ref::<crate::symfony::console::output::console_output::ConsoleOutput>()
+ .map(|console| console.get_error_output());
+ redirected.unwrap_or(output)
+ };
let formatter: Rc<RefCell<DebugFormatterHelper>> = self
.get_helper_set()
@@ -220,15 +225,18 @@ impl ProcessHelper {
&self,
output: Rc<RefCell<dyn OutputInterface>>,
process: &Process,
- // TODO: remove allow(unused_mut) once todo!() is resolved.
- #[allow(unused_mut)] mut callback: Option<Box<dyn FnMut(&str, &str)>>,
+ mut callback: Option<Box<dyn FnMut(&str, &str)>>,
) -> Box<dyn FnMut(&str, &str)> {
// 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<RefCell<dyn OutputInterface>> =
- 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<RefCell<dyn OutputInterface>> = {
+ let redirected = shirabe_php_shim::AsAny::as_any(&*output.borrow())
+ .downcast_ref::<crate::symfony::console::output::console_output::ConsoleOutput>()
+ .map(|console| console.get_error_output());
+ redirected.unwrap_or(output)
+ };
let formatter: Rc<RefCell<DebugFormatterHelper>> = self
.get_helper_set()