diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-11 16:33:05 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-11 16:33:05 +0900 |
| commit | 27d00055df8691a6bd99aaf38633a7338b16cc6a (patch) | |
| tree | 4af17ccff5f8c2d09156fa62c559e60e3e683dac /crates/shirabe-external-packages/src/symfony/console/helper | |
| parent | 1ec2220def43e37e5a65b96dde93c19b493258f4 (diff) | |
| download | php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.tar.gz php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.tar.zst php-shirabe-27d00055df8691a6bd99aaf38633a7338b16cc6a.zip | |
chore: use fully-qualified name for Rc/RefCell
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/console/helper')
12 files changed, 98 insertions, 102 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs index d3731b1b..6fcbce8e 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs @@ -4,8 +4,6 @@ use crate::symfony::console::helper::helper::Helper; use crate::symfony::console::helper::helper_interface::HelperInterface; use crate::symfony::console::helper::helper_set::HelperSet; use indexmap::IndexMap; -use std::cell::RefCell; -use std::rc::Rc; const COLORS: [&str; 9] = [ "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "default", @@ -163,11 +161,11 @@ impl DebugFormatterHelper { } impl HelperInterface for DebugFormatterHelper { - fn set_helper_set(&mut self, helper_set: Option<Rc<RefCell<HelperSet>>>) { + fn set_helper_set(&mut self, helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>) { self.inner.set_helper_set(helper_set); } - fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>> { + fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>> { self.inner.get_helper_set() } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/descriptor_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/descriptor_helper.rs index 83e946ca..d422f99f 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/descriptor_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/descriptor_helper.rs @@ -13,8 +13,6 @@ use crate::symfony::console::helper::helper_interface::HelperInterface; use crate::symfony::console::helper::helper_set::HelperSet; use crate::symfony::console::output::output_interface::OutputInterface; use indexmap::IndexMap; -use std::cell::RefCell; -use std::rc::Rc; /// This class adds helper method to describe objects in various formats. #[derive(Default)] @@ -113,11 +111,11 @@ impl DescriptorHelper { } impl HelperInterface for DescriptorHelper { - fn set_helper_set(&mut self, helper_set: Option<Rc<RefCell<HelperSet>>>) { + fn set_helper_set(&mut self, helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>) { self.inner.set_helper_set(helper_set); } - fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>> { + fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>> { self.inner.get_helper_set() } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs index e26915e3..056a2ffe 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs @@ -4,8 +4,6 @@ use crate::symfony::console::formatter::output_formatter::OutputFormatter; use crate::symfony::console::helper::helper::Helper; use crate::symfony::console::helper::helper_interface::HelperInterface; use crate::symfony::console::helper::helper_set::HelperSet; -use std::cell::RefCell; -use std::rc::Rc; /// The Formatter class provides helpers to format messages. #[derive(Debug, Default)] @@ -80,11 +78,11 @@ impl FormatterHelper { } impl HelperInterface for FormatterHelper { - fn set_helper_set(&mut self, helper_set: Option<Rc<RefCell<HelperSet>>>) { + fn set_helper_set(&mut self, helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>) { self.inner.set_helper_set(helper_set); } - fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>> { + fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>> { self.inner.get_helper_set() } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/helper.rs index 64256591..be5eb050 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/helper.rs @@ -3,21 +3,22 @@ use crate::symfony::console::formatter::output_formatter_interface::OutputFormatterInterface; use crate::symfony::console::helper::helper_set::HelperSet; use crate::symfony::string::unicode_string::UnicodeString; -use std::cell::RefCell; -use std::rc::Rc; /// Helper is the base class for all helper classes. #[derive(Debug, Default)] pub struct Helper { - pub(crate) helper_set: Option<Rc<RefCell<HelperSet>>>, + pub(crate) helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>, } impl Helper { - pub fn set_helper_set(&mut self, helper_set: Option<Rc<RefCell<HelperSet>>>) { + pub fn set_helper_set( + &mut self, + helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>, + ) { self.helper_set = helper_set; } - pub fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>> { + pub fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>> { self.helper_set.clone() } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/helper_interface.rs b/crates/shirabe-external-packages/src/symfony/console/helper/helper_interface.rs index 4d767bfe..8dae6c85 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/helper_interface.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/helper_interface.rs @@ -1,16 +1,14 @@ //! ref: composer/vendor/symfony/console/Helper/HelperInterface.php use crate::symfony::console::helper::helper_set::HelperSet; -use std::cell::RefCell; -use std::rc::Rc; /// HelperInterface is the interface all helpers must implement. pub trait HelperInterface: std::fmt::Debug + shirabe_php_shim::AsAny { /// Sets the helper set associated with this helper. - fn set_helper_set(&mut self, helper_set: Option<Rc<RefCell<HelperSet>>>); + fn set_helper_set(&mut self, helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>); /// Gets the helper set associated with this helper. - fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>>; + fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>; /// Returns the canonical name of this helper. fn get_name(&self) -> String; diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/helper_set.rs b/crates/shirabe-external-packages/src/symfony/console/helper/helper_set.rs index d72b6277..b505fedf 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/helper_set.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/helper_set.rs @@ -5,8 +5,6 @@ use crate::symfony::console::helper::formatter_helper::FormatterHelper; use crate::symfony::console::helper::helper_interface::HelperInterface; use crate::symfony::console::helper::process_helper::ProcessHelper; use crate::symfony::console::helper::question_helper::QuestionHelper; -use std::cell::RefCell; -use std::rc::Rc; /// HelperSet represents a set of helpers to be used with a command. /// @@ -20,22 +18,24 @@ use std::rc::Rc; /// lookup) is deferred until the plugin API is implemented. #[derive(Debug)] pub struct HelperSet { - formatter_helper: Rc<RefCell<FormatterHelper>>, - debug_formatter_helper: Rc<RefCell<DebugFormatterHelper>>, - process_helper: Rc<RefCell<ProcessHelper>>, - question_helper: Rc<RefCell<QuestionHelper>>, + formatter_helper: std::rc::Rc<std::cell::RefCell<FormatterHelper>>, + debug_formatter_helper: std::rc::Rc<std::cell::RefCell<DebugFormatterHelper>>, + process_helper: std::rc::Rc<std::cell::RefCell<ProcessHelper>>, + question_helper: std::rc::Rc<std::cell::RefCell<QuestionHelper>>, } impl HelperSet { /// Builds the fixed set of helpers and wires each one's back-reference to the owning set, /// mirroring the `$helper->setHelperSet($this)` call PHP's `HelperSet::set()` performs. - pub fn new() -> Rc<RefCell<HelperSet>> { - let formatter_helper = Rc::new(RefCell::new(FormatterHelper::default())); - let debug_formatter_helper = Rc::new(RefCell::new(DebugFormatterHelper::default())); - let process_helper = Rc::new(RefCell::new(ProcessHelper::default())); - let question_helper = Rc::new(RefCell::new(QuestionHelper::default())); + pub fn new() -> std::rc::Rc<std::cell::RefCell<HelperSet>> { + let formatter_helper = + std::rc::Rc::new(std::cell::RefCell::new(FormatterHelper::default())); + let debug_formatter_helper = + std::rc::Rc::new(std::cell::RefCell::new(DebugFormatterHelper::default())); + let process_helper = std::rc::Rc::new(std::cell::RefCell::new(ProcessHelper::default())); + let question_helper = std::rc::Rc::new(std::cell::RefCell::new(QuestionHelper::default())); - let this = Rc::new(RefCell::new(HelperSet { + let this = std::rc::Rc::new(std::cell::RefCell::new(HelperSet { formatter_helper: formatter_helper.clone(), debug_formatter_helper: debug_formatter_helper.clone(), process_helper: process_helper.clone(), @@ -58,19 +58,19 @@ impl HelperSet { this } - pub fn get_formatter(&self) -> Rc<RefCell<FormatterHelper>> { + pub fn get_formatter(&self) -> std::rc::Rc<std::cell::RefCell<FormatterHelper>> { self.formatter_helper.clone() } - pub fn get_debug_formatter(&self) -> Rc<RefCell<DebugFormatterHelper>> { + pub fn get_debug_formatter(&self) -> std::rc::Rc<std::cell::RefCell<DebugFormatterHelper>> { self.debug_formatter_helper.clone() } - pub fn get_process(&self) -> Rc<RefCell<ProcessHelper>> { + pub fn get_process(&self) -> std::rc::Rc<std::cell::RefCell<ProcessHelper>> { self.process_helper.clone() } - pub fn get_question(&self) -> Rc<RefCell<QuestionHelper>> { + pub fn get_question(&self) -> std::rc::Rc<std::cell::RefCell<QuestionHelper>> { self.question_helper.clone() } } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs index 28e2329a..58d1ea3f 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs @@ -8,8 +8,6 @@ use crate::symfony::console::output::ConsoleOutputInterface; use crate::symfony::console::output::output_interface::{self, OutputInterface}; use crate::symfony::process::exception::process_failed_exception::ProcessFailedException; use crate::symfony::process::process::Process; -use std::cell::RefCell; -use std::rc::Rc; /// The ProcessHelper class provides helpers to run external processes. /// @@ -41,7 +39,7 @@ impl ProcessHelper { /// output available on STDOUT or STDERR pub fn run( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, cmd: ProcessHelperCmd, error: Option<&str>, callback: Option<Box<dyn FnMut(&str, &str)>>, @@ -54,14 +52,14 @@ impl ProcessHelper { // $output->getErrorOutput(); }`. ConsoleOutput is the only OutputInterface // implementor that also implements ConsoleOutputInterface, so the check // reduces to a downcast to the concrete type. - let output: Rc<RefCell<dyn OutputInterface>> = { + let output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>> = { let redirected = shirabe_php_shim::AsAny::as_any(&*output.borrow()) .downcast_ref::<crate::symfony::console::output::console_output::ConsoleOutput>() .map(|console| console.get_error_output()); redirected.unwrap_or(output) }; - let formatter: Rc<RefCell<DebugFormatterHelper>> = self + let formatter: std::rc::Rc<std::cell::RefCell<DebugFormatterHelper>> = self .get_helper_set() .unwrap() .borrow() @@ -200,7 +198,7 @@ impl ProcessHelper { /// @see run() pub fn must_run( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, cmd: ProcessHelperCmd, error: Option<&str>, callback: Option<Box<dyn FnMut(&str, &str)>>, @@ -223,7 +221,7 @@ impl ProcessHelper { /// Wraps a Process callback to add debugging output. pub fn wrap_callback( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, process: &Process, mut callback: Option<Box<dyn FnMut(&str, &str)>>, ) -> Box<dyn FnMut(&str, &str)> { @@ -231,14 +229,14 @@ impl ProcessHelper { // $output->getErrorOutput(); }`. ConsoleOutput is the only OutputInterface // implementor that also implements ConsoleOutputInterface, so the check // reduces to a downcast to the concrete type. - let output: Rc<RefCell<dyn OutputInterface>> = { + let output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>> = { let redirected = shirabe_php_shim::AsAny::as_any(&*output.borrow()) .downcast_ref::<crate::symfony::console::output::console_output::ConsoleOutput>() .map(|console| console.get_error_output()); redirected.unwrap_or(output) }; - let formatter: Rc<RefCell<DebugFormatterHelper>> = self + let formatter: std::rc::Rc<std::cell::RefCell<DebugFormatterHelper>> = self .get_helper_set() .unwrap() .borrow() @@ -272,7 +270,7 @@ impl ProcessHelper { } fn formatter_start( - formatter: &Rc<RefCell<DebugFormatterHelper>>, + formatter: &std::rc::Rc<std::cell::RefCell<DebugFormatterHelper>>, id: &str, message: &str, ) -> String { @@ -280,7 +278,7 @@ impl ProcessHelper { } fn formatter_stop( - formatter: &Rc<RefCell<DebugFormatterHelper>>, + formatter: &std::rc::Rc<std::cell::RefCell<DebugFormatterHelper>>, id: &str, message: &str, successful: bool, @@ -289,7 +287,7 @@ impl ProcessHelper { } fn formatter_progress( - formatter: &Rc<RefCell<DebugFormatterHelper>>, + formatter: &std::rc::Rc<std::cell::RefCell<DebugFormatterHelper>>, id: &str, buffer: &str, error: bool, @@ -301,11 +299,11 @@ impl ProcessHelper { } impl HelperInterface for ProcessHelper { - fn set_helper_set(&mut self, helper_set: Option<Rc<RefCell<HelperSet>>>) { + fn set_helper_set(&mut self, helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>) { self.inner.set_helper_set(helper_set); } - fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>> { + fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>> { self.inner.get_helper_set() } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs b/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs index a18e62f5..0abee1e7 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs @@ -9,8 +9,6 @@ use crate::symfony::console::output::OutputInterface; use crate::symfony::console::output::output_interface; use crate::symfony::console::terminal::Terminal; use indexmap::IndexMap; -use std::cell::RefCell; -use std::rc::Rc; pub const FORMAT_VERBOSE: &str = "verbose"; pub const FORMAT_VERY_VERBOSE: &str = "very_verbose"; @@ -26,7 +24,7 @@ const FORMAT_NORMAL_NOMAX: &str = "normal_nomax"; pub type PlaceholderFormatter = Box< dyn Fn( &ProgressBar, - &Rc<RefCell<dyn OutputInterface>>, + &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<Result<shirabe_php_shim::PhpMixed, LogicException>>, >; @@ -44,7 +42,7 @@ pub struct ProgressBar { last_write_time: f64, min_seconds_between_redraws: f64, max_seconds_between_redraws: f64, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, step: i64, max: i64, start_time: i64, @@ -58,14 +56,14 @@ pub struct ProgressBar { } thread_local! { - static FORMATTERS: RefCell<Option<IndexMap<String, PlaceholderFormatter>>> = const { RefCell::new(None) }; - static FORMATS: RefCell<Option<IndexMap<String, String>>> = const { RefCell::new(None) }; + static FORMATTERS: std::cell::RefCell<Option<IndexMap<String, PlaceholderFormatter>>> = const { std::cell::RefCell::new(None) }; + static FORMATS: std::cell::RefCell<Option<IndexMap<String, String>>> = const { std::cell::RefCell::new(None) }; } impl ProgressBar { /// `$max` Maximum steps (0 if unknown) pub fn new( - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, max: i64, min_seconds_between_redraws: f64, ) -> Self { @@ -73,7 +71,7 @@ impl ProgressBar { // $output->getErrorOutput(); }`. ConsoleOutput is the only OutputInterface // implementor that also implements ConsoleOutputInterface, so the check // reduces to a downcast to the concrete type. - let output: Rc<RefCell<dyn OutputInterface>> = { + let output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>> = { let redirected = shirabe_php_shim::AsAny::as_any(&*output.borrow()) .downcast_ref::<crate::symfony::console::output::console_output::ConsoleOutput>() .map(|console| console.get_error_output()); @@ -596,7 +594,8 @@ impl ProgressBar { formatters.insert( "bar".to_string(), Box::new( - |bar: &ProgressBar, output: &Rc<RefCell<dyn OutputInterface>>| { + |bar: &ProgressBar, + output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>| { let complete_bars = bar.get_bar_offset(); let mut display = shirabe_php_shim::str_repeat( &bar.get_bar_character(), @@ -627,7 +626,8 @@ impl ProgressBar { formatters.insert( "elapsed".to_string(), Box::new( - |bar: &ProgressBar, _output: &Rc<RefCell<dyn OutputInterface>>| { + |bar: &ProgressBar, + _output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>| { Ok(Ok(shirabe_php_shim::PhpMixed::String( Helper::format_time( (shirabe_php_shim::time() - bar.get_start_time()) as f64, @@ -640,7 +640,7 @@ impl ProgressBar { formatters.insert( "remaining".to_string(), - Box::new(|bar: &ProgressBar, _output: &Rc<RefCell<dyn OutputInterface>>| { + Box::new(|bar: &ProgressBar, _output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>| { if bar.get_max_steps() == 0 { return Ok(Err(LogicException(shirabe_php_shim::LogicException { message: "Unable to display the remaining time if the maximum number of steps is not set.".to_string(), @@ -656,7 +656,7 @@ impl ProgressBar { formatters.insert( "estimated".to_string(), - Box::new(|bar: &ProgressBar, _output: &Rc<RefCell<dyn OutputInterface>>| { + Box::new(|bar: &ProgressBar, _output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>| { if bar.get_max_steps() == 0 { return Ok(Err(LogicException(shirabe_php_shim::LogicException { message: "Unable to display the estimated time if the maximum number of steps is not set.".to_string(), @@ -673,7 +673,8 @@ impl ProgressBar { formatters.insert( "memory".to_string(), Box::new( - |_bar: &ProgressBar, _output: &Rc<RefCell<dyn OutputInterface>>| { + |_bar: &ProgressBar, + _output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>| { Ok(Ok(shirabe_php_shim::PhpMixed::String( Helper::format_memory(shirabe_php_shim::memory_get_usage()), ))) @@ -684,7 +685,8 @@ impl ProgressBar { formatters.insert( "current".to_string(), Box::new( - |bar: &ProgressBar, _output: &Rc<RefCell<dyn OutputInterface>>| { + |bar: &ProgressBar, + _output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>| { Ok(Ok(shirabe_php_shim::PhpMixed::String( shirabe_php_shim::str_pad( &bar.get_progress().to_string(), @@ -700,7 +702,8 @@ impl ProgressBar { formatters.insert( "max".to_string(), Box::new( - |bar: &ProgressBar, _output: &Rc<RefCell<dyn OutputInterface>>| { + |bar: &ProgressBar, + _output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>| { Ok(Ok(shirabe_php_shim::PhpMixed::Int(bar.get_max_steps()))) }, ), @@ -709,7 +712,8 @@ impl ProgressBar { formatters.insert( "percent".to_string(), Box::new( - |bar: &ProgressBar, _output: &Rc<RefCell<dyn OutputInterface>>| { + |bar: &ProgressBar, + _output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>| { Ok(Ok(shirabe_php_shim::PhpMixed::Float( (bar.get_progress_percent() * 100.0).floor(), ))) 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 b6d096aa..3f95f4da 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 @@ -20,8 +20,6 @@ use crate::symfony::console::question::QuestionInterface; use crate::symfony::console::terminal::Terminal; use crate::symfony::string::s; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; /// The QuestionHelper class provides helpers to interact with the user. #[derive(Debug, Default)] @@ -46,7 +44,7 @@ impl QuestionHelper { pub fn ask( &mut self, input: &mut dyn InputInterface, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, question: &impl QuestionInterface, ) -> anyhow::Result<Result<PhpMixed, MissingInputException>> { let mut output = output; @@ -73,12 +71,12 @@ impl QuestionHelper { let result: anyhow::Result<Result<PhpMixed, MissingInputException>> = (|| { if question.get_validator().is_none() { - return self.do_ask(Rc::clone(&output), question); + return self.do_ask(std::rc::Rc::clone(&output), question); } - let interviewer = || self.do_ask(Rc::clone(&output), question); + let interviewer = || self.do_ask(std::rc::Rc::clone(&output), question); - self.validate_attempts(&interviewer, Rc::clone(&output), question) + self.validate_attempts(&interviewer, std::rc::Rc::clone(&output), question) })(); let result = result?; @@ -113,10 +111,10 @@ impl QuestionHelper { /// @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden fn do_ask( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, question: &impl QuestionInterface, ) -> anyhow::Result<Result<PhpMixed, MissingInputException>> { - self.write_prompt(Rc::clone(&output), question); + self.write_prompt(std::rc::Rc::clone(&output), question); let input_stream = self .input_stream @@ -134,8 +132,12 @@ impl QuestionHelper { // The autocompleter callback yields an iterable (Option here); PHP // treats a null result as an empty list of suggestions. let callback = move |input: &str| callback(input).unwrap_or_default(); - let autocomplete = - self.autocomplete(Rc::clone(&output), question, &input_stream, &callback); + let autocomplete = self.autocomplete( + std::rc::Rc::clone(&output), + question, + &input_stream, + &callback, + ); ret = PhpMixed::String(if question.is_trimmable() { shirabe_php_shim::trim(&autocomplete, None) } else { @@ -145,7 +147,7 @@ impl QuestionHelper { let mut r: PhpMixed = PhpMixed::Bool(false); if question.is_hidden() { match self.get_hidden_response( - Rc::clone(&output), + std::rc::Rc::clone(&output), &input_stream, question.is_trimmable(), )? { @@ -261,7 +263,7 @@ impl QuestionHelper { /// Outputs the question prompt. pub(crate) fn write_prompt( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, question: &impl QuestionInterface, ) { let mut message = question.get_question().to_string(); @@ -313,7 +315,7 @@ impl QuestionHelper { /// Outputs an error message. pub(crate) fn write_error( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, error: &shirabe_php_shim::Exception, ) { let message = if let Some(helper_set) = self.get_helper_set() { @@ -338,12 +340,12 @@ impl QuestionHelper { /// @param resource $inputStream fn autocomplete( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, question: &impl QuestionInterface, input_stream: &shirabe_php_shim::PhpResource, autocomplete: &dyn Fn(&str) -> Vec<PhpMixed>, ) -> String { - let cursor = Cursor::new(Rc::clone(&output), Some(input_stream.clone())); + let cursor = Cursor::new(std::rc::Rc::clone(&output), Some(input_stream.clone())); let mut full_choice = String::new(); let mut ret = String::new(); @@ -594,7 +596,7 @@ impl QuestionHelper { /// @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden fn get_hidden_response( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, input_stream: &shirabe_php_shim::PhpResource, trimmable: bool, ) -> anyhow::Result<Result<String, RuntimeException>> { @@ -679,7 +681,7 @@ impl QuestionHelper { fn validate_attempts( &self, interviewer: &dyn Fn() -> anyhow::Result<Result<PhpMixed, MissingInputException>>, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, question: &impl QuestionInterface, ) -> anyhow::Result<Result<PhpMixed, MissingInputException>> { let mut error: Option<shirabe_php_shim::Exception> = None; @@ -694,7 +696,7 @@ impl QuestionHelper { } if let Some(ref error) = error { - self.write_error(Rc::clone(&output), error); + self.write_error(std::rc::Rc::clone(&output), error); } let interviewed = match interviewer()? { @@ -876,11 +878,11 @@ fn magic_file() -> String { } impl HelperInterface for QuestionHelper { - fn set_helper_set(&mut self, helper_set: Option<Rc<RefCell<HelperSet>>>) { + fn set_helper_set(&mut self, helper_set: Option<std::rc::Rc<std::cell::RefCell<HelperSet>>>) { self.inner.set_helper_set(helper_set); } - fn get_helper_set(&self) -> Option<Rc<RefCell<HelperSet>>> { + fn get_helper_set(&self) -> Option<std::rc::Rc<std::cell::RefCell<HelperSet>>> { self.inner.get_helper_set() } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs index a5118f4e..786141e9 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs @@ -7,9 +7,7 @@ use crate::symfony::console::output::output_interface::OutputInterface; use crate::symfony::console::question::QuestionInterface; use crate::symfony::console::style::symfony_style::SymfonyStyle; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; use std::ops::{Deref, DerefMut}; -use std::rc::Rc; /// Symfony Style Guide compliant question helper. #[derive(Debug, Default)] @@ -24,7 +22,7 @@ impl SymfonyQuestionHelper { pub(crate) fn write_prompt( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, question: &impl QuestionInterface, ) { let mut text = OutputFormatter::escape_trailing_backslash(question.get_question()); @@ -112,7 +110,7 @@ impl SymfonyQuestionHelper { pub(crate) fn write_error( &self, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, error: &shirabe_php_shim::Exception, ) { let is_symfony_style = { diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs index 04d5f1f6..cae3f896 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs @@ -15,8 +15,6 @@ use crate::symfony::console::output::console_section_output::ConsoleSectionOutpu use crate::symfony::console::output::output_interface::OutputInterface; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; /// A single cell within a table row. /// @@ -58,7 +56,7 @@ impl Cell { } } - fn style(&self) -> Option<Rc<TableCellStyle>> { + fn style(&self) -> Option<std::rc::Rc<TableCellStyle>> { match self { Cell::Cell(c) => c.get_style(), Cell::Separator(s) => s.get_style(), @@ -246,7 +244,7 @@ pub struct Table { /// Number of columns cache. number_of_columns: Option<i64>, - output: Rc<RefCell<dyn OutputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, style: TableStyle, @@ -276,7 +274,7 @@ fn styles() -> &'static std::sync::Mutex<Option<IndexMap<String, TableStyle>>> { } impl Table { - pub fn new(output: Rc<RefCell<dyn OutputInterface>>) -> Self { + pub fn new(output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>) -> Self { let mut styles_guard = styles().lock().unwrap(); if styles_guard.is_none() { *styles_guard = Some(Self::init_styles()); @@ -1383,7 +1381,9 @@ impl Table { ))) } - fn formatter_is_wrappable(_output: &Rc<RefCell<dyn OutputInterface>>) -> bool { + fn formatter_is_wrappable( + _output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, + ) -> bool { // PHP: $this->output->getFormatter() instanceof WrappableOutputFormatterInterface // TODO(phase-c/d): instanceof on `dyn OutputFormatterInterface` needs an AsAny supertrait // on OutputFormatterInterface to downcast to the concrete wrappable formatter; adding it @@ -1399,7 +1399,9 @@ impl Table { Helper::remove_decoration(&mut *formatter, string) } - fn output_is_console_section(output: &Rc<RefCell<dyn OutputInterface>>) -> bool { + fn output_is_console_section( + output: &std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, + ) -> bool { // PHP: $this->output instanceof ConsoleSectionOutput let borrowed = output.borrow(); (*borrowed) @@ -1417,7 +1419,7 @@ impl Table { fn table_cell_options_colspan_style( colspan: i64, - style: Option<Rc<TableCellStyle>>, + style: Option<std::rc::Rc<TableCellStyle>>, ) -> IndexMap<String, TableCellOption> { // PHP: ['colspan' => $colspan, 'style' => $style] let mut options = IndexMap::new(); diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs b/crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs index b85b7d1d..2b1e592b 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/table_cell.rs @@ -3,13 +3,12 @@ use crate::symfony::console::exception::invalid_argument_exception::InvalidArgumentException; use crate::symfony::console::helper::table_cell_style::TableCellStyle; use indexmap::IndexMap; -use std::rc::Rc; /// A `TableCell` option value: an integer span, a `TableCellStyle`, or null. #[derive(Debug, Clone)] pub enum TableCellOption { Int(i64), - Style(Rc<TableCellStyle>), + Style(std::rc::Rc<TableCellStyle>), Null, } @@ -94,7 +93,7 @@ impl TableCell { } } - pub fn get_style(&self) -> Option<Rc<TableCellStyle>> { + pub fn get_style(&self) -> Option<std::rc::Rc<TableCellStyle>> { match &self.options["style"] { TableCellOption::Style(style) => Some(style.clone()), _ => None, |
