diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-03 00:34:01 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-03 00:34:01 +0900 |
| commit | e93ea9ae1058334fc72b7795021bb42c1bd64401 (patch) | |
| tree | dd0972233aa13308975f7a3c1e0380ebbd7672ec /crates/shirabe/src/event_dispatcher | |
| parent | 51843230859ef39344c0b67daa9049ead87ec49c (diff) | |
| download | php-shirabe-e93ea9ae1058334fc72b7795021bb42c1bd64401.tar.gz php-shirabe-e93ea9ae1058334fc72b7795021bb42c1bd64401.tar.zst php-shirabe-e93ea9ae1058334fc72b7795021bb42c1bd64401.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/event_dispatcher')
| -rw-r--r-- | crates/shirabe/src/event_dispatcher/event_dispatcher.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index 237fad4..175b689 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -609,11 +609,8 @@ impl EventDispatcher { .join(" "); // reusing the output from $this->io is mostly needed for tests, but generally speaking // it does not hurt to keep the same stream as the current Application - // TODO(phase-b): IOInterface needs an `as_any` shim before - // `instanceof ConsoleIO` can be expressed; treat io as a - // generic IOInterface for now. - let downcast: Option<&ConsoleIO> = None; - let output: ConsoleOutput = if let Some(_console_io) = downcast { + let is_console_io = self.io.borrow().as_any().is::<ConsoleIO>(); + let output: ConsoleOutput = if is_console_io { // TODO(plugin): \ReflectionProperty to read private `output` from ConsoleIO // is required by the original PHP — needs user-decided porting strategy. let _refl_php_version_gate = PHP_VERSION_ID < 80100; |
