From e5e6cc6807c9fbbef883ffe0eec9eed477d5bee3 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 1 Aug 2026 20:51:40 +0900 Subject: feat(symfony-console): implement interactive question/style helpers Resolve the remaining todo!()s in SymfonyStyle, OutputStyle, QuestionHelper and SymfonyQuestionHelper: * Wire up the virtual dispatch PHP performs for the protected writePrompt()/writeError() overrides, following the codebase's established inheritance idiom (Command, ArchiveDownloader): the base class becomes a trait (QuestionHelperInterface, named after the QuestionInterface precedent) whose provided methods ask/do_ask/ validate_attempts carry the template logic and late-bind the write_prompt/write_error hooks through Self, with inner()/inner_mut() reaching the base-class state. SymfonyQuestionHelper overrides the hooks as plain trait-impl methods, mirroring PHP's protected-method overriding, so SymfonyStyle-driven questions now render the Symfony Style Guide prompt. * Type definition_list input as an enum (string|array|TableSeparator) because PhpMixed intentionally cannot carry objects; the InvalidArgumentException branch (a LogicException) becomes unrepresentable. horizontal_table now takes typed Cells/Rows. * Propagate the MissingInputException thrown inside autocomplete() through a Result instead of aborting. * Implement as_console_output_interface via Ref::filter_map on ConsoleOutput, the interface's only implementor. * Port progressIterate eagerly, following ProgressBar::iterate. * Map __FILE__ to current_exe(): a native binary never runs from a phar, so the hiddeninput.exe relocation branch correctly never fires. Co-Authored-By: Claude Fable 5 --- .../src/symfony/console/style/output_style.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/console/style/output_style.rs') diff --git a/crates/shirabe-external-packages/src/symfony/console/style/output_style.rs b/crates/shirabe-external-packages/src/symfony/console/style/output_style.rs index 7d68ceaf..8d28e76d 100644 --- a/crates/shirabe-external-packages/src/symfony/console/style/output_style.rs +++ b/crates/shirabe-external-packages/src/symfony/console/style/output_style.rs @@ -41,7 +41,6 @@ impl OutputStyle { Self::as_console_output_interface(&self.output) .unwrap() - .borrow() .get_error_output() } @@ -55,10 +54,18 @@ impl OutputStyle { .is_some() } + /// PHP casts to `ConsoleOutputInterface`; `ConsoleOutput` being its only implementor, a + /// borrow of the concrete type serves as the cast result. fn as_console_output_interface( - _output: &std::rc::Rc>, - ) -> Option>> { - todo!() + output: &std::rc::Rc>, + ) -> Option> + { + std::cell::Ref::filter_map(output.borrow(), |output| { + output + .as_any() + .downcast_ref::() + }) + .ok() } } -- cgit v1.3.1