diff options
Diffstat (limited to 'crates/shirabe/src')
58 files changed, 375 insertions, 413 deletions
diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs index 402483c7..32e34380 100644 --- a/crates/shirabe/src/advisory/auditor.rs +++ b/crates/shirabe/src/advisory/auditor.rs @@ -18,8 +18,6 @@ use shirabe_php_shim::{ DATE_ATOM, InvalidArgumentException, PhpMixed, array_all, array_any, array_key_exists, array_keys, array_reduce, get_class, sprintf, str_starts_with, }; -use std::cell::RefCell; -use std::rc::Rc; /// Shape of the `--format=json` audit output. #[derive(serde::Serialize)] @@ -115,7 +113,7 @@ impl Auditor { #[allow(clippy::too_many_arguments, reason = "to keep PHP signature")] pub fn audit( &self, - io: &Rc<RefCell<dyn IOInterface>>, + io: &std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, repo_set: &RepositorySet, packages: Vec<PackageInterfaceHandle>, format: &str, @@ -428,7 +426,7 @@ impl Auditor { /// @param self::FORMAT_* $format The format that will be used to output audit results. fn output_advisories( &self, - io: &Rc<RefCell<dyn IOInterface>>, + io: &std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, advisories: &IndexMap<String, Vec<AnySecurityAdvisory>>, format: &str, ) -> anyhow::Result<()> { @@ -528,7 +526,7 @@ impl Auditor { /// @param array<string, array<SecurityAdvisory>> $advisories fn output_advisories_plain( &self, - io: &Rc<RefCell<dyn IOInterface>>, + io: &std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, advisories: &IndexMap<String, Vec<AnySecurityAdvisory>>, ) -> anyhow::Result<()> { let mut error: Vec<String> = vec![]; @@ -575,7 +573,7 @@ impl Auditor { /// @param self::FORMAT_PLAIN|self::FORMAT_TABLE $format fn output_abandoned_packages( &self, - io: &Rc<RefCell<dyn IOInterface>>, + io: &std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, packages: &[CompletePackageInterfaceHandle], format: &str, ) -> anyhow::Result<()> { diff --git a/crates/shirabe/src/command/about_command.rs b/crates/shirabe/src/command/about_command.rs index 7983a580..386beebb 100644 --- a/crates/shirabe/src/command/about_command.rs +++ b/crates/shirabe/src/command/about_command.rs @@ -7,8 +7,6 @@ use crate::composer; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct AboutCommand { @@ -43,8 +41,8 @@ impl Command for AboutCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer_version = composer::get_version(); let _ = (input, output); @@ -60,8 +58,8 @@ impl Command for AboutCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs index 741847a7..2a099c89 100644 --- a/crates/shirabe/src/command/archive_command.rs +++ b/crates/shirabe/src/command/archive_command.rs @@ -28,14 +28,12 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{LogicException, get_debug_type}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct ArchiveCommand { base_command_data: BaseCommandData, /// For testing only: partial-mock seam mirroring PHPUnit `onlyMethods(['initialize', 'archive'])`. - test_hooks: RefCell<ArchiveCommandTestHooks>, + test_hooks: std::cell::RefCell<ArchiveCommandTestHooks>, } /// For testing only: records and stubs for the `ArchiveCommand` partial-mock seam. @@ -70,7 +68,7 @@ impl ArchiveCommand { pub fn new() -> Self { let command = ArchiveCommand { base_command_data: BaseCommandData::new(None), - test_hooks: RefCell::new(ArchiveCommandTestHooks::default()), + test_hooks: std::cell::RefCell::new(ArchiveCommandTestHooks::default()), }; command .configure() @@ -104,8 +102,8 @@ impl Command for ArchiveCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.try_composer(None, None); @@ -206,8 +204,8 @@ impl Command for ArchiveCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { if self.test_hooks.borrow().skip_initialize { return Ok(()); diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs index 236ecdc0..fb56169e 100644 --- a/crates/shirabe/src/command/audit_command.rs +++ b/crates/shirabe/src/command/audit_command.rs @@ -19,8 +19,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, UnexpectedValueException, implode, in_array, }; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct AuditCommand { @@ -116,8 +114,8 @@ impl Command for AuditCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.require_composer(None, None)?; let packages = self.get_packages(&composer, input.clone())?; @@ -220,8 +218,8 @@ impl Command for AuditCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs index 33864964..b80cb2b4 100644 --- a/crates/shirabe/src/command/base_command.rs +++ b/crates/shirabe/src/command/base_command.rs @@ -30,8 +30,6 @@ use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, UnexpectedValueException, count, explode, in_array, is_string, }; -use std::cell::RefCell; -use std::rc::Rc; pub const SUCCESS: i64 = 0; pub const FAILURE: i64 = 1; @@ -42,16 +40,16 @@ pub const INVALID: i64 = 2; #[derive(Debug)] pub struct BaseCommandData { inner: CommandData, - pub(crate) composer: RefCell<Option<PartialComposerHandle>>, - pub(crate) io: RefCell<Option<Rc<RefCell<dyn IOInterface>>>>, + pub(crate) composer: std::cell::RefCell<Option<PartialComposerHandle>>, + pub(crate) io: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>>, } impl BaseCommandData { pub fn new(name: Option<String>) -> Self { BaseCommandData { inner: CommandData::new(name), - composer: RefCell::new(None), - io: RefCell::new(None), + composer: std::cell::RefCell::new(None), + io: std::cell::RefCell::new(None), } } @@ -152,15 +150,15 @@ pub trait BaseCommand: Command { /// Removes the cached composer instance fn reset_composer(&self) -> anyhow::Result<()>; - fn get_io(&self) -> Rc<RefCell<dyn IOInterface>>; + fn get_io(&self) -> std::rc::Rc<std::cell::RefCell<dyn IOInterface>>; - fn set_io(&self, io: Rc<RefCell<dyn IOInterface>>); + fn set_io(&self, io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>); /// Calls {@see Factory::create()} with the given arguments, taking into account flags and default states for disabling scripts and plugins fn create_composer_instance( &self, - input: Rc<RefCell<dyn InputInterface>>, - io: Rc<RefCell<dyn IOInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: Option<IndexMap<String, PhpMixed>>, disable_plugins: bool, disable_scripts: Option<bool>, @@ -170,14 +168,14 @@ pub trait BaseCommand: Command { fn get_preferred_install_options( &self, config: &Config, - input: Rc<RefCell<dyn InputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, keep_vcs_requires_prefer_source: bool, ) -> anyhow::Result<(bool, bool)>; fn get_platform_requirement_filter( &self, - input: Rc<RefCell<dyn InputInterface>>, - ) -> anyhow::Result<Rc<dyn PlatformRequirementFilterInterface>>; + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + ) -> anyhow::Result<std::rc::Rc<dyn PlatformRequirementFilterInterface>>; /// @param array<string> $requirements /// @@ -196,7 +194,11 @@ pub trait BaseCommand: Command { ) -> anyhow::Result<Vec<IndexMap<String, String>>>; /// @param array<TableSeparator|mixed[]> $table - fn render_table(&self, table: Vec<PhpMixed>, output: Rc<RefCell<dyn OutputInterface>>); + fn render_table( + &self, + table: Vec<PhpMixed>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, + ); fn get_terminal_width(&self) -> i64; @@ -205,7 +207,7 @@ pub trait BaseCommand: Command { /// @return Auditor::FORMAT_* fn get_audit_format( &self, - input: Rc<RefCell<dyn InputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, opt_name: &str, ) -> anyhow::Result<String>; @@ -213,7 +215,7 @@ pub trait BaseCommand: Command { fn create_audit_config( &self, config: &mut Config, - input: Rc<RefCell<dyn InputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, ) -> anyhow::Result<AuditConfig>; } @@ -327,7 +329,7 @@ impl BaseCommand for BaseCommandData { Ok(()) } - fn get_io(&self) -> Rc<RefCell<dyn IOInterface>> { + fn get_io(&self) -> std::rc::Rc<std::cell::RefCell<dyn IOInterface>> { if self.io.borrow().is_none() { match self.get_application() { Some(application) => { @@ -343,7 +345,8 @@ impl BaseCommand for BaseCommandData { *self.io.borrow_mut() = Some(io); } None => { - *self.io.borrow_mut() = Some(Rc::new(RefCell::new(NullIO::new()))); + *self.io.borrow_mut() = + Some(std::rc::Rc::new(std::cell::RefCell::new(NullIO::new()))); } } } @@ -351,14 +354,14 @@ impl BaseCommand for BaseCommandData { self.io.borrow().clone().unwrap() } - fn set_io(&self, io: Rc<RefCell<dyn IOInterface>>) { + fn set_io(&self, io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>) { *self.io.borrow_mut() = Some(io); } fn create_composer_instance( &self, - input: Rc<RefCell<dyn InputInterface>>, - io: Rc<RefCell<dyn IOInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, config: Option<IndexMap<String, PhpMixed>>, disable_plugins: bool, disable_scripts: Option<bool>, @@ -387,7 +390,7 @@ impl BaseCommand for BaseCommandData { fn get_preferred_install_options( &self, config: &Config, - input: Rc<RefCell<dyn InputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, keep_vcs_requires_prefer_source: bool, ) -> anyhow::Result<(bool, bool)> { let mut prefer_source = false; @@ -510,8 +513,8 @@ impl BaseCommand for BaseCommandData { fn get_platform_requirement_filter( &self, - input: Rc<RefCell<dyn InputInterface>>, - ) -> anyhow::Result<Rc<dyn PlatformRequirementFilterInterface>> { + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + ) -> anyhow::Result<std::rc::Rc<dyn PlatformRequirementFilterInterface>> { if !input.borrow().has_option("ignore-platform-reqs") || !input.borrow().has_option("ignore-platform-req") { @@ -577,7 +580,11 @@ impl BaseCommand for BaseCommandData { parser.parse_name_version_pairs(requirements) } - fn render_table(&self, table: Vec<PhpMixed>, output: Rc<RefCell<dyn OutputInterface>>) { + fn render_table( + &self, + table: Vec<PhpMixed>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, + ) { let mut renderer = Table::new(output); renderer .set_style("compact".into()) @@ -604,7 +611,7 @@ impl BaseCommand for BaseCommandData { fn get_audit_format( &self, - input: Rc<RefCell<dyn InputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, opt_name: &str, ) -> anyhow::Result<String> { if !input.borrow().has_option(opt_name) { @@ -641,7 +648,7 @@ impl BaseCommand for BaseCommandData { fn create_audit_config( &self, config: &mut Config, - input: Rc<RefCell<dyn InputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, ) -> anyhow::Result<AuditConfig> { // Handle both --audit and --no-audit flags let audit = if input.borrow().has_option("audit") { @@ -700,7 +707,11 @@ impl BaseCommand for BaseCommandData { /// (same for `getDisableScriptsByDefault()`), ORed into the caller's flags. fn apply_application_defaults( application: Option< - Rc<RefCell<dyn shirabe_external_packages::symfony::console::application::Application>>, + std::rc::Rc< + std::cell::RefCell< + dyn shirabe_external_packages::symfony::console::application::Application, + >, + >, >, mut disable_plugins: bool, mut disable_scripts: bool, @@ -725,8 +736,8 @@ fn apply_application_defaults( /// future overrides) bind correctly. pub fn base_command_initialize( cmd: &dyn BaseCommand, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { // initialize a plugin-enabled Composer instance, either local or global let disable_plugins = input diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs index e3dac8a2..e6c565c1 100644 --- a/crates/shirabe/src/command/bump_command.rs +++ b/crates/shirabe/src/command/bump_command.rs @@ -20,8 +20,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{PhpMixed, file_get_contents, file_put_contents, is_writable, strtolower}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct BumpCommand { @@ -388,8 +386,8 @@ impl Command for BumpCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let packages_filter: Vec<String> = input .borrow() @@ -430,8 +428,8 @@ impl Command for BumpCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs index 4f53e79a..0f310ea4 100644 --- a/crates/shirabe/src/command/check_platform_reqs_command.rs +++ b/crates/shirabe/src/command/check_platform_reqs_command.rs @@ -17,8 +17,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{PhpMixed, array_merge_map, strip_tags}; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; -use std::cell::RefCell; -use std::rc::Rc; struct CheckResult { platform_package: String, @@ -189,8 +187,8 @@ impl Command for CheckPlatformReqsCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.require_composer(None, None)?; let composer = crate::composer::composer_full(&composer); @@ -394,8 +392,8 @@ impl Command for CheckPlatformReqsCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/clear_cache_command.rs b/crates/shirabe/src/command/clear_cache_command.rs index 2e414125..054ea8b1 100644 --- a/crates/shirabe/src/command/clear_cache_command.rs +++ b/crates/shirabe/src/command/clear_cache_command.rs @@ -12,8 +12,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::realpath; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct ClearCacheCommand { @@ -62,8 +60,8 @@ impl Command for ClearCacheCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.try_composer(None, None); // composer.getConfig() yields an Rc<RefCell<Config>>; Factory::createConfig() an owned @@ -180,8 +178,8 @@ impl Command for ClearCacheCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index 755590f6..4544cb63 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -44,9 +44,7 @@ use shirabe_php_shim::{ UnexpectedValueException, array_pop, chdir, explode_with_limit, file_exists, getcwd, implode, is_dir, is_file, mkdir, realpath, rtrim, strtolower, unlink, }; -use std::cell::RefCell; use std::path::PathBuf; -use std::rc::Rc; /// Install a package as new project into new directory. #[derive(Debug)] @@ -257,8 +255,8 @@ impl Command for CreateProjectCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/depends_command.rs b/crates/shirabe/src/command/depends_command.rs index 00b5abcb..4c6f85b5 100644 --- a/crates/shirabe/src/command/depends_command.rs +++ b/crates/shirabe/src/command/depends_command.rs @@ -9,8 +9,6 @@ use crate::console::input::InputOption; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct DependsCommand { @@ -101,16 +99,16 @@ impl Command for DependsCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { self.do_execute(input, output, false) } fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index 0c50d695..e7fb9c74 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -47,8 +47,6 @@ use shirabe_php_shim::{ is_array, is_string, ob_get_clean, ob_start, phpinfo, rtrim, str_contains, str_replace, str_starts_with, strpos, strstr, strtolower, trim, version_compare, }; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct DiagnoseCommand { @@ -441,8 +439,8 @@ impl Command for DiagnoseCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs index de917b5d..906185b0 100644 --- a/crates/shirabe/src/command/dump_autoload_command.rs +++ b/crates/shirabe/src/command/dump_autoload_command.rs @@ -11,8 +11,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct DumpAutoloadCommand { @@ -64,8 +62,8 @@ impl Command for DumpAutoloadCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.require_composer(None, None)?; let composer = crate::composer::composer_full(&composer); @@ -313,8 +311,8 @@ impl Command for DumpAutoloadCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs index 659b8f75..3eaee5a9 100644 --- a/crates/shirabe/src/command/exec_command.rs +++ b/crates/shirabe/src/command/exec_command.rs @@ -11,8 +11,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{PhpMixed, RuntimeException, basename, chdir, getcwd, glob}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct ExecCommand { @@ -98,8 +96,8 @@ impl Command for ExecCommand { fn interact( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) { let _ = (|| -> anyhow::Result<()> { let binaries = self.get_binaries(false)?; @@ -140,8 +138,8 @@ impl Command for ExecCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.require_composer(None, None)?; @@ -236,8 +234,8 @@ impl Command for ExecCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs index 5c980314..65ae2c94 100644 --- a/crates/shirabe/src/command/fund_command.rs +++ b/crates/shirabe/src/command/fund_command.rs @@ -17,8 +17,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::PhpMixed; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MatchAllConstraint; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct FundCommand { @@ -97,8 +95,8 @@ impl Command for FundCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.require_composer(None, None)?; let composer = crate::composer::composer_full(&composer); @@ -217,8 +215,8 @@ impl Command for FundCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index b0a3542d..a1f5f72e 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -16,9 +16,7 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::input::StringInput; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{LogicException, RuntimeException, chdir}; -use std::cell::RefCell; use std::path::Path; -use std::rc::Rc; #[derive(Debug)] pub struct GlobalCommand { @@ -67,7 +65,7 @@ impl GlobalCommand { fn prepare_subcommand_input( &self, - input: Rc<RefCell<dyn InputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, quiet: bool, ) -> anyhow::Result<StringInput> { if Platform::get_env("COMPOSER").is_some() { @@ -152,8 +150,8 @@ impl Command for GlobalCommand { fn run( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let tokens = Preg::split(r"{\s+}", &Self::input_to_string(&*input.borrow())?); let mut args: Vec<String> = vec![]; @@ -171,7 +169,8 @@ impl Command for GlobalCommand { } let sub_input = self.prepare_subcommand_input(input, false)?; - let sub_input: Rc<RefCell<dyn InputInterface>> = Rc::new(RefCell::new(sub_input)); + let sub_input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(sub_input)); let application = { let application = self @@ -190,8 +189,8 @@ impl Command for GlobalCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/home_command.rs b/crates/shirabe/src/command/home_command.rs index 8ff43f39..5a823d8b 100644 --- a/crates/shirabe/src/command/home_command.rs +++ b/crates/shirabe/src/command/home_command.rs @@ -16,8 +16,6 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::PhpMixed; use shirabe_php_shim::filter_var_url; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct HomeCommand { @@ -178,8 +176,8 @@ impl Command for HomeCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let repos = self.initialize_repos()?; let io = self.get_io().clone(); @@ -256,8 +254,8 @@ impl Command for HomeCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index 4a2e9a3d..f0f07a56 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -31,8 +31,6 @@ use shirabe_php_shim::{ is_string, preg_quote, realpath, str_replace, strpos, strtolower, trim, ucwords, }; use shirabe_spdx_licenses::SpdxLicenses; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct InitCommand { @@ -116,8 +114,8 @@ impl Command for InitCommand { /// @throws \Seld\JsonLint\ParsingException fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let io = self.get_io(); @@ -402,8 +400,8 @@ impl Command for InitCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input.clone(), output.clone())?; @@ -430,8 +428,8 @@ impl Command for InitCommand { fn interact( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) { let _ = (|| -> anyhow::Result<()> { let io = self.get_io(); diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs index 11929689..635c1461 100644 --- a/crates/shirabe/src/command/install_command.rs +++ b/crates/shirabe/src/command/install_command.rs @@ -15,8 +15,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct InstallCommand { @@ -84,8 +82,8 @@ impl Command for InstallCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let io = self.get_io().clone(); @@ -265,8 +263,8 @@ impl Command for InstallCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs index 52f7d2fa..be467a13 100644 --- a/crates/shirabe/src/command/licenses_command.rs +++ b/crates/shirabe/src/command/licenses_command.rs @@ -20,8 +20,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_external_packages::symfony::console::style::StyleInterface; use shirabe_external_packages::symfony::console::style::SymfonyStyle; use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct LicensesCommand { @@ -91,8 +89,8 @@ impl Command for LicensesCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer_handle = self.require_composer(None, None)?; @@ -330,8 +328,8 @@ impl Command for LicensesCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs index 73f191d2..e0892692 100644 --- a/crates/shirabe/src/command/outdated_command.rs +++ b/crates/shirabe/src/command/outdated_command.rs @@ -11,8 +11,6 @@ use shirabe_external_packages::symfony::console::input::ArrayInput; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct OutdatedCommand { @@ -74,8 +72,8 @@ impl Command for OutdatedCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let mut args: IndexMap<String, PhpMixed> = IndexMap::new(); args.insert("command".to_string(), PhpMixed::String("show".to_string())); @@ -206,7 +204,8 @@ impl Command for OutdatedCommand { None, )?; - let input: Rc<RefCell<dyn InputInterface>> = Rc::new(RefCell::new(input)); + let input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(input)); let application = { let application = self @@ -225,8 +224,8 @@ impl Command for OutdatedCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/prohibits_command.rs b/crates/shirabe/src/command/prohibits_command.rs index 9f9b0eea..49c8a19b 100644 --- a/crates/shirabe/src/command/prohibits_command.rs +++ b/crates/shirabe/src/command/prohibits_command.rs @@ -8,8 +8,6 @@ use crate::console::input::InputOption; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct ProhibitsCommand { @@ -108,16 +106,16 @@ impl Command for ProhibitsCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { self.do_execute(input, output, true) } fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs index b28f6168..c2c3ab18 100644 --- a/crates/shirabe/src/command/reinstall_command.rs +++ b/crates/shirabe/src/command/reinstall_command.rs @@ -20,8 +20,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::InvalidArgumentException; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct ReinstallCommand { @@ -79,8 +77,8 @@ impl Command for ReinstallCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.require_composer(None, None)?; let composer = crate::composer::composer_full(&composer); @@ -243,9 +241,9 @@ impl Command for ReinstallCommand { indexmap::IndexMap::new(), ); - let uninstall_operations: Vec<Rc<dyn OperationInterface>> = uninstall_operations + let uninstall_operations: Vec<std::rc::Rc<dyn OperationInterface>> = uninstall_operations .into_iter() - .map(|op| Rc::new(op) as Rc<dyn OperationInterface>) + .map(|op| std::rc::Rc::new(op) as std::rc::Rc<dyn OperationInterface>) .collect(); { let mut local_repo_ref = local_repo.borrow_mut(); @@ -356,8 +354,8 @@ impl Command for ReinstallCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs index aa8f7723..e7686efd 100644 --- a/crates/shirabe/src/command/remove_command.rs +++ b/crates/shirabe/src/command/remove_command.rs @@ -21,8 +21,6 @@ use shirabe_external_packages::symfony::console::exception::InvalidArgumentExcep use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{PhpMixed, UnexpectedValueException, strtolower}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct RemoveCommand { @@ -175,8 +173,8 @@ impl Command for RemoveCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { if input .borrow() @@ -713,8 +711,8 @@ impl Command for RemoveCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs index 89fb84b4..06ecfb4f 100644 --- a/crates/shirabe/src/command/repository_command.rs +++ b/crates/shirabe/src/command/repository_command.rs @@ -17,8 +17,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ InvalidArgumentException, PHP_URL_HOST, PhpMixed, RuntimeException, parse_url, strtolower, }; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct RepositoryCommand { @@ -494,8 +492,8 @@ impl Command for RepositoryCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { <Self as crate::command::base_config_command::BaseConfigCommand>::initialize( self, input, output, diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 952f8d89..219ad3d8 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -40,8 +40,6 @@ use shirabe_php_shim::{ array_merge, array_unique, empty, file_exists, file_get_contents, file_put_contents, filesize, implode, is_writable, strtolower, unlink, }; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct RequireCommand { @@ -633,15 +631,15 @@ impl Command for RequireCommand { fn interact( &self, - _input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + _input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) { } fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs index 7fc9703f..c256eea2 100644 --- a/crates/shirabe/src/command/run_script_command.rs +++ b/crates/shirabe/src/command/run_script_command.rs @@ -18,8 +18,6 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::PhpMixed; use shirabe_php_shim::{InvalidArgumentException, RuntimeException}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct RunScriptCommand { @@ -59,7 +57,10 @@ impl RunScriptCommand { command } - fn list_scripts(&self, output: Rc<RefCell<dyn OutputInterface>>) -> anyhow::Result<i64> { + fn list_scripts( + &self, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, + ) -> anyhow::Result<i64> { let scripts = self.get_scripts()?; if scripts.is_empty() { return Ok(0); @@ -181,8 +182,8 @@ impl Command for RunScriptCommand { fn interact( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) { let _ = (|| -> anyhow::Result<()> { let scripts = self.get_scripts()?; @@ -223,8 +224,8 @@ impl Command for RunScriptCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { if input .borrow() @@ -323,8 +324,8 @@ impl Command for RunScriptCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs index ff1fd3d2..17629162 100644 --- a/crates/shirabe/src/command/script_alias_command.rs +++ b/crates/shirabe/src/command/script_alias_command.rs @@ -11,8 +11,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{InvalidArgumentException, LogicException, PhpMixed, is_string}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct ScriptAliasCommand { @@ -108,8 +106,8 @@ impl Command for ScriptAliasCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.require_composer(None, None)?; let dispatcher = crate::composer::composer_full(&composer) @@ -164,8 +162,8 @@ impl Command for ScriptAliasCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs index 89abddd7..6709613c 100644 --- a/crates/shirabe/src/command/search_command.rs +++ b/crates/shirabe/src/command/search_command.rs @@ -18,8 +18,6 @@ use shirabe_external_packages::symfony::console::formatter::OutputFormatter; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{InvalidArgumentException, PhpMixed, implode, in_array, preg_quote}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct SearchCommand { @@ -104,8 +102,8 @@ impl Command for SearchCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let platform_repo = PlatformRepository::new4(vec![], IndexMap::new(), None, None)?; let io = self.get_io(); @@ -271,8 +269,8 @@ impl Command for SearchCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs index 35a1374b..87efd4b9 100644 --- a/crates/shirabe/src/command/self_update_command.rs +++ b/crates/shirabe/src/command/self_update_command.rs @@ -11,8 +11,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct SelfUpdateCommand { @@ -72,8 +70,8 @@ impl Command for SelfUpdateCommand { /// been published yet. The command is therefore disabled. fn execute( &self, - _input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + _input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let io = self.get_io(); io.write_error3( @@ -87,8 +85,8 @@ impl Command for SelfUpdateCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index 68b42e68..a63e08cf 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -47,8 +47,6 @@ use shirabe_php_shim::{ use shirabe_semver::Semver; use shirabe_semver::constraint::AnyConstraint; use shirabe_spdx_licenses::SpdxLicenses; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct ShowCommand { @@ -209,8 +207,8 @@ impl Command for ShowCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { *self.version_parser.borrow_mut() = VersionParser::new(); if input.borrow().get_option("tree")?.as_bool() == Some(true) { @@ -1443,8 +1441,8 @@ impl Command for ShowCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/status_command.rs b/crates/shirabe/src/command/status_command.rs index 3b3445b6..b527d5aa 100644 --- a/crates/shirabe/src/command/status_command.rs +++ b/crates/shirabe/src/command/status_command.rs @@ -16,8 +16,6 @@ use indexmap::IndexMap; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct StatusCommand { @@ -335,8 +333,8 @@ impl Command for StatusCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer_rc = self.require_composer(None, None)?; { @@ -381,8 +379,8 @@ impl Command for StatusCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/suggests_command.rs b/crates/shirabe/src/command/suggests_command.rs index f7b04142..e42f20ba 100644 --- a/crates/shirabe/src/command/suggests_command.rs +++ b/crates/shirabe/src/command/suggests_command.rs @@ -15,8 +15,6 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{PhpMixed, empty, in_array}; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct SuggestsCommand { @@ -109,8 +107,8 @@ impl Command for SuggestsCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - _output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let composer = self.require_composer(None, None)?; let composer = crate::composer::composer_full(&composer); @@ -215,8 +213,8 @@ impl Command for SuggestsCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index 366cf8bb..0163f6bc 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -35,8 +35,6 @@ use shirabe_php_shim::{ }; use shirabe_semver::Intervals; use shirabe_semver::constraint::MultiConstraint; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct UpdateCommand { @@ -124,8 +122,8 @@ impl Command for UpdateCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let io = self.get_io().clone(); if input.borrow().get_option("dev")?.as_bool().unwrap_or(false) { @@ -572,8 +570,8 @@ impl Command for UpdateCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs index bceaa991..12e28188 100644 --- a/crates/shirabe/src/command/validate_command.rs +++ b/crates/shirabe/src/command/validate_command.rs @@ -16,8 +16,6 @@ use crate::util::Filesystem; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct ValidateCommand { @@ -132,8 +130,8 @@ impl Command for ValidateCommand { fn execute( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { let file = input .borrow() @@ -303,8 +301,8 @@ impl Command for ValidateCommand { fn initialize( &self, - input: Rc<RefCell<dyn InputInterface>>, - output: Rc<RefCell<dyn OutputInterface>>, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<()> { base_command_initialize(self, input, output) } diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs index cac6181e..d1cd4212 100644 --- a/crates/shirabe/src/config.rs +++ b/crates/shirabe/src/config.rs @@ -15,7 +15,6 @@ use shirabe_php_shim::{ is_array, is_string, parse_url, php_to_string, rtrim, strtolower, strtoupper, strtr, substr, trigger_error, }; -use std::cell::RefCell; use crate::advisory::Auditor; use crate::downloader::TransportException; @@ -40,7 +39,7 @@ pub struct Config { warned_hosts: IndexMap<String, bool>, /// @var array<string, true> ssl_verify_warned_hosts: IndexMap<String, bool>, - source_of_config_value: RefCell<IndexMap<String, String>>, + source_of_config_value: std::cell::RefCell<IndexMap<String, String>>, } impl Config { @@ -229,7 +228,7 @@ impl Config { local_auth_config_source: None, warned_hosts: IndexMap::new(), ssl_verify_warned_hosts: IndexMap::new(), - source_of_config_value: RefCell::new(IndexMap::new()), + source_of_config_value: std::cell::RefCell::new(IndexMap::new()), }; let config_clone = this.config.clone(); diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 86639444..a2f36cf4 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -833,7 +833,7 @@ impl Application { return self .shared() .add(todo!( - "Rc<RefCell<dyn SymfonyCommand>> from command_loader.get(name)" + "std::rc::Rc<std::cell::RefCell<dyn SymfonyCommand>> from command_loader.get(name)" )) .map(|c| c.is_some()) .unwrap_or(false); @@ -1052,7 +1052,7 @@ impl Application { command_list.insert( name_or_alias.clone(), todo!( - "Rc<RefCell<dyn SymfonyCommand>> from command_loader.get(name_or_alias)" + "std::rc::Rc<std::cell::RefCell<dyn SymfonyCommand>> from command_loader.get(name_or_alias)" ), ); } diff --git a/crates/shirabe/src/dependency_resolver/default_policy.rs b/crates/shirabe/src/dependency_resolver/default_policy.rs index d56a96c5..e7d02e24 100644 --- a/crates/shirabe/src/dependency_resolver/default_policy.rs +++ b/crates/shirabe/src/dependency_resolver/default_policy.rs @@ -8,7 +8,6 @@ use crate::util::Platform; use indexmap::IndexMap; use shirabe_semver::CompilingMatcher; use shirabe_semver::constraint::SimpleConstraint; -use std::cell::RefCell; #[derive(Debug)] pub struct DefaultPolicy { @@ -16,8 +15,9 @@ pub struct DefaultPolicy { prefer_lowest: bool, prefer_dev_over_prerelease: bool, preferred_versions: Option<IndexMap<String, String>>, - preferred_package_result_cache_per_pool: RefCell<IndexMap<i64, IndexMap<String, Vec<i64>>>>, - sorting_cache_per_pool: RefCell<IndexMap<i64, IndexMap<String, i64>>>, + preferred_package_result_cache_per_pool: + std::cell::RefCell<IndexMap<i64, IndexMap<String, Vec<i64>>>>, + sorting_cache_per_pool: std::cell::RefCell<IndexMap<i64, IndexMap<String, i64>>>, } impl DefaultPolicy { @@ -33,8 +33,8 @@ impl DefaultPolicy { prefer_dev_over_prerelease: Platform::get_env("COMPOSER_PREFER_DEV_OVER_PRERELEASE") .map(|v| !v.is_empty()) .unwrap_or(false), - preferred_package_result_cache_per_pool: RefCell::new(IndexMap::new()), - sorting_cache_per_pool: RefCell::new(IndexMap::new()), + preferred_package_result_cache_per_pool: std::cell::RefCell::new(IndexMap::new()), + sorting_cache_per_pool: std::cell::RefCell::new(IndexMap::new()), } } diff --git a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs index 6238ddbe..789d0aed 100644 --- a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs +++ b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs @@ -12,13 +12,12 @@ use shirabe_semver::Intervals; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MultiConstraint; use shirabe_semver::constraint::SimpleConstraint; -use std::rc::Rc; /// Optimizes a given pool #[derive(Debug)] pub struct PoolOptimizer { /// @var PolicyInterface - policy: Rc<dyn PolicyInterface>, + policy: std::rc::Rc<dyn PolicyInterface>, /// @var array<int, true> irremovable_packages: IndexMap<i64, bool>, @@ -46,7 +45,7 @@ struct IdenticalDefinitionPointers { } impl PoolOptimizer { - pub fn new(policy: Rc<dyn PolicyInterface>) -> Self { + pub fn new(policy: std::rc::Rc<dyn PolicyInterface>) -> Self { Self { policy, irremovable_packages: IndexMap::new(), diff --git a/crates/shirabe/src/dependency_resolver/rule.rs b/crates/shirabe/src/dependency_resolver/rule.rs index ab4eeb0c..e1572b0b 100644 --- a/crates/shirabe/src/dependency_resolver/rule.rs +++ b/crates/shirabe/src/dependency_resolver/rule.rs @@ -18,8 +18,6 @@ use shirabe_php_shim::{ }; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub enum ReasonData { @@ -323,7 +321,7 @@ impl Rule { pool: &mut Pool, is_verbose: bool, installed_map: &IndexMap<String, BasePackageHandle>, - _learned_pool: &Vec<Vec<Rc<RefCell<Rule>>>>, + _learned_pool: &Vec<Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>, ) -> anyhow::Result<String> { let mut literals = self.get_literals(); diff --git a/crates/shirabe/src/dependency_resolver/rule_set.rs b/crates/shirabe/src/dependency_resolver/rule_set.rs index cde4ebca..f7300d93 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set.rs @@ -7,15 +7,13 @@ use crate::dependency_resolver::RuleSetIterator; use crate::repository::RepositorySet; use indexmap::IndexMap; use shirabe_php_shim::OutOfBoundsException; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct RuleSet { - pub rule_by_id: IndexMap<i64, Rc<RefCell<Rule>>>, - pub(crate) rules: IndexMap<i64, Vec<Rc<RefCell<Rule>>>>, + pub rule_by_id: IndexMap<i64, std::rc::Rc<std::cell::RefCell<Rule>>>, + pub(crate) rules: IndexMap<i64, Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>, pub(crate) next_rule_id: i64, - pub(crate) rules_by_hash: IndexMap<String, Vec<Rc<RefCell<Rule>>>>, + pub(crate) rules_by_hash: IndexMap<String, Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>, } impl Default for RuleSet { @@ -54,7 +52,11 @@ impl RuleSet { Self::types().into_keys().collect() } - pub fn add(&mut self, rule: Rc<RefCell<Rule>>, r#type: i64) -> anyhow::Result<()> { + pub fn add( + &mut self, + rule: std::rc::Rc<std::cell::RefCell<Rule>>, + r#type: i64, + ) -> anyhow::Result<()> { let types = Self::types(); if !types.contains_key(&r#type) { return Err(OutOfBoundsException { @@ -92,11 +94,11 @@ impl RuleSet { self.next_rule_id } - pub fn rule_by_id(&self, id: i64) -> Rc<RefCell<Rule>> { + pub fn rule_by_id(&self, id: i64) -> std::rc::Rc<std::cell::RefCell<Rule>> { self.rule_by_id[&id].clone() } - pub fn get_rules(&self) -> &IndexMap<i64, Vec<Rc<RefCell<Rule>>>> { + pub fn get_rules(&self) -> &IndexMap<i64, Vec<std::rc::Rc<std::cell::RefCell<Rule>>>> { &self.rules } @@ -105,7 +107,7 @@ impl RuleSet { } pub fn get_iterator_for(&self, types: Vec<i64>) -> RuleSetIterator { - let mut rules: IndexMap<i64, Vec<Rc<RefCell<Rule>>>> = IndexMap::new(); + let mut rules: IndexMap<i64, Vec<std::rc::Rc<std::cell::RefCell<Rule>>>> = IndexMap::new(); for r#type in types { if let Some(rules_for_type) = self.rules.get(&r#type) { rules.insert(r#type, rules_for_type.clone()); @@ -115,7 +117,7 @@ impl RuleSet { } pub fn get_iterator_without(&self, types: Vec<i64>) -> RuleSetIterator { - let mut rules: IndexMap<i64, Vec<Rc<RefCell<Rule>>>> = IndexMap::new(); + let mut rules: IndexMap<i64, Vec<std::rc::Rc<std::cell::RefCell<Rule>>>> = IndexMap::new(); for (r#type, rules_for_type) in &self.rules { if types.contains(r#type) { continue; diff --git a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs index 6c2824e4..2f4837d4 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs @@ -13,13 +13,11 @@ use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; use crate::package::PackageInterfaceHandle; use indexmap::IndexMap; -use std::cell::RefCell; use std::collections::VecDeque; -use std::rc::Rc; #[derive(Debug)] pub struct RuleSetGenerator { - pub(crate) policy: Rc<dyn PolicyInterface>, + pub(crate) policy: std::rc::Rc<dyn PolicyInterface>, pub(crate) pool: std::rc::Rc<std::cell::RefCell<Pool>>, pub(crate) rules: RuleSet, pub(crate) added_map: IndexMap<i64, PackageInterfaceHandle>, @@ -28,7 +26,7 @@ pub struct RuleSetGenerator { impl RuleSetGenerator { pub fn new( - policy: Rc<dyn PolicyInterface>, + policy: std::rc::Rc<dyn PolicyInterface>, pool: std::rc::Rc<std::cell::RefCell<Pool>>, ) -> Self { Self { @@ -128,7 +126,9 @@ impl RuleSetGenerator { /// methods null is allowed which will not insert a rule. fn add_rule(&mut self, r#type: i64, new_rule: Option<Rule>) { if let Some(rule) = new_rule { - self.rules.add(Rc::new(RefCell::new(rule)), r#type).ok(); + self.rules + .add(std::rc::Rc::new(std::cell::RefCell::new(rule)), r#type) + .ok(); } } @@ -397,7 +397,7 @@ impl RuleSetGenerator { pub fn get_rules_for( &mut self, request: &Request, - platform_requirement_filter: Option<Rc<dyn PlatformRequirementFilterInterface>>, + platform_requirement_filter: Option<std::rc::Rc<dyn PlatformRequirementFilterInterface>>, ) -> anyhow::Result<RuleSet> { let platform_requirement_filter = platform_requirement_filter .unwrap_or_else(PlatformRequirementFilterFactory::ignore_nothing); diff --git a/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs b/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs index 2c4b9a45..b469a193 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs @@ -2,13 +2,11 @@ use crate::dependency_resolver::Rule; use indexmap::IndexMap; -use std::cell::RefCell; -use std::rc::Rc; /// Implements PHP \Iterator over a grouped rule set. #[derive(Debug)] pub struct RuleSetIterator { - pub(crate) rules: IndexMap<i64, Vec<Rc<RefCell<Rule>>>>, + pub(crate) rules: IndexMap<i64, Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>, pub(crate) types: Vec<i64>, pub(crate) current_offset: i64, pub(crate) current_type: i64, @@ -16,7 +14,7 @@ pub struct RuleSetIterator { } impl RuleSetIterator { - pub fn new(rules: IndexMap<i64, Vec<Rc<RefCell<Rule>>>>) -> Self { + pub fn new(rules: IndexMap<i64, Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>) -> Self { let mut types: Vec<i64> = rules.keys().copied().collect(); types.sort(); let mut iter = Self { @@ -30,7 +28,7 @@ impl RuleSetIterator { iter } - pub fn current(&self) -> Rc<RefCell<Rule>> { + pub fn current(&self) -> std::rc::Rc<std::cell::RefCell<Rule>> { self.rules[&self.current_type][self.current_offset as usize].clone() } diff --git a/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs b/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs index b746f504..6646490b 100644 --- a/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs +++ b/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs @@ -5,8 +5,6 @@ use crate::dependency_resolver::Rule; use crate::dependency_resolver::RuleWatchChain; use crate::dependency_resolver::RuleWatchNode; use indexmap::IndexMap; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct RuleWatchGraph { @@ -26,7 +24,7 @@ impl RuleWatchGraph { } } - pub fn insert(&mut self, node: Rc<RefCell<RuleWatchNode>>) { + pub fn insert(&mut self, node: std::rc::Rc<std::cell::RefCell<RuleWatchNode>>) { if node.borrow().get_rule().borrow().is_assertion() { return; } @@ -64,7 +62,7 @@ impl RuleWatchGraph { decided_literal: i64, level: i64, decisions: &mut Decisions, - ) -> Option<Rc<RefCell<Rule>>> { + ) -> Option<std::rc::Rc<std::cell::RefCell<Rule>>> { let literal = -decided_literal; if !self.watch_chains.contains_key(&literal) { @@ -127,7 +125,7 @@ impl RuleWatchGraph { &mut self, from_literal: i64, to_literal: i64, - node: Rc<RefCell<RuleWatchNode>>, + node: std::rc::Rc<std::cell::RefCell<RuleWatchNode>>, ) { if !self.watch_chains.contains_key(&to_literal) { self.watch_chains.insert(to_literal, RuleWatchChain::new()); diff --git a/crates/shirabe/src/dependency_resolver/rule_watch_node.rs b/crates/shirabe/src/dependency_resolver/rule_watch_node.rs index 92faae72..b11c1771 100644 --- a/crates/shirabe/src/dependency_resolver/rule_watch_node.rs +++ b/crates/shirabe/src/dependency_resolver/rule_watch_node.rs @@ -2,13 +2,11 @@ use crate::dependency_resolver::Decisions; use crate::dependency_resolver::Rule; -use std::cell::RefCell; -use std::rc::Rc; pub struct RuleWatchNode { pub watch1: i64, pub watch2: i64, - pub(crate) rule: Rc<RefCell<Rule>>, + pub(crate) rule: std::rc::Rc<std::cell::RefCell<Rule>>, } impl std::fmt::Debug for RuleWatchNode { @@ -21,7 +19,7 @@ impl std::fmt::Debug for RuleWatchNode { } impl RuleWatchNode { - pub fn new(rule: Rc<RefCell<Rule>>) -> Self { + pub fn new(rule: std::rc::Rc<std::cell::RefCell<Rule>>) -> Self { let literals = rule.borrow().get_literals(); let literal_count = literals.len(); let watch1 = if literal_count > 0 { literals[0] } else { 0 }; @@ -54,7 +52,7 @@ impl RuleWatchNode { } } - pub fn get_rule(&self) -> Rc<RefCell<Rule>> { + pub fn get_rule(&self) -> std::rc::Rc<std::cell::RefCell<Rule>> { self.rule.clone() } diff --git a/crates/shirabe/src/dependency_resolver/solver.rs b/crates/shirabe/src/dependency_resolver/solver.rs index 933f79f5..960cd7a6 100644 --- a/crates/shirabe/src/dependency_resolver/solver.rs +++ b/crates/shirabe/src/dependency_resolver/solver.rs @@ -23,12 +23,10 @@ use crate::package::BasePackageHandle; use indexmap::IndexMap; use shirabe_php_shim::{array_shift, array_unshift, microtime, spl_object_hash}; use shirabe_semver::constraint::AnyConstraint; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct Solver { - pub(crate) policy: Rc<dyn PolicyInterface>, + pub(crate) policy: std::rc::Rc<dyn PolicyInterface>, pub(crate) pool: std::rc::Rc<std::cell::RefCell<Pool>>, pub(crate) rules: RuleSet, @@ -41,7 +39,7 @@ pub struct Solver { /// Pairs of `(literals, level)` — PHP indexes into these with the BRANCH_* constants. pub(crate) branches: Vec<(Vec<i64>, i64)>, pub(crate) problems: Vec<Problem>, - pub(crate) learned_pool: Vec<Vec<Rc<RefCell<Rule>>>>, + pub(crate) learned_pool: Vec<Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>, pub(crate) learned_why: IndexMap<String, i64>, pub test_flag_learned_positive_literal: bool, @@ -54,7 +52,7 @@ impl Solver { const BRANCH_LEVEL: usize = 1; pub fn new( - policy: Rc<dyn PolicyInterface>, + policy: std::rc::Rc<dyn PolicyInterface>, pool: std::rc::Rc<std::cell::RefCell<Pool>>, io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, ) -> Self { @@ -205,14 +203,16 @@ impl Solver { .is_empty() { let mut problem = Problem::new(); - problem.add_rule(Rc::new(RefCell::new(Rule::Generic(GenericRule::new( - Vec::new(), - rule::RULE_ROOT_REQUIRE, - rule::ReasonData::RootRequire { - package_name: package_name.clone(), - constraint: active_constraint.clone(), - }, - ))))); + problem.add_rule(std::rc::Rc::new(std::cell::RefCell::new(Rule::Generic( + GenericRule::new( + Vec::new(), + rule::RULE_ROOT_REQUIRE, + rule::ReasonData::RootRequire { + package_name: package_name.clone(), + constraint: active_constraint.clone(), + }, + ), + )))); self.problems.push(problem); } } @@ -223,7 +223,7 @@ impl Solver { pub fn solve( &mut self, request: &Request, - platform_requirement_filter: Option<Rc<dyn PlatformRequirementFilterInterface>>, + platform_requirement_filter: Option<std::rc::Rc<dyn PlatformRequirementFilterInterface>>, ) -> anyhow::Result<Result<LockTransaction, SolverProblemsException>> { let platform_requirement_filter = platform_requirement_filter .unwrap_or_else(|| PlatformRequirementFilterFactory::ignore_nothing()); @@ -244,7 +244,9 @@ impl Solver { while iterator.valid() { let rule = iterator.current(); self.watch_graph - .insert(Rc::new(RefCell::new(RuleWatchNode::new(rule)))); + .insert(std::rc::Rc::new(std::cell::RefCell::new( + RuleWatchNode::new(rule), + ))); iterator.next(); } @@ -293,7 +295,7 @@ impl Solver { /// If we find unit rules we make new decisions based on them /// /// Returns a `Rule` on conflict, otherwise `None`. - fn propagate(&mut self, level: i64) -> Option<Rc<RefCell<Rule>>> { + fn propagate(&mut self, level: i64) -> Option<std::rc::Rc<std::cell::RefCell<Rule>>> { while self.decisions.valid_offset(self.propagate_index) { let decision = self .decisions @@ -354,7 +356,7 @@ impl Solver { &mut self, level: i64, literal: i64, - rule: Rc<RefCell<Rule>>, + rule: std::rc::Rc<std::cell::RefCell<Rule>>, ) -> anyhow::Result<i64> { let mut level = level + 1; @@ -390,13 +392,15 @@ impl Solver { // The same learned rule instance is shared between RuleSet, // RuleWatchGraph, and Decisions (PHP shares one object). - let new_rule = Rc::new(RefCell::new(Rule::Generic(new_rule))); + let new_rule = std::rc::Rc::new(std::cell::RefCell::new(Rule::Generic(new_rule))); self.rules.add(new_rule.clone(), RuleSet::TYPE_LEARNED)?; self.learned_why .insert(spl_object_hash(&*new_rule.borrow()), why); - let rule_node = Rc::new(RefCell::new(RuleWatchNode::new(new_rule.clone()))); + let rule_node = std::rc::Rc::new(std::cell::RefCell::new(RuleWatchNode::new( + new_rule.clone(), + ))); rule_node.borrow_mut().watch2_on_highest(&self.decisions); self.watch_graph.insert(rule_node); @@ -410,7 +414,7 @@ impl Solver { &mut self, level: i64, decision_queue: Vec<i64>, - rule: Rc<RefCell<Rule>>, + rule: std::rc::Rc<std::cell::RefCell<Rule>>, ) -> anyhow::Result<i64> { // choose best package to install from decisionQueue let mut literals = self.policy.select_preferred_packages( @@ -433,7 +437,7 @@ impl Solver { fn analyze( &mut self, level: i64, - rule: Rc<RefCell<Rule>>, + rule: std::rc::Rc<std::cell::RefCell<Rule>>, ) -> anyhow::Result<(i64, i64, GenericRule, i64)> { let analyzed_rule = rule.clone(); let mut rule = rule; @@ -602,7 +606,7 @@ impl Solver { fn analyze_unsolvable_rule( &self, problem: &mut Problem, - conflict_rule: Rc<RefCell<Rule>>, + conflict_rule: std::rc::Rc<std::cell::RefCell<Rule>>, rule_seen: &mut IndexMap<String, bool>, ) { let why = spl_object_hash(&*conflict_rule.borrow()); @@ -630,7 +634,7 @@ impl Solver { problem.add_rule(conflict_rule); } - fn analyze_unsolvable(&mut self, conflict_rule: Rc<RefCell<Rule>>) { + fn analyze_unsolvable(&mut self, conflict_rule: std::rc::Rc<std::cell::RefCell<Rule>>) { let mut problem = Problem::new(); problem.add_rule(conflict_rule.clone()); diff --git a/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs b/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs index b0016d07..48fe76b3 100644 --- a/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs +++ b/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs @@ -7,14 +7,12 @@ use crate::dependency_resolver::Rule; use crate::repository::RepositorySet; use crate::util::IniHelper; use shirabe_php_shim::RuntimeException; -use std::cell::RefCell; -use std::rc::Rc; #[derive(Debug)] pub struct SolverProblemsException { inner: RuntimeException, pub(crate) problems: Vec<Problem>, - pub(crate) learned_pool: Vec<Vec<Rc<RefCell<Rule>>>>, + pub(crate) learned_pool: Vec<Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>, } impl SolverProblemsException { @@ -28,7 +26,10 @@ impl SolverProblemsException { &self.inner.message } - pub fn new(problems: Vec<Problem>, learned_pool: Vec<Vec<Rc<RefCell<Rule>>>>) -> Self { + pub fn new( + problems: Vec<Problem>, + learned_pool: Vec<Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>, + ) -> Self { let message = format!( "Failed resolving dependencies with {} problems, call getPrettyString to get formatted details", problems.len() @@ -154,7 +155,7 @@ impl SolverProblemsException { fn get_extension_problems( &self, - reason_sets: &indexmap::IndexMap<i64, Vec<Rc<RefCell<Rule>>>>, + reason_sets: &indexmap::IndexMap<i64, Vec<std::rc::Rc<std::cell::RefCell<Rule>>>>, ) -> Vec<String> { let mut missing_extensions: indexmap::IndexMap<String, i64> = indexmap::IndexMap::new(); for reason_set in reason_sets.values() { diff --git a/crates/shirabe/src/filter/platform_requirement_filter/platform_requirement_filter_factory.rs b/crates/shirabe/src/filter/platform_requirement_filter/platform_requirement_filter_factory.rs index dcfd5191..12c69091 100644 --- a/crates/shirabe/src/filter/platform_requirement_filter/platform_requirement_filter_factory.rs +++ b/crates/shirabe/src/filter/platform_requirement_filter/platform_requirement_filter_factory.rs @@ -7,14 +7,13 @@ use crate::filter::platform_requirement_filter::{ platform_requirement_filter_interface::PlatformRequirementFilterInterface, }; use shirabe_php_shim::{InvalidArgumentException, PhpMixed}; -use std::rc::Rc; pub struct PlatformRequirementFilterFactory; impl PlatformRequirementFilterFactory { pub fn from_bool_or_list( bool_or_list: PhpMixed, - ) -> anyhow::Result<Rc<dyn PlatformRequirementFilterInterface>> { + ) -> anyhow::Result<std::rc::Rc<dyn PlatformRequirementFilterInterface>> { match bool_or_list { PhpMixed::Bool(b) => { if b { @@ -35,7 +34,9 @@ impl PlatformRequirementFilterFactory { .collect(), _ => unreachable!(), }; - Ok(Rc::new(IgnoreListPlatformRequirementFilter::new(list)?)) + Ok(std::rc::Rc::new(IgnoreListPlatformRequirementFilter::new( + list, + )?)) } other => Err(anyhow::anyhow!(InvalidArgumentException { message: format!( @@ -47,11 +48,11 @@ impl PlatformRequirementFilterFactory { } } - pub fn ignore_all() -> Rc<dyn PlatformRequirementFilterInterface> { - Rc::new(IgnoreAllPlatformRequirementFilter) + pub fn ignore_all() -> std::rc::Rc<dyn PlatformRequirementFilterInterface> { + std::rc::Rc::new(IgnoreAllPlatformRequirementFilter) } - pub fn ignore_nothing() -> Rc<dyn PlatformRequirementFilterInterface> { - Rc::new(IgnoreNothingPlatformRequirementFilter) + pub fn ignore_nothing() -> std::rc::Rc<dyn PlatformRequirementFilterInterface> { + std::rc::Rc::new(IgnoreNothingPlatformRequirementFilter) } } diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs index 04bff2a5..a3e429b1 100644 --- a/crates/shirabe/src/installer/installation_manager.rs +++ b/crates/shirabe/src/installer/installation_manager.rs @@ -737,7 +737,7 @@ impl InstallationManager { // PHP appends a post-exec step to the promise chain that dispatches the // POST_PACKAGE_* event via the event dispatcher with repo/all_operations/operation. // TODO(phase-c): the callback captures the event dispatcher (&mut) and the operation - // and must outlive the loop body; that requires the dispatcher behind Rc<RefCell> + // and must outlive the loop body; that requires the dispatcher behind Rc<RefCell<_>> // and the deferred event dispatch to be wired into the promise chain (todo!()). let _ = event_name_post; post_exec_callbacks.push(Box::new(|| { diff --git a/crates/shirabe/src/io/console_io.rs b/crates/shirabe/src/io/console_io.rs index eb7ab317..fe796d9e 100644 --- a/crates/shirabe/src/io/console_io.rs +++ b/crates/shirabe/src/io/console_io.rs @@ -27,7 +27,6 @@ use shirabe_php_shim::{ PhpMixed, array_search, function_exists, implode, in_array, is_array, is_string, mb_check_encoding, mb_convert_encoding, microtime, str_repeat, strip_tags, strlen, }; -use std::cell::RefCell; /// The Input/Output helper. #[derive(Debug)] @@ -41,10 +40,10 @@ pub struct ConsoleIO { /// `$this->helperSet->get('question')` on every ask. The Application class, which constructs /// this class, registers a single `QuestionHelper`. So this port holds the `QuestionHelper` /// directly instead of a `HelperSet`. - question_helper: RefCell<QuestionHelper>, + question_helper: std::cell::RefCell<QuestionHelper>, - pub(crate) last_message: RefCell<String>, - pub(crate) last_message_err: RefCell<String>, + pub(crate) last_message: std::cell::RefCell<String>, + pub(crate) last_message_err: std::cell::RefCell<String>, start_time: Option<f64>, verbosity_map: IndexMap<i64, i64>, @@ -69,9 +68,9 @@ impl ConsoleIO { authentications: indexmap![], input, output, - question_helper: RefCell::new(question_helper), - last_message: RefCell::new(String::new()), - last_message_err: RefCell::new(String::new()), + question_helper: std::cell::RefCell::new(question_helper), + last_message: std::cell::RefCell::new(String::new()), + last_message_err: std::cell::RefCell::new(String::new()), start_time: None, verbosity_map, } diff --git a/crates/shirabe/src/io/io_interface.rs b/crates/shirabe/src/io/io_interface.rs index af3f688a..96bc1980 100644 --- a/crates/shirabe/src/io/io_interface.rs +++ b/crates/shirabe/src/io/io_interface.rs @@ -3,8 +3,6 @@ use crate::config::Config; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; pub const QUIET: i64 = 1; pub const NORMAL: i64 = 2; @@ -167,7 +165,7 @@ pub trait IOInterface: IOInterfaceImmutable + IOInterfaceMutable { // `load_configuration`) are reached via `io.borrow_mut()`. Because the handle // does not implement `IOInterfaceMutable`, calling those directly on the handle // is a compile error rather than a runtime panic. -impl IOInterfaceImmutable for Rc<RefCell<dyn IOInterface>> { +impl IOInterfaceImmutable for std::rc::Rc<std::cell::RefCell<dyn IOInterface>> { fn is_interactive(&self) -> bool { self.borrow().is_interactive() } diff --git a/crates/shirabe/src/package/handle.rs b/crates/shirabe/src/package/handle.rs index c1db49c1..2b23a8c2 100644 --- a/crates/shirabe/src/package/handle.rs +++ b/crates/shirabe/src/package/handle.rs @@ -7,8 +7,6 @@ use crate::package::{ AliasPackage, BasePackage, CompleteAliasPackage, CompletePackage, CompletePackageInterface, Package, PackageInterface, RootAliasPackage, RootPackage, RootPackageInterface, }; -use std::cell::RefCell; -use std::rc::Rc; /// Any package type. #[derive(Debug, Clone)] @@ -192,7 +190,7 @@ impl AnyPackage { // parent::__clone(); // $this->aliasOf = clone $this->aliasOf; let new_alias_of_inner = p.alias_of.0.borrow().dup(); - let new_alias_of_rc = Rc::new(RefCell::new(new_alias_of_inner)); + let new_alias_of_rc = std::rc::Rc::new(std::cell::RefCell::new(new_alias_of_inner)); let new_root = RootPackageHandle(new_alias_of_rc.clone()); let new_complete = CompletePackageHandle(new_alias_of_rc.clone()); let new_pkg = PackageHandle(new_alias_of_rc); @@ -1361,7 +1359,7 @@ macro_rules! impl_handle_upcast { /// Shared reference to any package. Corresponds to PHP `PackageInterface`. #[derive(Debug, Clone)] -pub struct PackageInterfaceHandle(Rc<RefCell<AnyPackage>>); +pub struct PackageInterfaceHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); /// Shared reference to any package. Corresponds to PHP `BasePackage`. /// It is exactly the same as `PackageInterface` in Shirabe. It is only for mirroing PHP type @@ -1370,35 +1368,35 @@ pub type BasePackageHandle = PackageInterfaceHandle; /// Shared reference to a complete package. Corresponds to PHP `CompletePackageInterface`. #[derive(Debug, Clone)] -pub struct CompletePackageInterfaceHandle(Rc<RefCell<AnyPackage>>); +pub struct CompletePackageInterfaceHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); /// Shared reference to a root package. Corresponds to PHP `RootPackageInterface`. #[derive(Debug, Clone)] -pub struct RootPackageInterfaceHandle(Rc<RefCell<AnyPackage>>); +pub struct RootPackageInterfaceHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); /// Shared reference to a real (non-alias) package. Corresponds to PHP `Package`. #[derive(Debug, Clone)] -pub struct PackageHandle(Rc<RefCell<AnyPackage>>); +pub struct PackageHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); /// Shared reference to a real complete package. Corresponds to PHP `CompletePackage`. #[derive(Debug, Clone)] -pub struct CompletePackageHandle(Rc<RefCell<AnyPackage>>); +pub struct CompletePackageHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); /// Shared reference to a real root package. Corresponds to PHP `RootPackage`. #[derive(Debug, Clone)] -pub struct RootPackageHandle(Rc<RefCell<AnyPackage>>); +pub struct RootPackageHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); /// Shared reference to an alias package. Corresponds to PHP `AliasPackage`. #[derive(Debug, Clone)] -pub struct AliasPackageHandle(Rc<RefCell<AnyPackage>>); +pub struct AliasPackageHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); /// Shared reference to a complete alias package. Corresponds to PHP `CompleteAliasPackage`. #[derive(Debug, Clone)] -pub struct CompleteAliasPackageHandle(Rc<RefCell<AnyPackage>>); +pub struct CompleteAliasPackageHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); /// Shared reference to a root alias package. Corresponds to PHP `RootAliasPackage`. #[derive(Debug, Clone)] -pub struct RootAliasPackageHandle(Rc<RefCell<AnyPackage>>); +pub struct RootAliasPackageHandle(std::rc::Rc<std::cell::RefCell<AnyPackage>>); impl_handle_common!(PackageInterfaceHandle); impl_handle_common!(CompletePackageInterfaceHandle); @@ -1552,7 +1550,9 @@ impl PackageInterfaceHandle { impl PackageHandle { pub fn from_package(package: Package) -> Self { - Self(Rc::new(RefCell::new(AnyPackage::Package(package)))) + Self(std::rc::Rc::new(std::cell::RefCell::new( + AnyPackage::Package(package), + ))) } pub fn new(name: String, version: String, pretty_version: String) -> Self { @@ -1562,7 +1562,9 @@ impl PackageHandle { impl CompletePackageHandle { pub fn from_complete_package(package: CompletePackage) -> Self { - Self(Rc::new(RefCell::new(AnyPackage::CompletePackage(package)))) + Self(std::rc::Rc::new(std::cell::RefCell::new( + AnyPackage::CompletePackage(package), + ))) } pub fn new(name: String, version: String, pretty_version: String) -> Self { @@ -1572,7 +1574,9 @@ impl CompletePackageHandle { impl RootPackageHandle { pub fn from_root_package(package: RootPackage) -> Self { - Self(Rc::new(RefCell::new(AnyPackage::RootPackage(package)))) + Self(std::rc::Rc::new(std::cell::RefCell::new( + AnyPackage::RootPackage(package), + ))) } pub fn new(name: String, version: String, pretty_version: String) -> Self { @@ -1589,7 +1593,9 @@ impl RootPackageHandle { impl AliasPackageHandle { pub fn from_alias_package(package: AliasPackage) -> Self { - Self(Rc::new(RefCell::new(AnyPackage::AliasPackage(package)))) + Self(std::rc::Rc::new(std::cell::RefCell::new( + AnyPackage::AliasPackage(package), + ))) } pub fn new(alias_of: PackageHandle, version: String, pretty_version: String) -> Self { @@ -1636,9 +1642,9 @@ impl AliasPackageHandle { impl CompleteAliasPackageHandle { pub fn from_complete_alias_package(package: CompleteAliasPackage) -> Self { - Self(Rc::new(RefCell::new(AnyPackage::CompleteAliasPackage( - package, - )))) + Self(std::rc::Rc::new(std::cell::RefCell::new( + AnyPackage::CompleteAliasPackage(package), + ))) } pub fn new(alias_of: CompletePackageHandle, version: String, pretty_version: String) -> Self { @@ -1669,7 +1675,9 @@ impl CompleteAliasPackageHandle { impl RootAliasPackageHandle { pub fn from_root_alias_package(package: RootAliasPackage) -> Self { - Self(Rc::new(RefCell::new(AnyPackage::RootAliasPackage(package)))) + Self(std::rc::Rc::new(std::cell::RefCell::new( + AnyPackage::RootAliasPackage(package), + ))) } pub fn new(alias_of: RootPackageHandle, version: String, pretty_version: String) -> Self { diff --git a/crates/shirabe/src/package/loader/validating_array_loader.rs b/crates/shirabe/src/package/loader/validating_array_loader.rs index 3250f011..4d7965f8 100644 --- a/crates/shirabe/src/package/loader/validating_array_loader.rs +++ b/crates/shirabe/src/package/loader/validating_array_loader.rs @@ -18,7 +18,6 @@ use shirabe_semver::Intervals; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; use shirabe_spdx_licenses::SpdxLicenses; -use std::cell::RefCell; #[derive(Debug)] pub struct ValidatingArrayLoader { @@ -26,9 +25,9 @@ pub struct ValidatingArrayLoader { version_parser: VersionParser, // RefCell: `load` implements `LoaderInterface`, whose signature takes `&self`, but PHP's // implementation freely mutates these as scratch state for the duration of a single call. - errors: RefCell<Vec<String>>, - warnings: RefCell<Vec<String>>, - config: RefCell<IndexMap<String, PhpMixed>>, + errors: std::cell::RefCell<Vec<String>>, + warnings: std::cell::RefCell<Vec<String>>, + config: std::cell::RefCell<IndexMap<String, PhpMixed>>, flags: i64, } @@ -55,9 +54,9 @@ impl ValidatingArrayLoader { Self { loader, version_parser, - errors: RefCell::new(Vec::new()), - warnings: RefCell::new(Vec::new()), - config: RefCell::new(IndexMap::new()), + errors: std::cell::RefCell::new(Vec::new()), + warnings: std::cell::RefCell::new(Vec::new()), + config: std::cell::RefCell::new(IndexMap::new()), flags, } } diff --git a/crates/shirabe/src/package/package.rs b/crates/shirabe/src/package/package.rs index 6eaf348b..ce22b755 100644 --- a/crates/shirabe/src/package/package.rs +++ b/crates/shirabe/src/package/package.rs @@ -12,7 +12,6 @@ use chrono::{DateTime, Utc}; use indexmap::{IndexMap, IndexSet}; use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{E_USER_DEPRECATED, LogicException, PhpMixed, strpos, trigger_error}; -use std::rc::Rc; /// Mirror entry, e.g. `['url' => 'https://...', 'preferred' => true]`. #[derive(Debug, Clone)] @@ -709,7 +708,7 @@ impl PackageInterface for Package { } fn set_repository(&mut self, repository: RepositoryInterfaceHandle) -> anyhow::Result<()> { if let Some(existing) = self.repository.as_ref().and_then(|w| w.upgrade()) - && !Rc::ptr_eq(&existing, repository.as_rc()) + && !std::rc::Rc::ptr_eq(&existing, repository.as_rc()) { return Err(LogicException { message: "A package can only be added to one repository".to_string(), diff --git a/crates/shirabe/src/plugin/plugin_interface.rs b/crates/shirabe/src/plugin/plugin_interface.rs index 486dbeac..5a92a87a 100644 --- a/crates/shirabe/src/plugin/plugin_interface.rs +++ b/crates/shirabe/src/plugin/plugin_interface.rs @@ -3,17 +3,27 @@ use crate::composer::ComposerHandle; use crate::io::IOInterface; use crate::plugin::Capable; -use std::cell::RefCell; -use std::rc::Rc; pub const PLUGIN_API_VERSION: &str = "2.9.0"; pub trait PluginInterface: std::fmt::Debug { - fn activate(&mut self, composer: &ComposerHandle, io: Rc<RefCell<dyn IOInterface>>); + fn activate( + &mut self, + composer: &ComposerHandle, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, + ); - fn deactivate(&mut self, composer: &ComposerHandle, io: Rc<RefCell<dyn IOInterface>>); + fn deactivate( + &mut self, + composer: &ComposerHandle, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, + ); - fn uninstall(&mut self, composer: &ComposerHandle, io: Rc<RefCell<dyn IOInterface>>); + fn uninstall( + &mut self, + composer: &ComposerHandle, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, + ); // TODO(plugin): PHP-side `instanceof` checks for EventSubscriberInterface / Capable. // EventSubscriberInterface is not dyn-compatible (its only method is associated, not diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs index dc31baad..6f5e4194 100644 --- a/crates/shirabe/src/repository/array_repository.rs +++ b/crates/shirabe/src/repository/array_repository.rs @@ -16,20 +16,19 @@ use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{implode, preg_quote, strtolower}; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; -use std::cell::RefCell; use std::rc::Weak; /// A repository implementation that simply stores packages in an array #[derive(Debug)] pub struct ArrayRepository { - pub(crate) packages: RefCell<Option<Vec<BasePackageHandle>>>, + pub(crate) packages: std::cell::RefCell<Option<Vec<BasePackageHandle>>>, /// @var ?array<BasePackage> indexed by package unique name and used to cache hasPackage calls - pub(crate) package_map: RefCell<Option<IndexMap<String, BasePackageHandle>>>, + pub(crate) package_map: std::cell::RefCell<Option<IndexMap<String, BasePackageHandle>>>, /// Weak reference to the outermost repository handle wrapping this `ArrayRepository`, /// injected via `set_self_handle`. Used to wire package -> repository back-references. - self_weak: RefCell<Option<RepositoryInterfaceWeakHandle>>, + self_weak: std::cell::RefCell<Option<RepositoryInterfaceWeakHandle>>, } impl ArrayRepository { @@ -120,9 +119,9 @@ impl ArrayRepository { /// @param array<PackageInterface> $packages pub fn new(packages: Vec<PackageInterfaceHandle>) -> anyhow::Result<Self> { let this = Self { - packages: RefCell::new(None), - package_map: RefCell::new(None), - self_weak: RefCell::new(None), + packages: std::cell::RefCell::new(None), + package_map: std::cell::RefCell::new(None), + self_weak: std::cell::RefCell::new(None), }; for package in packages { this.add_package(package)?; diff --git a/crates/shirabe/src/repository/handle.rs b/crates/shirabe/src/repository/handle.rs index 64cb5b73..f093f66b 100644 --- a/crates/shirabe/src/repository/handle.rs +++ b/crates/shirabe/src/repository/handle.rs @@ -8,35 +8,36 @@ use crate::repository::{ }; use indexmap::IndexMap; use shirabe_semver::constraint::AnyConstraint; -use std::cell::{Ref, RefCell, RefMut}; -use std::rc::{Rc, Weak}; +use std::cell::{Ref, RefMut}; +use std::rc::Weak; /// Shared reference to a repository. Corresponds to PHP `RepositoryInterface`. #[derive(Debug, Clone)] -pub struct RepositoryInterfaceHandle(Rc<RefCell<dyn RepositoryInterface>>); +pub struct RepositoryInterfaceHandle(std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>>); /// Weak back-reference held by packages to the repository that owns them. -pub type RepositoryInterfaceWeakHandle = Weak<RefCell<dyn RepositoryInterface>>; +pub type RepositoryInterfaceWeakHandle = Weak<std::cell::RefCell<dyn RepositoryInterface>>; impl RepositoryInterfaceHandle { /// Wraps a concrete repository in a shared handle and injects its own weak reference so that /// `add_package` can wire package -> repository back-references (PHP `setRepository($this)`). pub fn new<T: RepositoryInterface + 'static>(repository: T) -> Self { - let rc: Rc<RefCell<dyn RepositoryInterface>> = Rc::new(RefCell::new(repository)); - rc.borrow().set_self_handle(Rc::downgrade(&rc)); + let rc: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = + std::rc::Rc::new(std::cell::RefCell::new(repository)); + rc.borrow().set_self_handle(std::rc::Rc::downgrade(&rc)); Self(rc) } - pub fn from_rc(rc: Rc<RefCell<dyn RepositoryInterface>>) -> Self { + pub fn from_rc(rc: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>>) -> Self { Self(rc) } - pub fn as_rc(&self) -> &Rc<RefCell<dyn RepositoryInterface>> { + pub fn as_rc(&self) -> &std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> { &self.0 } pub fn downgrade(&self) -> RepositoryInterfaceWeakHandle { - Rc::downgrade(&self.0) + std::rc::Rc::downgrade(&self.0) } pub fn borrow(&self) -> Ref<'_, dyn RepositoryInterface> { @@ -49,12 +50,12 @@ impl RepositoryInterfaceHandle { /// PHP `===` (reference identity). pub fn ptr_eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } /// Stable identity usable as a map key (PHP `spl_object_hash`). pub fn ptr_id(&self) -> usize { - Rc::as_ptr(&self.0) as *const () as usize + std::rc::Rc::as_ptr(&self.0) as *const () as usize } /// PHP `instanceof T` for a concrete repository type. Keeps the `RefCell` borrow internal. @@ -63,13 +64,15 @@ impl RepositoryInterfaceHandle { } /// Downcasts the shared handle to a concrete repository type, preserving shared ownership. - pub fn downcast_rc<T: RepositoryInterface + 'static>(&self) -> Option<Rc<RefCell<T>>> { + pub fn downcast_rc<T: RepositoryInterface + 'static>( + &self, + ) -> Option<std::rc::Rc<std::cell::RefCell<T>>> { if self.0.borrow().as_any().is::<T>() { let rc = self.0.clone(); - let ptr = Rc::into_raw(rc) as *const RefCell<T>; + let ptr = std::rc::Rc::into_raw(rc) as *const std::cell::RefCell<T>; // SAFETY: is::<T>() proved the value is `T`, and handles are always allocated as // `Rc::new(RefCell::new(concrete))`, so the layout matches `RcBox<RefCell<T>>`. - Some(unsafe { Rc::from_raw(ptr) }) + Some(unsafe { std::rc::Rc::from_raw(ptr) }) } else { None } @@ -191,7 +194,7 @@ impl RepositoryInterfaceHandle { impl PartialEq for RepositoryInterfaceHandle { fn eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } } @@ -205,21 +208,22 @@ impl std::hash::Hash for RepositoryInterfaceHandle { /// Typed shared handle over `LockArrayRepository`. #[derive(Debug, Clone)] -pub struct LockArrayRepositoryHandle(Rc<RefCell<LockArrayRepository>>); +pub struct LockArrayRepositoryHandle(std::rc::Rc<std::cell::RefCell<LockArrayRepository>>); impl LockArrayRepositoryHandle { pub fn new(repository: LockArrayRepository) -> Self { - let rc: Rc<RefCell<LockArrayRepository>> = Rc::new(RefCell::new(repository)); - let rc_dyn: Rc<RefCell<dyn RepositoryInterface>> = rc.clone(); - rc.borrow().set_self_handle(Rc::downgrade(&rc_dyn)); + let rc: std::rc::Rc<std::cell::RefCell<LockArrayRepository>> = + std::rc::Rc::new(std::cell::RefCell::new(repository)); + let rc_dyn: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = rc.clone(); + rc.borrow().set_self_handle(std::rc::Rc::downgrade(&rc_dyn)); Self(rc) } - pub fn from_rc(rc: Rc<RefCell<LockArrayRepository>>) -> Self { + pub fn from_rc(rc: std::rc::Rc<std::cell::RefCell<LockArrayRepository>>) -> Self { Self(rc) } - pub fn as_rc(&self) -> &Rc<RefCell<LockArrayRepository>> { + pub fn as_rc(&self) -> &std::rc::Rc<std::cell::RefCell<LockArrayRepository>> { &self.0 } @@ -236,24 +240,24 @@ impl LockArrayRepositoryHandle { } pub fn ptr_eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } pub fn ptr_id(&self) -> usize { - Rc::as_ptr(&self.0) as *const () as usize + std::rc::Rc::as_ptr(&self.0) as *const () as usize } } impl From<LockArrayRepositoryHandle> for RepositoryInterfaceHandle { fn from(h: LockArrayRepositoryHandle) -> Self { - let rc: Rc<RefCell<dyn RepositoryInterface>> = h.0; + let rc: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = h.0; RepositoryInterfaceHandle::from_rc(rc) } } impl PartialEq for LockArrayRepositoryHandle { fn eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } } @@ -267,21 +271,22 @@ impl std::hash::Hash for LockArrayRepositoryHandle { /// Typed shared handle over `PlatformRepository`. #[derive(Debug, Clone)] -pub struct PlatformRepositoryHandle(Rc<RefCell<PlatformRepository>>); +pub struct PlatformRepositoryHandle(std::rc::Rc<std::cell::RefCell<PlatformRepository>>); impl PlatformRepositoryHandle { pub fn new(repository: PlatformRepository) -> Self { - let rc: Rc<RefCell<PlatformRepository>> = Rc::new(RefCell::new(repository)); - let rc_dyn: Rc<RefCell<dyn RepositoryInterface>> = rc.clone(); - rc.borrow().set_self_handle(Rc::downgrade(&rc_dyn)); + let rc: std::rc::Rc<std::cell::RefCell<PlatformRepository>> = + std::rc::Rc::new(std::cell::RefCell::new(repository)); + let rc_dyn: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = rc.clone(); + rc.borrow().set_self_handle(std::rc::Rc::downgrade(&rc_dyn)); Self(rc) } - pub fn from_rc(rc: Rc<RefCell<PlatformRepository>>) -> Self { + pub fn from_rc(rc: std::rc::Rc<std::cell::RefCell<PlatformRepository>>) -> Self { Self(rc) } - pub fn as_rc(&self) -> &Rc<RefCell<PlatformRepository>> { + pub fn as_rc(&self) -> &std::rc::Rc<std::cell::RefCell<PlatformRepository>> { &self.0 } @@ -294,24 +299,24 @@ impl PlatformRepositoryHandle { } pub fn ptr_eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } pub fn ptr_id(&self) -> usize { - Rc::as_ptr(&self.0) as *const () as usize + std::rc::Rc::as_ptr(&self.0) as *const () as usize } } impl From<PlatformRepositoryHandle> for RepositoryInterfaceHandle { fn from(h: PlatformRepositoryHandle) -> Self { - let rc: Rc<RefCell<dyn RepositoryInterface>> = h.0; + let rc: std::rc::Rc<std::cell::RefCell<dyn RepositoryInterface>> = h.0; RepositoryInterfaceHandle::from_rc(rc) } } impl PartialEq for PlatformRepositoryHandle { fn eq(&self, other: &Self) -> bool { - Rc::ptr_eq(&self.0, &other.0) + std::rc::Rc::ptr_eq(&self.0, &other.0) } } diff --git a/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs b/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs index fb10d0f2..628f78b7 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs @@ -5,8 +5,6 @@ use crate::io::IOInterface; use chrono::{DateTime, FixedOffset}; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; pub trait VcsDriverInterface: std::fmt::Debug { fn initialize(&mut self) -> anyhow::Result<()>; @@ -40,8 +38,8 @@ pub trait VcsDriverInterface: std::fmt::Debug { fn cleanup(&mut self) -> anyhow::Result<()>; fn supports( - io: Rc<RefCell<dyn IOInterface>>, - config: Rc<RefCell<Config>>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, + config: std::rc::Rc<std::cell::RefCell<Config>>, url: &str, deep: bool, ) -> anyhow::Result<bool> diff --git a/crates/shirabe/src/util/error_handler.rs b/crates/shirabe/src/util/error_handler.rs index 45ad28a8..7a9cf9c2 100644 --- a/crates/shirabe/src/util/error_handler.rs +++ b/crates/shirabe/src/util/error_handler.rs @@ -7,14 +7,13 @@ use shirabe_php_shim::{ STDERR, debug_backtrace, error_reporting, filter_var_boolean, fwrite, ini_get, set_error_handler, }; -use std::cell::{Cell, RefCell}; -use std::rc::Rc; +use std::cell::Cell; // PHP keeps `$io` / `$hasShownDeprecationNotice` as process-global statics. Composer runs // single-threaded, so thread-locals on the main thread reproduce that faithfully while letting // us hold the same shared (`Rc<RefCell<dyn IOInterface>>`) IO instance the application uses. thread_local! { - static IO: RefCell<Option<Rc<RefCell<dyn IOInterface>>>> = const { RefCell::new(None) }; + static IO: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>> = const { std::cell::RefCell::new(None) }; static HAS_SHOWN_DEPRECATION_NOTICE: Cell<i64> = const { Cell::new(0) }; } @@ -88,7 +87,7 @@ impl ErrorHandler { Ok(true) } - pub fn register(io: Option<Rc<RefCell<dyn IOInterface>>>) { + pub fn register(io: Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>) { set_error_handler(|level, message, file, line| { Self::handle(level, message.to_string(), file.to_string(), line).unwrap_or(true) }); |
