From 421d98d9a52dd036acd5632f9049f4503c9add18 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 23 Jun 2026 01:41:33 +0900 Subject: refactor(io): hold QuestionHelper directly in ConsoleIO instead of HelperSet Every ConsoleIO construction site only ever registers a single QuestionHelper (production) or none (tests), and routing asks through HelperSet::get('question') loses the concrete type, forcing a downcast back to QuestionHelper. Receive the QuestionHelper in the constructor and hold it directly (in a RefCell, since QuestionHelper::ask takes &mut self while the IOInterfaceImmutable ask methods are &self), dropping the HelperSet field and the throwaway HelperSet built at each call site. Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/tests/io/console_io_test.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/tests/io') diff --git a/crates/shirabe/tests/io/console_io_test.rs b/crates/shirabe/tests/io/console_io_test.rs index a79b7ca..3c8242a 100644 --- a/crates/shirabe/tests/io/console_io_test.rs +++ b/crates/shirabe/tests/io/console_io_test.rs @@ -7,7 +7,7 @@ use indexmap::IndexMap; use shirabe::io::ConsoleIO; use shirabe::io::IOInterfaceImmutable; use shirabe::io::IOInterfaceMutable; -use shirabe_external_packages::symfony::console::helper::HelperSet; +use shirabe_external_packages::symfony::console::helper::QuestionHelper; use shirabe_external_packages::symfony::console::input::array_input::ArrayInput; use shirabe_external_packages::symfony::console::input::input_interface::InputInterface; use shirabe_external_packages::symfony::console::output::buffered_output::BufferedOutput; @@ -15,7 +15,7 @@ use shirabe_external_packages::symfony::console::output::output_interface::Outpu use std::cell::RefCell; use std::rc::Rc; -/// Builds a ConsoleIO backed by real, side-effect-free Input/Output/HelperSet. PHP uses +/// Builds a ConsoleIO backed by real, side-effect-free Input/Output/QuestionHelper. PHP uses /// PHPUnit mocks here, but for tests that exercise only the authentication map they carry no /// expectations, so concrete implementations are an exact substitute. fn make_console_io() -> ConsoleIO { @@ -23,8 +23,7 @@ fn make_console_io() -> ConsoleIO { Rc::new(RefCell::new(ArrayInput::new(vec![], None).unwrap())); let output: Rc> = Rc::new(RefCell::new(BufferedOutput::new(None, false, None))); - let helper_set = HelperSet::default(); - ConsoleIO::new(input, output, helper_set) + ConsoleIO::new(input, output, QuestionHelper::default()) } #[ignore = "requires a PHPUnit mock of InputInterface::isInteractive with willReturnOnConsecutiveCalls; no mocking framework"] -- cgit v1.3.1