aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-23 02:26:56 +0900
committernsfisis <nsfisis@gmail.com>2026-06-23 02:26:56 +0900
commitc644aa4df0dfcd58e3f0a1372611921678ed6c6d (patch)
tree715f6b41884c2632047a7f310674293aa30c80fa /crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
parent421d98d9a52dd036acd5632f9049f4503c9add18 (diff)
downloadphp-shirabe-c644aa4df0dfcd58e3f0a1372611921678ed6c6d.tar.gz
php-shirabe-c644aa4df0dfcd58e3f0a1372611921678ed6c6d.tar.zst
php-shirabe-c644aa4df0dfcd58e3f0a1372611921678ed6c6d.zip
refactor(console): close HelperSet to a fixed set of four helpers
Replace the dynamic, string-keyed HelperSet (set/has/get/get_iterator, HelperSetKey, deprecated set_command/get_command) with a closed set of FormatterHelper, DebugFormatterHelper, ProcessHelper and QuestionHelper instantiated by an argument-less constructor and exposed through typed getters (get_formatter/get_debug_formatter/get_process/get_question). The typed getters let ProcessHelper, QuestionHelper::write_error and InitCommand::interact drop their downcast/placeholder todo!() stubs. Dynamic registration of plugin-provided helpers is intentionally dropped for now and tracked via TODO(plugin) comments. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs')
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
index db9c094..f2c2a00 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
@@ -5,6 +5,7 @@ use crate::symfony::console::exception::missing_input_exception::MissingInputExc
use crate::symfony::console::exception::runtime_exception::RuntimeException;
use crate::symfony::console::formatter::output_formatter::OutputFormatter;
use crate::symfony::console::formatter::output_formatter_style::OutputFormatterStyle;
+use crate::symfony::console::helper::formatter_helper::FormatBlockMessages;
use crate::symfony::console::helper::helper::Helper;
use crate::symfony::console::helper::helper_interface::HelperInterface;
use crate::symfony::console::helper::helper_set::HelperSet;
@@ -316,22 +317,17 @@ impl QuestionHelper {
output: Rc<RefCell<dyn OutputInterface>>,
error: &shirabe_php_shim::Exception,
) {
- let message;
- if let Some(helper_set) = self.get_helper_set() {
- if helper_set.borrow().has("formatter") {
- // PHP: `$this->getHelperSet()->get('formatter')->formatBlock(...)`.
- // HelperSet::get yields `dyn HelperInterface`, which does not have
- // `AsAny` as a supertrait, so it cannot be downcast to
- // FormatterHelper. Resolved once HelperInterface gains AsAny (see
- // report).
- let _formatter = helper_set.borrow().get("formatter").unwrap();
- todo!("downcast dyn HelperInterface to FormatterHelper for format_block");
- } else {
- message = format!("<error>{}</error>", error.message);
- }
+ let message = if let Some(helper_set) = self.get_helper_set() {
+ let formatter = helper_set.borrow().get_formatter();
+ let message = formatter.borrow().format_block(
+ FormatBlockMessages::String(error.message.clone()),
+ "error",
+ false,
+ );
+ message
} else {
- message = format!("<error>{}</error>", error.message);
- }
+ format!("<error>{}</error>", error.message)
+ };
output
.borrow()