diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-24 04:51:47 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-24 05:02:54 +0900 |
| commit | a8623a5e867825400073d2597dfb3118d6624ef7 (patch) | |
| tree | 7df29f68596765dc3914209e14af4999b721815f /crates/shirabe | |
| parent | e87d37a294a4c754585309d391d793a2c9a1287e (diff) | |
| download | php-shirabe-a8623a5e867825400073d2597dfb3118d6624ef7.tar.gz php-shirabe-a8623a5e867825400073d2597dfb3118d6624ef7.tar.zst php-shirabe-a8623a5e867825400073d2597dfb3118d6624ef7.zip | |
chore: unwrap meaningless PhpMixed::String()
Diffstat (limited to 'crates/shirabe')
29 files changed, 196 insertions, 256 deletions
diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs index 411e83e..ca49591 100644 --- a/crates/shirabe/src/advisory/auditor.rs +++ b/crates/shirabe/src/advisory/auditor.rs @@ -537,12 +537,12 @@ impl Auditor { ) -> Result<()> { io.write_error(&format!( "<error>Found {} abandoned package{}:</error>", - PhpMixed::Int(packages.len() as i64), - PhpMixed::String(if packages.len() > 1 { + packages.len() as i64, + if packages.len() > 1 { "s".to_string() } else { String::new() - }), + }, )); if format == Self::FORMAT_PLAIN { @@ -554,8 +554,8 @@ impl Auditor { }; io.write_error(&format!( "{} is abandoned. {}.", - PhpMixed::String(self.get_package_name_with_link(pkg.clone().into())), - PhpMixed::String(replacement), + self.get_package_name_with_link(pkg.clone().into()), + replacement, )); } diff --git a/crates/shirabe/src/cache.rs b/crates/shirabe/src/cache.rs index 8d9473a..696378a 100644 --- a/crates/shirabe/src/cache.rs +++ b/crates/shirabe/src/cache.rs @@ -125,7 +125,7 @@ impl Cache { self.io .write_error(&format!("Writing {}{} into cache", self.root, file)); - let temp_file_name = format!("{}{}{}.tmp", self.root, file, bin2hex(&random_bytes(5)),); + let temp_file_name = format!("{}{}{}.tmp", self.root, file, bin2hex(&random_bytes(5))); let dest = format!("{}{}", self.root, file); let attempt = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { file_put_contents(&temp_file_name, contents.as_bytes()).is_some() diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs index caa9808..db91012 100644 --- a/crates/shirabe/src/command/exec_command.rs +++ b/crates/shirabe/src/command/exec_command.rs @@ -90,11 +90,11 @@ impl Command for ExecCommand { InputArgument::new("binary", Some(InputArgument::OPTIONAL), "The binary to run, e.g. phpunit", - None,).unwrap().into(), + None).unwrap().into(), InputArgument::new("args", Some(InputArgument::IS_ARRAY | InputArgument::OPTIONAL), "Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments", - None,).unwrap().into(), + None).unwrap().into(), ]); self.set_help( "Executes a vendored binary/script.\n\n\ diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index ec9ede4..d98793a 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -888,7 +888,7 @@ impl Command for InitCommand { return Err(InvalidArgumentException { message: format!( "The src folder name \"{}\" is invalid. Please add a relative path with tailing forward slash. [A-Za-z0-9_-/]+/", - PhpMixed::String(value_or_default.clone()), + value_or_default.clone(), ), code: 0, } @@ -1049,10 +1049,7 @@ impl InitCommand { return false; } - let pattern = format!( - "{{^/?{}(/\\*?)?$}}", - PhpMixed::String(preg_quote(vendor, None)), - ); + let pattern = format!("{{^/?{}(/\\*?)?$}}", preg_quote(vendor, None)); let lines = file(ignore_file, FILE_IGNORE_NEW_LINES).unwrap_or_default(); for line in &lines { @@ -1229,11 +1226,7 @@ impl InitCommand { } if let (Some(name), Some(email)) = (author_name, author_email) { - return Some(format!( - "{} <{}>", - PhpMixed::String(name), - PhpMixed::String(email), - )); + return Some(format!("{} <{}>", name, email)); } None diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs index 943eeaf..bce7e9a 100644 --- a/crates/shirabe/src/command/package_discovery_trait.rs +++ b/crates/shirabe/src/command/package_discovery_trait.rs @@ -188,10 +188,8 @@ pub trait PackageDiscoveryTrait: BaseCommand { io.write_error3( &format!( "Using version <info>{}</info> for <info>{}</info>", - PhpMixed::String(version), - PhpMixed::String( - requirement.get("name").cloned().unwrap_or_default(), - ), + version, + requirement.get("name").cloned().unwrap_or_default(), ), true, io_interface::NORMAL, @@ -295,23 +293,20 @@ pub trait PackageDiscoveryTrait: BaseCommand { if let Some(ai) = &found_package.abandoned { let replacement = match ai { crate::repository::AbandonedInfo::Replacement(r) => { - format!("Use {} instead", PhpMixed::String(r.clone())) + format!("Use {} instead", r.clone()) } crate::repository::AbandonedInfo::Abandoned => { "No replacement was suggested".to_string() } }; - abandoned = format!( - "<warning>Abandoned. {}.</warning>", - PhpMixed::String(replacement), - ); + abandoned = format!("<warning>Abandoned. {}.</warning>", replacement); } choices.push(format!( " <info>{:>5}</info> {} {}", - PhpMixed::String(format!("[{}]", position)), - PhpMixed::String(found_package.name.clone()), - PhpMixed::String(abandoned), + format!("[{}]", position), + found_package.name.clone(), + abandoned, )); } @@ -319,8 +314,8 @@ pub trait PackageDiscoveryTrait: BaseCommand { io.write_error3( &format!( "Found <info>{}</info> packages matching <info>{}</info>", - PhpMixed::Int(matches.len() as i64), - PhpMixed::String(package.clone()), + matches.len() as i64, + package.clone(), ), true, io_interface::NORMAL, @@ -432,8 +427,8 @@ pub trait PackageDiscoveryTrait: BaseCommand { io.write_error3( &format!( "Using version <info>{}</info> for <info>{}</info>", - PhpMixed::String(c.clone()), - PhpMixed::String(package.clone()), + c.clone(), + package.clone(), ), true, io_interface::NORMAL, @@ -563,7 +558,7 @@ pub trait PackageDiscoveryTrait: BaseCommand { return Err(InvalidArgumentException { message: format!( "Package {} has requirements incompatible with your PHP version, PHP extensions and Composer version{}", - PhpMixed::String(name.to_string()), + name.to_string(), self.get_platform_exception_details( candidate.clone(), platform_repo, @@ -617,8 +612,8 @@ pub trait PackageDiscoveryTrait: BaseCommand { return Err(InvalidArgumentException { message: format!( "Could not find a version of package {} matching your minimum-stability ({}). Require it with an explicit version constraint allowing its desired stability.", - PhpMixed::String(name.to_string()), - PhpMixed::String(effective_minimum_stability.clone()), + name.to_string(), + effective_minimum_stability.clone(), ), code: 0, } @@ -659,12 +654,12 @@ pub trait PackageDiscoveryTrait: BaseCommand { return Err(InvalidArgumentException { message: format!( "Could not find package {} in any version matching your PHP version, PHP extensions and Composer version{}{}", - PhpMixed::String(name.to_string()), + name.to_string(), self.get_platform_exception_details( candidate.clone(), platform_repo, )?, - PhpMixed::String(additional), + additional, ), code: 0, } @@ -688,7 +683,7 @@ pub trait PackageDiscoveryTrait: BaseCommand { return Err(InvalidArgumentException { message: format!( "Could not find package {}. It was however found via repository search, which indicates a consistency issue with the repository.", - PhpMixed::String(name.to_string()), + name.to_string(), ), code: 0, } @@ -725,13 +720,13 @@ pub trait PackageDiscoveryTrait: BaseCommand { return Err(InvalidArgumentException { message: format!( "Could not find package {}.\n\nDid you mean {}?\n {}", - PhpMixed::String(name.to_string()), + name.to_string(), if similar.len() > 1 { "one of these" } else { "this" }, - PhpMixed::String(implode("\n ", &similar)), + implode("\n ", &similar), ), code: 0, } @@ -741,8 +736,8 @@ pub trait PackageDiscoveryTrait: BaseCommand { return Err(InvalidArgumentException { message: format!( "Could not find a matching version of package {}. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability ({}).", - PhpMixed::String(name.to_string()), - PhpMixed::String(effective_minimum_stability), + name.to_string(), + effective_minimum_stability, ), code: 0, } diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs index 0cac581..d880ca0 100644 --- a/crates/shirabe/src/command/remove_command.rs +++ b/crates/shirabe/src/command/remove_command.rs @@ -67,112 +67,112 @@ impl Command for RemoveCommand { InputArgument::new("packages", Some(InputArgument::IS_ARRAY), "Packages that should be removed.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("dev", None, Some(InputOption::VALUE_NONE), "Removes a package from the require-dev section.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("dry-run", None, Some(InputOption::VALUE_NONE), "Outputs the operations but will not execute anything (implicitly enables --verbose).", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("no-progress", None, Some(InputOption::VALUE_NONE), "Do not output download progress.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("no-update", None, Some(InputOption::VALUE_NONE), "Disables the automatic update of the dependencies (implies --no-install).", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("no-install", None, Some(InputOption::VALUE_NONE), "Skip the install step after updating the composer.lock file.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("no-audit", None, Some(InputOption::VALUE_NONE), "Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var).", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\", or \"summary\".", - Some(PhpMixed::String(Auditor::FORMAT_SUMMARY.to_string())),).unwrap().into(), + Some(PhpMixed::String(Auditor::FORMAT_SUMMARY.to_string()))).unwrap().into(), InputOption::new("no-security-blocking", None, Some(InputOption::VALUE_NONE), "Allows installing packages with security advisories or that are abandoned (can also be set via the COMPOSER_NO_SECURITY_BLOCKING=1 env var).", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("update-no-dev", None, Some(InputOption::VALUE_NONE), "Run the dependency update with the --no-dev option.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("update-with-dependencies", Some(PhpMixed::String("w".to_string())), Some(InputOption::VALUE_NONE), "Allows inherited dependencies to be updated with explicit dependencies (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var). (Deprecated, is now default behavior)", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("update-with-all-dependencies", Some(PhpMixed::String("W".to_string())), Some(InputOption::VALUE_NONE), "Allows all inherited dependencies to be updated, including those that are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("with-all-dependencies", None, Some(InputOption::VALUE_NONE), "Alias for --update-with-all-dependencies", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("no-update-with-dependencies", None, Some(InputOption::VALUE_NONE), "Does not allow inherited dependencies to be updated with explicit dependencies.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("minimal-changes", Some(PhpMixed::String("m".to_string())), Some(InputOption::VALUE_NONE), "During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("unused", None, Some(InputOption::VALUE_NONE), "Remove all packages which are locked but not required by any other package.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages).", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("ignore-platform-reqs", None, Some(InputOption::VALUE_NONE), "Ignore all platform requirements (php & ext- packages).", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("optimize-autoloader", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("classmap-authoritative", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("apcu-autoloader", None, Some(InputOption::VALUE_NONE), "Use APCu to cache found/not-found classes.", - None,).unwrap().into(), + None).unwrap().into(), InputOption::new("apcu-autoloader-prefix", None, Some(InputOption::VALUE_REQUIRED), "Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader", - None,).unwrap().into(), + None).unwrap().into(), ]); self.set_help( "The <info>remove</info> command removes a package from the current\n\ diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index b1dfd4a..4bed4df 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -463,7 +463,7 @@ impl Command for RequireCommand { if strtolower(package) == composer.get_package().get_name() { let msg = format!( "<error>Root package '{}' cannot require itself in its composer.json</error>", - PhpMixed::String(package.clone()), + package.clone(), ); self.get_io().write_error3(&msg, true, io_interface::NORMAL); @@ -481,17 +481,15 @@ impl Command for RequireCommand { for package in &inconsistent_require_keys { let warn_msg = format!( "{} is currently present in the {} key and you ran the command {} the --dev flag, which will move it to the {} key.", - PhpMixed::String(package.clone()), - PhpMixed::String(remove_key.to_string()), - PhpMixed::String( - if input.borrow().get_option("dev")?.as_bool().unwrap_or(false) { - "with" - } else { - "without" - } - .to_string(), - ), - PhpMixed::String(require_key.to_string()), + package.clone(), + remove_key.to_string(), + if input.borrow().get_option("dev")?.as_bool().unwrap_or(false) { + "with" + } else { + "without" + } + .to_string(), + require_key.to_string(), ); self.get_io().warning(&warn_msg, &[]); } @@ -499,26 +497,22 @@ impl Command for RequireCommand { if self.get_io().is_interactive() { let q1 = format!( "<info>Do you want to move {}?</info> [<comment>no</comment>]? ", - PhpMixed::String( - if (inconsistent_require_keys.len() as i64) > 1 { - "these requirements" - } else { - "this requirement" - } - .to_string(), - ), + if (inconsistent_require_keys.len() as i64) > 1 { + "these requirements" + } else { + "this requirement" + } + .to_string(), ); if !self.get_io().ask_confirmation(q1, false) { let q2 = format!( "<info>Do you want to re-run the command {} --dev?</info> [<comment>yes</comment>]? ", - PhpMixed::String( - if input.borrow().get_option("dev")?.as_bool().unwrap_or(false) { - "without" - } else { - "with" - } - .to_string(), - ), + if input.borrow().get_option("dev")?.as_bool().unwrap_or(false) { + "without" + } else { + "with" + } + .to_string(), ); if !self.get_io().ask_confirmation(q2, true) { return Ok(0); @@ -1122,8 +1116,8 @@ impl RequireCommand { self.get_io().write_error3( &format!( "Using version <info>{}</info> for <info>{}</info>", - PhpMixed::String(requirements.get(package_name).cloned().unwrap_or_default(),), - PhpMixed::String(package_name.clone()), + requirements.get(package_name).cloned().unwrap_or_default(), + package_name.clone(), ), true, io_interface::NORMAL, diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index 9073658..1903dec 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -707,9 +707,7 @@ impl UpdateCommand { if io.ask_confirmation( format!( "Would you like to continue and update the above package{} [<comment>yes</comment>]? ", - PhpMixed::String( - if 1 == packages.len() { "" } else { "s" }.to_string(), - ), + if 1 == packages.len() { "" } else { "s" }.to_string(), ), true, ) { diff --git a/crates/shirabe/src/config/json_config_source.rs b/crates/shirabe/src/config/json_config_source.rs index 85bd12e..3e0d285 100644 --- a/crates/shirabe/src/config/json_config_source.rs +++ b/crates/shirabe/src/config/json_config_source.rs @@ -37,7 +37,7 @@ impl JsonConfigSource { return Err(RuntimeException { message: format!( "The file \"{}\" is not writable.", - PhpMixed::String(self.file.borrow().get_path().to_string()), + self.file.borrow().get_path().to_string(), ), code: 0, } @@ -48,7 +48,7 @@ impl JsonConfigSource { return Err(RuntimeException { message: format!( "The file \"{}\" is not readable.", - PhpMixed::String(self.file.borrow().get_path().to_string()), + self.file.borrow().get_path().to_string(), ), code: 0, } @@ -401,7 +401,7 @@ impl ConfigSourceInterface for JsonConfigSource { return Err(RuntimeException { message: format!( "The referenced repository \"{}\" does not exist.", - PhpMixed::String(reference_name.to_string()), + reference_name.to_string(), ), code: 0, } diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 7f22a65..251fc67 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -549,7 +549,7 @@ impl Application { if !composer::BRANCH_ALIAS_VERSION.is_empty() && composer::BRANCH_ALIAS_VERSION != "@package_branch_alias_version@" { - branch_alias_string = format!(" ({})", composer::BRANCH_ALIAS_VERSION,); + branch_alias_string = format!(" ({})", composer::BRANCH_ALIAS_VERSION); } format!( @@ -796,10 +796,7 @@ impl Application { ) -> anyhow::Result<std::rc::Rc<std::cell::RefCell<dyn SymfonyCommand>>> { if !self.has(name) { return Err(CommandNotFoundException::new( - format!( - "The command \"{}\" does not exist.", - PhpMixed::from(name.to_string()), - ), + format!("The command \"{}\" does not exist.", name.to_string()), Vec::new(), 0, ) @@ -811,7 +808,7 @@ impl Application { return Err(CommandNotFoundException::new( format!( "The \"{}\" command cannot be found because it is registered under multiple names. Make sure you don't set a different name via constructor or \"setName()\".", - PhpMixed::from(name.to_string()), + name.to_string(), ), Vec::new(), 0, @@ -914,7 +911,7 @@ impl Application { if namespaces.is_empty() { let mut message = format!( "There are no commands defined in the \"{}\" namespace.", - PhpMixed::from(namespace.to_string()), + namespace.to_string(), ); let alternatives = self.find_alternatives(namespace, &all_namespaces); @@ -941,8 +938,8 @@ impl Application { return Err(NamespaceNotFoundException(CommandNotFoundException::new( format!( "The namespace \"{}\" is ambiguous.\nDid you mean one of these?\n{}.", - PhpMixed::from(namespace.to_string()), - PhpMixed::from(self.get_abbreviation_suggestions(&namespaces)), + namespace.to_string(), + self.get_abbreviation_suggestions(&namespaces), ), namespaces.clone(), 0, @@ -1143,8 +1140,8 @@ impl Application { return Err(CommandNotFoundException::new( format!( "SymfonyCommand \"{}\" is ambiguous.\nDid you mean one of these?\n{}.", - PhpMixed::from(name.to_string()), - PhpMixed::from(suggestions), + name.to_string(), + suggestions, ), commands.clone(), 0, @@ -1159,10 +1156,7 @@ impl Application { if command.borrow().is_hidden() { return Err(CommandNotFoundException::new( - format!( - "The command \"{}\" does not exist.", - PhpMixed::from(name.to_string()), - ), + format!("The command \"{}\" does not exist.", name.to_string()), Vec::new(), 0, ) @@ -1885,7 +1879,7 @@ impl ApplicationHandle { return Err(ConsoleLogicException(shirabe_php_shim::LogicException { message: format!( "The command defined in \"{}\" cannot have an empty name.", - PhpMixed::from(shirabe_php_shim::get_debug_type_obj(&command)), + shirabe_php_shim::get_debug_type_obj(&command), ), code: 0, }) @@ -2804,7 +2798,7 @@ impl ApplicationHandle { let formatted_block = FormatterHelper::default().format_block( FormatBlockMessages::String(format!( "Command \"{}\" is not defined.", - PhpMixed::from(name.clone()), + name.clone(), )), "error", true, @@ -2813,10 +2807,7 @@ impl ApplicationHandle { .borrow() .writeln(&[formatted_block], output_interface::OUTPUT_NORMAL); if !style.confirm( - &format!( - "Do you want to run \"{}\" instead? ", - PhpMixed::from(alternative.clone()), - ), + &format!("Do you want to run \"{}\" instead? ", alternative.clone()), false, ) { return Ok(1); diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs index 23b025f..15275a9 100644 --- a/crates/shirabe/src/downloader/download_manager.rs +++ b/crates/shirabe/src/downloader/download_manager.rs @@ -112,8 +112,8 @@ impl DownloadManager { return Err(InvalidArgumentException { message: format!( "Unknown downloader type: {}. Available types: {}.", - PhpMixed::String(r#type), - PhpMixed::String(implode(", ", &array_keys(&self.downloaders))), + r#type, + implode(", ", &array_keys(&self.downloaders)), ), code: 0, } @@ -159,10 +159,10 @@ impl DownloadManager { return Err(LogicException { message: format!( "Downloader \"{}\" is a {} type downloader and can not be used to download {} for package {}", - PhpMixed::String(shirabe_php_shim::get_class_obj(&*downloader.borrow())), - PhpMixed::String(downloader_installation_source), - PhpMixed::String(installation_source.clone().unwrap_or_default()), - PhpMixed::String(package.to_string()), + shirabe_php_shim::get_class_obj(&*downloader.borrow()), + downloader_installation_source, + installation_source.clone().unwrap_or_default(), + package.to_string(), ), code: 0, } diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index 0a6e242..fa7fd16 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -811,10 +811,7 @@ impl VcsDownloader for GitDownloader { io_interface::NORMAL, ); self.inner.io.write_error3( - &format!( - " Cloning to cache at {}", - PhpMixed::String(cache_path.clone()), - ), + &format!(" Cloning to cache at {}", cache_path.clone()), true, io_interface::DEBUG, ); diff --git a/crates/shirabe/src/downloader/vcs_downloader.rs b/crates/shirabe/src/downloader/vcs_downloader.rs index 482a343..78b3ae7 100644 --- a/crates/shirabe/src/downloader/vcs_downloader.rs +++ b/crates/shirabe/src/downloader/vcs_downloader.rs @@ -161,7 +161,7 @@ pub trait VcsDownloader: } if self.io().is_debug() { self.io().write_error3( - &format!("Failed: [{}] {}", get_class_err(&e), e,), + &format!("Failed: [{}] {}", get_class_err(&e), e), true, io_interface::NORMAL, ); @@ -265,7 +265,7 @@ pub trait VcsDownloader: } if self.io().is_debug() { self.io().write_error3( - &format!("Failed: [{}] {}", get_class_err(&e), e,), + &format!("Failed: [{}] {}", get_class_err(&e), e), true, io_interface::NORMAL, ); @@ -334,7 +334,7 @@ pub trait VcsDownloader: } if self.io().is_debug() { self.io().write_error3( - &format!("Failed: [{}] {}", get_class_err(&e), e,), + &format!("Failed: [{}] {}", get_class_err(&e), e), true, io_interface::NORMAL, ); diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index d3b5fad..3ef7661 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -343,8 +343,8 @@ impl EventDispatcher { self.io.write_error3( &format!( "> {}: {}", - PhpMixed::String(formatted_event_name_with_args.clone()), - PhpMixed::String(format!("{}->{}", prefix, method_name)), + formatted_event_name_with_args.clone(), + format!("{}->{}", prefix, method_name), ), true, crate::io::VERBOSE, @@ -358,8 +358,8 @@ impl EventDispatcher { self.io.write_error3( &format!( "> {}: {}", - PhpMixed::String(formatted_event_name_with_args.clone()), - PhpMixed::String(callable_str.clone()), + formatted_event_name_with_args.clone(), + callable_str.clone(), ), true, crate::io::VERBOSE, @@ -416,8 +416,8 @@ impl EventDispatcher { if exit_code != 0 { self.io.write_error3(&format!( "<error>Script {} handling the {} event returned with error code {}</error>", - PhpMixed::String(callable_str.clone()), - PhpMixed::String(event.get_name().to_string()), + callable_str.clone(), + event.get_name().to_string(), exit_code ), true, crate::io::QUIET); @@ -442,7 +442,7 @@ impl EventDispatcher { { self.io.write_error3(&format!( "<warning>You made a reference to a non-existent script {}</warning>", - PhpMixed::String(callable_str.clone()), + callable_str.clone(), ), true, crate::io::QUIET); } @@ -469,8 +469,8 @@ impl EventDispatcher { self.io.write_error3( &format!( "<error>Script {} was called via {}</error>", - PhpMixed::String(callable_str.clone()), - PhpMixed::String(event.get_name().to_string()), + callable_str.clone(), + event.get_name().to_string(), ), true, crate::io::QUIET, @@ -513,8 +513,8 @@ impl EventDispatcher { self.io.write_error3( &format!( "<error>Script {} handling the {} event terminated with an exception</error>", - PhpMixed::String(callable_str.clone()), - PhpMixed::String(event.get_name().to_string()), + callable_str.clone(), + event.get_name().to_string(), ), true, crate::io::QUIET, @@ -613,17 +613,13 @@ impl EventDispatcher { if self.io.is_verbose() { self.io.write_error3( - &format!( - "> {}: {}", - PhpMixed::String(event.get_name().to_string()), - PhpMixed::String(exec.clone()), - ), + &format!("> {}: {}", event.get_name().to_string(), exec.clone()), true, crate::io::NORMAL, ); } else if self.event_needs_to_output(event) { self.io.write_error3( - &format!("> {}", PhpMixed::String(exec.clone())), + &format!("> {}", exec.clone()), true, crate::io::NORMAL, ); @@ -741,8 +737,8 @@ impl EventDispatcher { if exit_code != 0 { self.io.write_error3(&format!( "<error>Script {} handling the {} event returned with error code {}</error>", - PhpMixed::String(callable_str.clone()), - PhpMixed::String(event.get_name().to_string()), + callable_str.clone(), + event.get_name().to_string(), exit_code ), true, crate::io::QUIET); @@ -843,20 +839,16 @@ impl EventDispatcher { self.io.write_error3( &format!( "> {}: {}::{}", - PhpMixed::String(event.get_name().to_string()), - PhpMixed::String(class_name.to_string()), - PhpMixed::String(method_name.to_string()), + event.get_name().to_string(), + class_name.to_string(), + method_name.to_string(), ), true, crate::io::NORMAL, ); } else if self.event_needs_to_output(event) { self.io.write_error3( - &format!( - "> {}::{}", - PhpMixed::String(class_name.to_string()), - PhpMixed::String(method_name.to_string()), - ), + &format!("> {}::{}", class_name.to_string(), method_name.to_string()), true, crate::io::NORMAL, ); diff --git a/crates/shirabe/src/installed_versions.rs b/crates/shirabe/src/installed_versions.rs index 3e43f90..fb93172 100644 --- a/crates/shirabe/src/installed_versions.rs +++ b/crates/shirabe/src/installed_versions.rs @@ -452,7 +452,7 @@ impl InstalledVersions { installed.push(cached); } else if is_file(&format!("{}/composer/installed.php", vendor_dir)) { let required = - require_php_file(&format!("{}/composer/installed.php", vendor_dir,)); + require_php_file(&format!("{}/composer/installed.php", vendor_dir)); let required_map: IndexMap<String, PhpMixed> = required.as_array().cloned().unwrap_or_default(); INSTALLED_BY_VENDOR diff --git a/crates/shirabe/src/io/console_io.rs b/crates/shirabe/src/io/console_io.rs index c83308c..1876db4 100644 --- a/crates/shirabe/src/io/console_io.rs +++ b/crates/shirabe/src/io/console_io.rs @@ -106,14 +106,7 @@ impl ConsoleIO { }; let mapped: Vec<String> = arr .into_iter() - .map(|message| { - format!( - "[{:.1}MiB/{:.2}s] {}", - memory_usage, - time_spent, - PhpMixed::String(message), - ) - }) + .map(|message| format!("[{:.1}MiB/{:.2}s] {}", memory_usage, time_spent, message)) .collect(); PhpMixed::List(mapped.into_iter().map(PhpMixed::String).collect()) } else { diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index 0aada36..e6cd990 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -385,7 +385,7 @@ impl JsonFile { let mut m = indexmap::IndexMap::new(); m.insert( "$ref".to_string(), - PhpMixed::String(format!("{}#/properties/config", schema_file,)), + PhpMixed::String(format!("{}#/properties/config", schema_file)), ); m.insert( "$schema".to_string(), diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs index 0411645..844b3ef 100644 --- a/crates/shirabe/src/package/loader/array_loader.rs +++ b/crates/shirabe/src/package/loader/array_loader.rs @@ -385,14 +385,13 @@ impl ArrayLoader { return Err(UnexpectedValueException { message: format!( "Package {}'s source key should be specified as {{\"type\": ..., \"url\": ..., \"reference\": ...}},\n{} given.", - PhpMixed::String( + config .get("name") .and_then(|v| v.as_string()) .unwrap_or("") .to_string(), - ), - PhpMixed::String(json_encode(&source).unwrap_or_default()), + json_encode(&source).unwrap_or_default(), ), code: 0, } @@ -428,14 +427,13 @@ impl ArrayLoader { return Err(UnexpectedValueException { message: format!( "Package {}'s dist key should be specified as {{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...}},\n{} given.", - PhpMixed::String( + config .get("name") .and_then(|v| v.as_string()) .unwrap_or("") .to_string(), - ), - PhpMixed::String(json_encode(&dist).unwrap_or_default()), + json_encode(&dist).unwrap_or_default(), ), code: 0, } diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs index 50374d2..16b905e 100644 --- a/crates/shirabe/src/package/loader/root_package_loader.rs +++ b/crates/shirabe/src/package/loader/root_package_loader.rs @@ -266,7 +266,7 @@ impl RootPackageLoader { for (req_name, req_version) in requires { let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); if Preg::is_match3( - r"(?:^|\| *|, *)([^,\s#|]+)(?:#[^ ]+)? +as +([^,\s|]+)(?:$| *\|| *,)", + r"(?:^|\| *|, *)([^,\s#|]+)(?:#[^ ]+)? +as +([^,\s|]+)(?:$| *\|| *)", req_version, Some(&mut m), ) { diff --git a/crates/shirabe/src/package/loader/validating_array_loader.rs b/crates/shirabe/src/package/loader/validating_array_loader.rs index 8081664..342e1cb 100644 --- a/crates/shirabe/src/package/loader/validating_array_loader.rs +++ b/crates/shirabe/src/package/loader/validating_array_loader.rs @@ -196,7 +196,7 @@ impl ValidatingArrayLoader { if !is_string(&license) { self.warnings.push(format!( "License {} should be a string.", - PhpMixed::String(json_encode(&license).unwrap_or_default()), + json_encode(&license).unwrap_or_default(), )); licenses.shift_remove(index); } @@ -219,18 +219,15 @@ impl ValidatingArrayLoader { { self.warnings.push(format!( "License {} must not contain extra spaces, make sure to trim it.", - PhpMixed::String( json_encode(&PhpMixed::String(license_str.clone())) .unwrap_or_default(), - ), )); } else { self.warnings.push(format!( "License {} is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.{}If the software is closed-source, you may use \"proprietary\" as license.", - PhpMixed::String( + json_encode(&PhpMixed::String(license_str.clone())) .unwrap_or_default(), - ), PHP_EOL )); } @@ -248,7 +245,7 @@ impl ValidatingArrayLoader { } else { self.warnings.push(format!( "License must be a string or array of strings, got {}.", - PhpMixed::String(json_encode(&license_val).unwrap_or_default(),), + json_encode(&license_val).unwrap_or_default(), )); self.config.shift_remove("license"); } diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs index 155d5d4..a034497 100644 --- a/crates/shirabe/src/package/locker.rs +++ b/crates/shirabe/src/package/locker.rs @@ -730,7 +730,7 @@ impl Locker { return Err(LogicException { message: format!( "Package \"{}\" has no version or name and can not be locked", - PhpMixed::String(package.to_string()), + package.to_string(), ), code: 0, } @@ -955,14 +955,12 @@ impl Locker { description = format!( "{} as {} by {}", verb, - PhpMixed::String( - provider_link.get_pretty_constraint().to_string(), - ), - PhpMixed::String(format!( + provider_link.get_pretty_constraint().to_string(), + format!( "{} {}", provider.get_pretty_name(), provider.get_pretty_version() - )), + ), ); break 'outer; } diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs index 2f74eaf..670bfb4 100644 --- a/crates/shirabe/src/repository/filesystem_repository.rs +++ b/crates/shirabe/src/repository/filesystem_repository.rs @@ -327,7 +327,7 @@ impl FilesystemRepository { self.filesystem.borrow_mut().file_put_contents_if_modified( &format!("{}/installed.php", repo_dir), - &format!("<?php return {};\n", self.dump_to_php_code(&versions, 0),), + &format!("<?php return {};\n", self.dump_to_php_code(&versions, 0)), ); self.filesystem.borrow_mut().file_put_contents_if_modified( &format!("{}/InstalledVersions.php", repo_dir), @@ -422,7 +422,7 @@ impl FilesystemRepository { } else if key == "install_path" && is_string(value) { let s = value.as_string().unwrap_or("").to_string(); if self.filesystem.borrow_mut().is_absolute_path(&s) { - lines.push_str(&format!("{},\n", var_export(&PhpMixed::String(s), true),)); + lines.push_str(&format!("{},\n", var_export(&PhpMixed::String(s), true))); } else { lines.push_str(&format!( "__DIR__ . {},\n", diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs index e006d19..26005e2 100644 --- a/crates/shirabe/src/repository/platform_repository.rs +++ b/crates/shirabe/src/repository/platform_repository.rs @@ -1278,9 +1278,9 @@ impl PlatformRepository { .unwrap_or(0); let version_built = format!( "{}.{}.{}", - PhpMixed::Int((lib_rd_kafka_version_int & 0x7F000000) >> 24), - PhpMixed::Int((lib_rd_kafka_version_int & 0x00FF0000) >> 16), - PhpMixed::Int((lib_rd_kafka_version_int & 0x0000FF00) >> 8), + (lib_rd_kafka_version_int & 0x7F000000) >> 24, + (lib_rd_kafka_version_int & 0x00FF0000) >> 16, + (lib_rd_kafka_version_int & 0x0000FF00) >> 8, ); self.add_library( &mut libraries, diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index fb450d8..b5469ec 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -95,7 +95,7 @@ impl GitBitbucketDriver { return Err(InvalidArgumentException { message: format!( "The Bitbucket repository URL {} is invalid. It must be the HTTPS URL of a Bitbucket repository.", - PhpMixed::String(self.inner.url.clone()), + self.inner.url.clone(), ), code: 0, } @@ -154,9 +154,9 @@ impl GitBitbucketDriver { fn get_repo_data(&mut self) -> Result<bool> { let resource = format!( "https://api.bitbucket.org/2.0/repositories/{}/{}?{}", - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), - PhpMixed::String(http_build_query_mixed( + self.owner.clone(), + self.repository.clone(), + http_build_query_mixed( &{ let mut m: IndexMap<String, PhpMixed> = IndexMap::new(); m.insert( @@ -167,7 +167,7 @@ impl GitBitbucketDriver { }, "", "&", - )), + ), ); let repo_data = self @@ -349,9 +349,9 @@ impl GitBitbucketDriver { "source".to_string(), PhpMixed::String(format!( "https://{}/{}/{}/src", - PhpMixed::String(self.inner.origin_url.clone()), - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), + self.inner.origin_url.clone(), + self.owner.clone(), + self.repository.clone(), )), ); } @@ -360,11 +360,11 @@ impl GitBitbucketDriver { "source".to_string(), PhpMixed::String(format!( "https://{}/{}/{}/src/{}/?at={}", - PhpMixed::String(self.inner.origin_url.clone()), - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), - PhpMixed::String(hash.unwrap()), - PhpMixed::String(label.clone()), + self.inner.origin_url.clone(), + self.owner.clone(), + self.repository.clone(), + hash.unwrap(), + label.clone(), )), ); } @@ -385,9 +385,9 @@ impl GitBitbucketDriver { "issues".to_string(), PhpMixed::String(format!( "https://{}/{}/{}/issues", - PhpMixed::String(self.inner.origin_url.clone()), - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), + self.inner.origin_url.clone(), + self.owner.clone(), + self.repository.clone(), )), ); } @@ -429,10 +429,10 @@ impl GitBitbucketDriver { let resource = format!( "https://api.bitbucket.org/2.0/repositories/{}/{}/src/{}/{}", - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), - PhpMixed::String(identifier), - PhpMixed::String(file.to_string()), + self.owner.clone(), + self.repository.clone(), + identifier, + file.to_string(), ); Ok(self @@ -457,9 +457,9 @@ impl GitBitbucketDriver { let resource = format!( "https://api.bitbucket.org/2.0/repositories/{}/{}/commit/{}?fields=date", - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), - PhpMixed::String(identifier), + self.owner.clone(), + self.repository.clone(), + identifier, ); let commit = self .fetch_with_oauth_credentials(&resource, false)? @@ -498,9 +498,9 @@ impl GitBitbucketDriver { let url = format!( "https://bitbucket.org/{}/{}/get/{}.zip", - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), - PhpMixed::String(identifier.to_string()), + self.owner.clone(), + self.repository.clone(), + identifier.to_string(), ); let mut m: IndexMap<String, String> = IndexMap::new(); @@ -521,8 +521,8 @@ impl GitBitbucketDriver { let mut tags: IndexMap<String, String> = IndexMap::new(); let mut resource = format!( "{}?{}", - PhpMixed::String(self.tags_url.clone()), - PhpMixed::String(http_build_query_mixed( + self.tags_url.clone(), + http_build_query_mixed( &{ let mut m: IndexMap<String, PhpMixed> = IndexMap::new(); m.insert("pagelen".to_string(), PhpMixed::Int(100)); @@ -538,7 +538,7 @@ impl GitBitbucketDriver { }, "", "&", - )), + ), ); let mut has_next = true; while has_next { @@ -600,8 +600,8 @@ impl GitBitbucketDriver { let mut branches: IndexMap<String, String> = IndexMap::new(); let mut resource = format!( "{}?{}", - PhpMixed::String(self.branches_url.clone()), - PhpMixed::String(http_build_query_mixed( + self.branches_url.clone(), + http_build_query_mixed( &{ let mut m: IndexMap<String, PhpMixed> = IndexMap::new(); m.insert("pagelen".to_string(), PhpMixed::Int(100)); @@ -619,7 +619,7 @@ impl GitBitbucketDriver { }, "", "&", - )), + ), ); let mut has_next = true; while has_next { diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index e9956a9..bea7294 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -82,7 +82,7 @@ impl GitHubDriver { return Err(InvalidArgumentException { message: format!( "The GitHub repository URL {} is invalid.", - PhpMixed::String(self.inner.url.clone()), + self.inner.url.clone(), ), code: 0, } @@ -364,10 +364,10 @@ impl GitHubDriver { "source".to_string(), PhpMixed::String(format!( "https://{}/{}/{}/tree/{}", - PhpMixed::String(self.inner.origin_url.clone()), - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), - PhpMixed::String(label_str), + self.inner.origin_url.clone(), + self.owner.clone(), + self.repository.clone(), + label_str, )), ); } @@ -388,9 +388,9 @@ impl GitHubDriver { "issues".to_string(), PhpMixed::String(format!( "https://{}/{}/{}/issues", - PhpMixed::String(self.inner.origin_url.clone()), - PhpMixed::String(self.owner.clone()), - PhpMixed::String(self.repository.clone()), + self.inner.origin_url.clone(), + self.owner.clone(), + self.repository.clone(), )), ); } diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index e0fb72e..f1f361e 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -88,7 +88,7 @@ impl GitLabDriver { return Err(InvalidArgumentException { message: format!( "The GitLab repository URL {} is invalid. It must be the HTTP URL of a GitLab project.", - PhpMixed::String(self.inner.url.clone()), + self.inner.url.clone(), ), code: 0, } @@ -357,11 +357,7 @@ impl GitLabDriver { }) { support.insert( "source".to_string(), - PhpMixed::String(format!( - "{}/-/tree/{}", - PhpMixed::String(web_url), - PhpMixed::String(label_str), - )), + PhpMixed::String(format!("{}/-/tree/{}", web_url, label_str)), ); } } @@ -388,7 +384,7 @@ impl GitLabDriver { }) { support.insert( "issues".to_string(), - PhpMixed::String(format!("{}/-/issues", PhpMixed::String(web_url),)), + PhpMixed::String(format!("{}/-/issues", PhpMixed::String(web_url))), ); } } diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs index d8b77ac..0b1620d 100644 --- a/crates/shirabe/src/util/auth_helper.rs +++ b/crates/shirabe/src/util/auth_helper.rs @@ -418,7 +418,7 @@ impl AuthHelper { } self.io.write_error3( - &format!(" Authentication required (<info>{}</info>):", origin,), + &format!(" Authentication required (<info>{}</info>):", origin), true, io_interface::NORMAL, ); diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs index 94e703d..4b8348f 100644 --- a/crates/shirabe/src/util/http/curl_downloader.rs +++ b/crates/shirabe/src/util/http/curl_downloader.rs @@ -1548,15 +1548,13 @@ impl CurlDownloader { self.io.write_error3( &format!( "Following redirect ({}) {}", - PhpMixed::Int( - job.get("attributes") - .and_then(|v| v.as_array()) - .and_then(|a| a.get("redirects")) - .and_then(|b| b.as_int()) - .unwrap_or(0) - + 1, - ), - PhpMixed::String(Url::sanitize(target_url.clone())), + job.get("attributes") + .and_then(|v| v.as_array()) + .and_then(|a| a.get("redirects")) + .and_then(|b| b.as_int()) + .unwrap_or(0) + + 1, + Url::sanitize(target_url.clone()), ), true, crate::io::DEBUG, diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index e36a174..2a15cf0 100644 --- a/crates/shirabe/src/util/remote_filesystem.rs +++ b/crates/shirabe/src/util/remote_filesystem.rs @@ -951,8 +951,8 @@ impl RemoteFilesystem { self.io.write_error3( &format!( "Following redirect ({}) {}", - PhpMixed::Int(self.redirects), - PhpMixed::String(Url::sanitize(target_url.clone())), + self.redirects, + Url::sanitize(target_url.clone()), ), true, crate::io::DEBUG, |
