aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/io/buffer_io.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-23 01:41:33 +0900
committernsfisis <nsfisis@gmail.com>2026-06-23 01:41:33 +0900
commit421d98d9a52dd036acd5632f9049f4503c9add18 (patch)
tree578d4bc15a7cb01a591393df85d0b9cdfd7d6ea2 /crates/shirabe/src/io/buffer_io.rs
parent894764ecb04f9c456b9ebda77d155bf6128e2175 (diff)
downloadphp-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.tar.gz
php-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.tar.zst
php-shirabe-421d98d9a52dd036acd5632f9049f4503c9add18.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/io/buffer_io.rs')
-rw-r--r--crates/shirabe/src/io/buffer_io.rs16
1 files changed, 1 insertions, 15 deletions
diff --git a/crates/shirabe/src/io/buffer_io.rs b/crates/shirabe/src/io/buffer_io.rs
index 91d22d7..933deab 100644
--- a/crates/shirabe/src/io/buffer_io.rs
+++ b/crates/shirabe/src/io/buffer_io.rs
@@ -4,9 +4,6 @@ use crate::io::ConsoleIO;
use anyhow::Result;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::formatter::OutputFormatterInterface;
-use shirabe_external_packages::symfony::console::helper::HelperInterface;
-use shirabe_external_packages::symfony::console::helper::HelperSet;
-use shirabe_external_packages::symfony::console::helper::HelperSetKey;
use shirabe_external_packages::symfony::console::helper::QuestionHelper;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::input::StringInput;
@@ -53,22 +50,11 @@ impl BufferIO {
let output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>> =
todo!("wire StreamOutput as the ConsoleIO output (needs PhpResource stream)");
- let question_helper: std::rc::Rc<std::cell::RefCell<dyn HelperInterface>> =
- std::rc::Rc::new(std::cell::RefCell::new(QuestionHelper::default()));
- let mut helpers: indexmap::IndexMap<
- HelperSetKey,
- std::rc::Rc<std::cell::RefCell<dyn HelperInterface>>,
- > = indexmap::IndexMap::new();
- helpers.insert(HelperSetKey::Int(0), question_helper);
- let helper_set = std::rc::Rc::new(std::cell::RefCell::new(HelperSet::default()));
- HelperSet::new(&helper_set, helpers);
- let helper_set = helper_set.borrow().clone();
-
let inner = ConsoleIO::new(
std::rc::Rc::new(std::cell::RefCell::new(input_obj))
as std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
output,
- helper_set,
+ QuestionHelper::default(),
);
Ok(Self { inner })