From e93ea9ae1058334fc72b7795021bb42c1bd64401 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 3 Jun 2026 00:34:01 +0900 Subject: feat(io): add as_any downcast shims for IOInterface and OutputInterface Introduce the cross-cutting downcast base for PHP `instanceof` checks on io/output trait objects: `IOInterface::as_any` (ConsoleIO/NullIO/BufferIO) and `OutputInterface::as_console_output_interface` (promoting ConsoleOutput to a proper ConsoleOutputInterface). Wire the resolved downcasts in ConsoleIO error output, Auditor table format, and the event dispatcher. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/symfony/component/console/output/output_interface.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/shirabe-external-packages/src/symfony/component/console/output/output_interface.rs') diff --git a/crates/shirabe-external-packages/src/symfony/component/console/output/output_interface.rs b/crates/shirabe-external-packages/src/symfony/component/console/output/output_interface.rs index 36b6c08..11fb82e 100644 --- a/crates/shirabe-external-packages/src/symfony/component/console/output/output_interface.rs +++ b/crates/shirabe-external-packages/src/symfony/component/console/output/output_interface.rs @@ -1,4 +1,5 @@ use crate::symfony::component::console::formatter::OutputFormatter; +use crate::symfony::component::console::output::ConsoleOutputInterface; pub trait OutputInterface { // PHP class semantics: OutputInterface methods take &self with interior mutability, @@ -21,6 +22,12 @@ pub trait OutputInterface { false } + /// PHP: `$output instanceof ConsoleOutputInterface`. Returns the output as a + /// ConsoleOutputInterface trait object when it is one. Default None; ConsoleOutput overrides. + fn as_console_output_interface(&self) -> Option<&dyn ConsoleOutputInterface> { + None + } + /// PHP: only StreamOutput exposes `getStream()`. Default panics for outputs without one. fn get_stream(&self) -> shirabe_php_shim::PhpResource { todo!("get_stream not available on this OutputInterface implementation") -- cgit v1.3.1