aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/advisory/auditor.rs2
-rw-r--r--crates/shirabe/src/advisory/ignored_security_advisory.rs1
-rw-r--r--crates/shirabe/src/advisory/partial_security_advisory.rs2
-rw-r--r--crates/shirabe/src/autoload/autoload_generator.rs23
-rw-r--r--crates/shirabe/src/autoload/class_loader.rs3
-rw-r--r--crates/shirabe/src/command/about_command.rs8
-rw-r--r--crates/shirabe/src/command/archive_command.rs4
-rw-r--r--crates/shirabe/src/command/audit_command.rs11
-rw-r--r--crates/shirabe/src/command/base_command.rs6
-rw-r--r--crates/shirabe/src/command/base_config_command.rs2
-rw-r--r--crates/shirabe/src/command/base_dependency_command.rs137
-rw-r--r--crates/shirabe/src/command/bump_command.rs11
-rw-r--r--crates/shirabe/src/command/check_platform_reqs_command.rs7
-rw-r--r--crates/shirabe/src/command/clear_cache_command.rs1
-rw-r--r--crates/shirabe/src/command/config_command.rs52
-rw-r--r--crates/shirabe/src/command/create_project_command.rs67
-rw-r--r--crates/shirabe/src/command/depends_command.rs7
-rw-r--r--crates/shirabe/src/command/diagnose_command.rs37
-rw-r--r--crates/shirabe/src/command/dump_autoload_command.rs6
-rw-r--r--crates/shirabe/src/command/exec_command.rs6
-rw-r--r--crates/shirabe/src/command/fund_command.rs13
-rw-r--r--crates/shirabe/src/command/global_command.rs12
-rw-r--r--crates/shirabe/src/command/home_command.rs9
-rw-r--r--crates/shirabe/src/command/init_command.rs18
-rw-r--r--crates/shirabe/src/command/install_command.rs8
-rw-r--r--crates/shirabe/src/command/licenses_command.rs13
-rw-r--r--crates/shirabe/src/command/outdated_command.rs5
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs19
-rw-r--r--crates/shirabe/src/command/prohibits_command.rs7
-rw-r--r--crates/shirabe/src/command/reinstall_command.rs10
-rw-r--r--crates/shirabe/src/command/remove_command.rs14
-rw-r--r--crates/shirabe/src/command/repository_command.rs5
-rw-r--r--crates/shirabe/src/command/require_command.rs31
-rw-r--r--crates/shirabe/src/command/run_script_command.rs5
-rw-r--r--crates/shirabe/src/command/script_alias_command.rs6
-rw-r--r--crates/shirabe/src/command/search_command.rs5
-rw-r--r--crates/shirabe/src/command/self_update_command.rs6
-rw-r--r--crates/shirabe/src/command/show_command.rs44
-rw-r--r--crates/shirabe/src/command/status_command.rs8
-rw-r--r--crates/shirabe/src/command/suggests_command.rs7
-rw-r--r--crates/shirabe/src/command/update_command.rs15
-rw-r--r--crates/shirabe/src/command/validate_command.rs8
-rw-r--r--crates/shirabe/src/config.rs8
-rw-r--r--crates/shirabe/src/config/json_config_source.rs8
-rw-r--r--crates/shirabe/src/console/application.rs34
-rw-r--r--crates/shirabe/src/dependency_resolver/default_policy.rs1
-rw-r--r--crates/shirabe/src/dependency_resolver/pool.rs1
-rw-r--r--crates/shirabe/src/dependency_resolver/pool_builder.rs9
-rw-r--r--crates/shirabe/src/dependency_resolver/pool_optimizer.rs3
-rw-r--r--crates/shirabe/src/dependency_resolver/problem.rs12
-rw-r--r--crates/shirabe/src/dependency_resolver/request.rs2
-rw-r--r--crates/shirabe/src/dependency_resolver/rule.rs10
-rw-r--r--crates/shirabe/src/dependency_resolver/rule_set.rs1
-rw-r--r--crates/shirabe/src/dependency_resolver/rule_set_generator.rs2
-rw-r--r--crates/shirabe/src/dependency_resolver/solver.rs5
-rw-r--r--crates/shirabe/src/downloader/archive_downloader.rs8
-rw-r--r--crates/shirabe/src/downloader/download_manager.rs6
-rw-r--r--crates/shirabe/src/downloader/file_downloader.rs28
-rw-r--r--crates/shirabe/src/downloader/git_downloader.rs5
-rw-r--r--crates/shirabe/src/downloader/path_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/perforce_downloader.rs6
-rw-r--r--crates/shirabe/src/downloader/svn_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/vcs_downloader.rs5
-rw-r--r--crates/shirabe/src/downloader/zip_downloader.rs99
-rw-r--r--crates/shirabe/src/event_dispatcher/event_dispatcher.rs46
-rw-r--r--crates/shirabe/src/factory.rs23
-rw-r--r--crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs2
-rw-r--r--crates/shirabe/src/installed_versions.rs2
-rw-r--r--crates/shirabe/src/installer.rs29
-rw-r--r--crates/shirabe/src/installer/binary_installer.rs6
-rw-r--r--crates/shirabe/src/installer/installation_manager.rs8
-rw-r--r--crates/shirabe/src/installer/library_installer.rs2
-rw-r--r--crates/shirabe/src/installer/plugin_installer.rs2
-rw-r--r--crates/shirabe/src/installer/suggested_packages_reporter.rs6
-rw-r--r--crates/shirabe/src/io/buffer_io.rs4
-rw-r--r--crates/shirabe/src/io/console_io.rs4
-rw-r--r--crates/shirabe/src/json/json_file.rs2
-rw-r--r--crates/shirabe/src/json/json_manipulator.rs10
-rw-r--r--crates/shirabe/src/package/alias_package.rs1
-rw-r--r--crates/shirabe/src/package/archiver/archive_manager.rs2
-rw-r--r--crates/shirabe/src/package/loader/array_loader.rs28
-rw-r--r--crates/shirabe/src/package/loader/root_package_loader.rs9
-rw-r--r--crates/shirabe/src/package/loader/validating_array_loader.rs6
-rw-r--r--crates/shirabe/src/package/locker.rs42
-rw-r--r--crates/shirabe/src/package/version/version_guesser.rs17
-rw-r--r--crates/shirabe/src/package/version/version_selector.rs3
-rw-r--r--crates/shirabe/src/phpstan/mod.rs3
-rw-r--r--crates/shirabe/src/plugin/plugin_manager.rs67
-rw-r--r--crates/shirabe/src/question/strict_confirmation_question.rs6
-rw-r--r--crates/shirabe/src/repository/advisory_provider_interface.rs2
-rw-r--r--crates/shirabe/src/repository/array_repository.rs1
-rw-r--r--crates/shirabe/src/repository/artifact_repository.rs1
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs50
-rw-r--r--crates/shirabe/src/repository/composite_repository.rs2
-rw-r--r--crates/shirabe/src/repository/filesystem_repository.rs9
-rw-r--r--crates/shirabe/src/repository/handle.rs5
-rw-r--r--crates/shirabe/src/repository/installed_repository.rs4
-rw-r--r--crates/shirabe/src/repository/package_repository.rs1
-rw-r--r--crates/shirabe/src/repository/path_repository.rs2
-rw-r--r--crates/shirabe/src/repository/platform_repository.rs8
-rw-r--r--crates/shirabe/src/repository/repository_factory.rs3
-rw-r--r--crates/shirabe/src/repository/repository_set.rs12
-rw-r--r--crates/shirabe/src/repository/repository_utils.rs1
-rw-r--r--crates/shirabe/src/repository/vcs/forgejo_driver.rs5
-rw-r--r--crates/shirabe/src/repository/vcs/fossil_driver.rs4
-rw-r--r--crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs65
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs10
-rw-r--r--crates/shirabe/src/repository/vcs/gitlab_driver.rs11
-rw-r--r--crates/shirabe/src/repository/vcs/hg_driver.rs3
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs12
-rw-r--r--crates/shirabe/src/repository/vcs/vcs_driver.rs3
-rw-r--r--crates/shirabe/src/repository/vcs_repository.rs1
-rw-r--r--crates/shirabe/src/util/auth_helper.rs8
-rw-r--r--crates/shirabe/src/util/bitbucket.rs2
-rw-r--r--crates/shirabe/src/util/error_handler.rs2
-rw-r--r--crates/shirabe/src/util/filesystem.rs19
-rw-r--r--crates/shirabe/src/util/git.rs27
-rw-r--r--crates/shirabe/src/util/github.rs1
-rw-r--r--crates/shirabe/src/util/http/curl_downloader.rs11
-rw-r--r--crates/shirabe/src/util/http_downloader.rs2
-rw-r--r--crates/shirabe/src/util/package_sorter.rs1
-rw-r--r--crates/shirabe/src/util/perforce.rs4
-rw-r--r--crates/shirabe/src/util/process_executor.rs41
-rw-r--r--crates/shirabe/src/util/remote_filesystem.rs2
-rw-r--r--crates/shirabe/src/util/stream_context_factory.rs5
-rw-r--r--crates/shirabe/src/util/svn.rs12
126 files changed, 611 insertions, 989 deletions
diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs
index 6c520fb..627b900 100644
--- a/crates/shirabe/src/advisory/auditor.rs
+++ b/crates/shirabe/src/advisory/auditor.rs
@@ -1,6 +1,5 @@
//! ref: composer/src/Composer/Advisory/Auditor.php
-use crate::io::io_interface;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
@@ -18,7 +17,6 @@ use crate::json::JsonFile;
use crate::package::CompletePackageInterfaceHandle;
use crate::package::PackageInterfaceHandle;
use crate::package::base_package;
-use crate::package::base_package::BasePackage;
use crate::repository::RepositorySet;
use crate::util::PackageInfo;
diff --git a/crates/shirabe/src/advisory/ignored_security_advisory.rs b/crates/shirabe/src/advisory/ignored_security_advisory.rs
index 7bcb823..4305782 100644
--- a/crates/shirabe/src/advisory/ignored_security_advisory.rs
+++ b/crates/shirabe/src/advisory/ignored_security_advisory.rs
@@ -3,7 +3,6 @@
use crate::advisory::SecurityAdvisory;
use chrono::{DateTime, Utc};
use indexmap::IndexMap;
-use shirabe_php_shim::PhpMixed;
use shirabe_semver::constraint::AnyConstraint;
#[derive(Debug, Clone, serde::Serialize)]
diff --git a/crates/shirabe/src/advisory/partial_security_advisory.rs b/crates/shirabe/src/advisory/partial_security_advisory.rs
index 352e562..11b95bd 100644
--- a/crates/shirabe/src/advisory/partial_security_advisory.rs
+++ b/crates/shirabe/src/advisory/partial_security_advisory.rs
@@ -7,7 +7,7 @@ use anyhow::Result;
use chrono::{DateTime, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
-use shirabe_php_shim::{DATE_RFC3339, PhpMixed, UnexpectedValueException};
+use shirabe_php_shim::PhpMixed;
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
diff --git a/crates/shirabe/src/autoload/autoload_generator.rs b/crates/shirabe/src/autoload/autoload_generator.rs
index 1910136..1bdea07 100644
--- a/crates/shirabe/src/autoload/autoload_generator.rs
+++ b/crates/shirabe/src/autoload/autoload_generator.rs
@@ -7,14 +7,12 @@ use shirabe_class_map_generator::class_map_generator::ClassMapGenerator;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::console::formatter::OutputFormatter;
use shirabe_php_shim::{
- InvalidArgumentException, PhpMixed, RuntimeException, array_filter, array_keys, array_map,
- array_merge, array_merge_map, array_merge_recursive, array_reverse, array_shift, array_slice,
- array_slice_strs, array_unique, bin2hex, explode, file_exists, file_get_contents, hash,
- implode, in_array, is_array, krsort, ksort, ltrim, preg_quote, random_bytes, realpath, sprintf,
- str_contains, str_replace, str_starts_with, strlen, strpos, strtr, substr, substr_count, trim,
- unlink, var_export,
+ InvalidArgumentException, PhpMixed, array_keys, array_map, array_merge_map,
+ array_merge_recursive, array_shift, array_slice_strs, array_unique, bin2hex, explode,
+ file_exists, file_get_contents, hash, implode, is_array, ksort, ltrim, preg_quote,
+ random_bytes, realpath, str_contains, str_replace, str_starts_with, strlen, strpos, strtr,
+ substr, substr_count, trim, unlink, var_export,
};
-use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::Bound;
use crate::autoload::ClassLoader;
@@ -29,7 +27,6 @@ use crate::io::IOInterfaceImmutable;
use crate::io::NullIO;
use crate::json::JsonFile;
use crate::package::Locker;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
use crate::package::RootPackageInterfaceHandle;
use crate::repository::InstalledRepositoryInterface;
@@ -516,7 +513,7 @@ impl AutoloadGenerator {
if suffix.is_none() && Filesystem::is_readable(&format!("{}/autoload.php", vendor_path))
{
let content =
- file_get_contents(&format!("{}/autoload.php", vendor_path)).unwrap_or_default();
+ file_get_contents(format!("{}/autoload.php", vendor_path)).unwrap_or_default();
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
if Preg::match3(
"{ComposerAutoloaderInit([^:\\s]+)::}",
@@ -624,8 +621,8 @@ impl AutoloadGenerator {
&format!("{}/platform_check.php", target_dir),
platform_check_content.as_ref().unwrap(),
)?;
- } else if file_exists(&format!("{}/platform_check.php", target_dir)) {
- unlink(&format!("{}/platform_check.php", target_dir));
+ } else if file_exists(format!("{}/platform_check.php", target_dir)) {
+ unlink(format!("{}/platform_check.php", target_dir));
}
filesystem.file_put_contents_if_modified(
&format!("{}/autoload.php", vendor_path),
@@ -1562,7 +1559,7 @@ impl AutoloadGenerator {
let prefix = "\0Composer\\Autoload\\ClassLoader\0";
let prefix_len = strlen(prefix);
let mut maps: IndexMap<String, PhpMixed> = IndexMap::new();
- if file_exists(&format!("{}/autoload_files.php", target_dir)) {
+ if file_exists(format!("{}/autoload_files.php", target_dir)) {
maps.insert(
"files".to_string(),
require_generated_php_array(&format!("{}/autoload_files.php", target_dir)),
@@ -1687,7 +1684,7 @@ impl AutoloadGenerator {
};
// PHP: foreach ((array) $paths as $path) — handles scalar by wrapping in an array
let path_list: Vec<PhpMixed> = match &paths {
- PhpMixed::List(l) => l.iter().cloned().collect(),
+ PhpMixed::List(l) => l.to_vec(),
PhpMixed::Array(a) => a.values().cloned().collect(),
other => vec![other.clone()],
};
diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs
index daa5d97..3889ca0 100644
--- a/crates/shirabe/src/autoload/class_loader.rs
+++ b/crates/shirabe/src/autoload/class_loader.rs
@@ -4,8 +4,7 @@ use indexmap::IndexMap;
use std::sync::{LazyLock, Mutex};
use shirabe_php_shim::{
- DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, array_merge, array_values,
- call_user_func_array, defined, file_exists, function_exists, include_file, ini_get,
+ DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, defined, file_exists, include_file,
spl_autoload_register, spl_autoload_unregister, stream_resolve_include_path, strlen, strpos,
strrpos, strtr, substr,
};
diff --git a/crates/shirabe/src/command/about_command.rs b/crates/shirabe/src/command/about_command.rs
index 5306b89..6aae55d 100644
--- a/crates/shirabe/src/command/about_command.rs
+++ b/crates/shirabe/src/command/about_command.rs
@@ -1,24 +1,16 @@
//! ref: composer/src/Composer/Command/AboutCommand.php
use anyhow::Result;
-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 shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
use crate::composer;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
-use crate::io::IOInterfaceImmutable;
#[derive(Debug)]
pub struct AboutCommand {
diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs
index 7355d63..3b27b4c 100644
--- a/crates/shirabe/src/command/archive_command.rs
+++ b/crates/shirabe/src/command/archive_command.rs
@@ -6,11 +6,10 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
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, PhpMixed, get_debug_type};
+use shirabe_php_shim::{LogicException, get_debug_type};
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
use crate::composer::PartialComposerHandle;
@@ -18,7 +17,6 @@ use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::package::archiver::ArchiveManager;
diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs
index 2a4f8a7..e5dc231 100644
--- a/crates/shirabe/src/command/audit_command.rs
+++ b/crates/shirabe/src/command/audit_command.rs
@@ -1,13 +1,11 @@
//! ref: composer/src/Composer/Command/AuditCommand.php
use anyhow::Result;
-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 shirabe_php_shim::{
- InvalidArgumentException, PhpMixed, UnexpectedValueException, array_fill_keys, array_merge,
- implode, in_array,
+ InvalidArgumentException, PhpMixed, UnexpectedValueException, implode, in_array,
};
use std::cell::RefCell;
use std::rc::Rc;
@@ -18,14 +16,9 @@ use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::repository::CanonicalPackagesTrait;
-use crate::repository::InstalledRepository;
-use crate::repository::RepositoryInterface;
use crate::repository::RepositorySet;
use crate::repository::RepositoryUtils;
@@ -252,7 +245,7 @@ impl AuditCommand {
composer: &PartialComposerHandle,
input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
) -> Result<Vec<crate::package::PackageInterfaceHandle>> {
- let mut composer = crate::command::composer_full_mut(composer);
+ let composer = crate::command::composer_full_mut(composer);
if input
.borrow()
.get_option("locked")?
diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs
index f3c88e5..149dc09 100644
--- a/crates/shirabe/src/command/base_command.rs
+++ b/crates/shirabe/src/command/base_command.rs
@@ -12,8 +12,8 @@ use shirabe_external_packages::symfony::console::helper::TableSeparator;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
use shirabe_php_shim::{
- AsAny, InvalidArgumentException, LogicException, PhpMixed, RuntimeException,
- UnexpectedValueException, count, explode, in_array, is_string,
+ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, UnexpectedValueException,
+ count, explode, in_array, is_string,
};
use std::cell::RefCell;
use std::rc::Rc;
@@ -23,9 +23,7 @@ use crate::advisory::Auditor;
use crate::composer::PartialComposerHandle;
use crate::config::Config;
use crate::console::Application;
-use crate::console::input::InputArgument;
use crate::console::input::InputDefinitionItem;
-use crate::console::input::InputOption;
use crate::factory::Factory;
use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory;
use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
diff --git a/crates/shirabe/src/command/base_config_command.rs b/crates/shirabe/src/command/base_config_command.rs
index fa14197..b218961 100644
--- a/crates/shirabe/src/command/base_config_command.rs
+++ b/crates/shirabe/src/command/base_config_command.rs
@@ -1,6 +1,6 @@
//! ref: composer/src/Composer/Command/BaseConfigCommand.php
-use crate::command::{BaseCommand, BaseCommandData};
+use crate::command::BaseCommand;
use crate::config::Config;
use crate::config::JsonConfigSource;
use crate::factory::Factory;
diff --git a/crates/shirabe/src/command/base_dependency_command.rs b/crates/shirabe/src/command/base_dependency_command.rs
index 7bedf7d..ccae039 100644
--- a/crates/shirabe/src/command/base_dependency_command.rs
+++ b/crates/shirabe/src/command/base_dependency_command.rs
@@ -9,11 +9,8 @@ use shirabe_php_shim::{InvalidArgumentException, PhpMixed, UnexpectedValueExcept
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::Bound;
-use crate::command::{BaseCommand, BaseCommandData};
-use crate::io::IOInterface;
+use crate::command::BaseCommand;
use crate::io::IOInterfaceImmutable;
-use crate::package::CompletePackageInterface;
-use crate::package::Link;
use crate::package::Package;
use crate::package::RootPackage;
use crate::package::version::VersionParser;
@@ -47,7 +44,7 @@ pub trait BaseDependencyCommand: BaseCommand {
inverted: bool,
) -> anyhow::Result<i64> {
let composer = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer);
+ let composer = crate::command::composer_full_mut(&composer);
// TODO(plugin): dispatch CommandEvent(PluginEvents::COMMAND, self.get_name(), input, output) via composer.get_event_dispatcher()
let mut repos: Vec<crate::repository::RepositoryInterfaceHandle> =
@@ -148,79 +145,85 @@ pub trait BaseDependencyCommand: BaseCommand {
&needle,
FindPackageConstraint::String(text_constraint.clone()),
)?;
- if matched_package.is_none() {
- let rm = composer.get_repository_manager();
- let mut default_repos = CompositeRepository::new(
- RepositoryFactory::default_repos(
- Some(self.get_io()),
- Some(composer.get_config()),
- Some(&mut rm.borrow_mut()),
- )?
- .into_values()
- .collect(),
- );
- if let Some(r#match) = default_repos.find_package(
- &needle,
- FindPackageConstraint::String(text_constraint.clone()),
- )? {
- installed_repo.add_repository(crate::repository::RepositoryInterfaceHandle::new(
- InstalledArrayRepository::new_with_packages(vec![
- crate::package::PackageInterfaceHandle::dup(&r#match),
- ])?,
- ));
- } else if PlatformRepository::is_platform_package(&needle) {
- let parser = VersionParser::new();
- let platform_constraint = parser.parse_constraints(&text_constraint)?;
- if platform_constraint.get_lower_bound() != Bound::zero() {
- let version = platform_constraint
- .get_lower_bound()
- .get_version()
- .to_string();
- let temp_platform_pkg = Package::new(needle.clone(), version.clone(), version);
+ match &matched_package {
+ None => {
+ let rm = composer.get_repository_manager();
+ let mut default_repos = CompositeRepository::new(
+ RepositoryFactory::default_repos(
+ Some(self.get_io()),
+ Some(composer.get_config()),
+ Some(&mut rm.borrow_mut()),
+ )?
+ .into_values()
+ .collect(),
+ );
+ if let Some(r#match) = default_repos.find_package(
+ &needle,
+ FindPackageConstraint::String(text_constraint.clone()),
+ )? {
installed_repo.add_repository(
crate::repository::RepositoryInterfaceHandle::new(
InstalledArrayRepository::new_with_packages(vec![
- crate::package::PackageHandle::from_package(temp_platform_pkg)
- .into(),
+ crate::package::PackageInterfaceHandle::dup(&r#match),
])?,
),
);
+ } else if PlatformRepository::is_platform_package(&needle) {
+ let parser = VersionParser::new();
+ let platform_constraint = parser.parse_constraints(&text_constraint)?;
+ if platform_constraint.get_lower_bound() != Bound::zero() {
+ let version = platform_constraint
+ .get_lower_bound()
+ .get_version()
+ .to_string();
+ let temp_platform_pkg =
+ Package::new(needle.clone(), version.clone(), version);
+ installed_repo.add_repository(
+ crate::repository::RepositoryInterfaceHandle::new(
+ InstalledArrayRepository::new_with_packages(vec![
+ crate::package::PackageHandle::from_package(temp_platform_pkg)
+ .into(),
+ ])?,
+ ),
+ );
+ }
+ } else {
+ self.get_io().write_error(&format!(
+ "<error>Package \"{}\" could not be found with constraint \"{}\", results below will most likely be incomplete.</error>",
+ needle, text_constraint
+ ));
}
- } else {
+ }
+ Some(matched) if PlatformRepository::is_platform_package(&needle) => {
+ let extra_notice = if matched
+ .get_extra()
+ .get("config.platform")
+ .and_then(|v| v.as_bool())
+ .unwrap_or(false)
+ {
+ " (version provided by config.platform)"
+ } else {
+ ""
+ };
self.get_io().write_error(&format!(
- "<error>Package \"{}\" could not be found with constraint \"{}\", results below will most likely be incomplete.</error>",
- needle, text_constraint
+ "<info>Package \"{} {}\" found in version \"{}\"{}.</info>",
+ needle,
+ text_constraint,
+ matched.get_pretty_version(),
+ extra_notice
));
}
- } else if PlatformRepository::is_platform_package(&needle) {
- let matched = matched_package.as_ref().unwrap();
- let extra_notice = if matched
- .get_extra()
- .get("config.platform")
- .and_then(|v| v.as_bool())
- .unwrap_or(false)
- {
- " (version provided by config.platform)"
- } else {
- ""
- };
- self.get_io().write_error(&format!(
- "<info>Package \"{} {}\" found in version \"{}\"{}.</info>",
- needle,
- text_constraint,
- matched.get_pretty_version(),
- extra_notice
- ));
- } else if inverted {
- let matched = matched_package.as_ref().unwrap();
- self.get_io().write(&format!(
- "<comment>Package \"{}\" {} is already installed! To find out why, run `composer why {}`</comment>",
- needle,
- matched.get_pretty_version(),
- needle
- ));
+ Some(matched) if inverted => {
+ self.get_io().write(&format!(
+ "<comment>Package \"{}\" {} is already installed! To find out why, run `composer why {}`</comment>",
+ needle,
+ matched.get_pretty_version(),
+ needle
+ ));
- return Ok(0);
+ return Ok(0);
+ }
+ Some(_) => {}
}
let mut needles = vec![needle.clone()];
diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs
index b80e41c..90947ef 100644
--- a/crates/shirabe/src/command/bump_command.rs
+++ b/crates/shirabe/src/command/bump_command.rs
@@ -3,7 +3,6 @@
use crate::io::io_interface;
use crate::package::base_package;
use anyhow::Result;
-use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
@@ -12,21 +11,15 @@ use shirabe_php_shim::{PhpMixed, file_get_contents, file_put_contents, is_writab
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
use crate::json::JsonManipulator;
-use crate::package::AliasPackage;
-use crate::package::BasePackage;
use crate::package::version::VersionBumper;
use crate::repository::PlatformRepository;
use crate::util::Filesystem;
@@ -107,7 +100,7 @@ impl BumpCommand {
}
let composer = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer);
+ let composer = crate::command::composer_full_mut(&composer);
let has_lock_file_disabled = !composer.get_config().borrow().has("lock")
|| composer
.get_config()
@@ -184,7 +177,7 @@ impl BumpCommand {
.iter()
.map(|constraint| Preg::replace(r"{[:= ].+}", "", constraint))
.collect();
- let mut unique_lower: Vec<String> = packages_filter
+ let unique_lower: Vec<String> = packages_filter
.iter()
.map(|s| strtolower(s))
.collect::<std::collections::HashSet<_>>()
diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs
index a7f5d9c..d3e8adc 100644
--- a/crates/shirabe/src/command/check_platform_reqs_command.rs
+++ b/crates/shirabe/src/command/check_platform_reqs_command.rs
@@ -11,14 +11,9 @@ use shirabe_semver::constraint::SimpleConstraint;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
use crate::package::Link;
@@ -200,7 +195,7 @@ impl Command for CheckPlatformReqsCommand {
_output: Rc<RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
let composer = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer);
+ let composer = crate::command::composer_full_mut(&composer);
let io = self.get_io();
let no_dev = input
diff --git a/crates/shirabe/src/command/clear_cache_command.rs b/crates/shirabe/src/command/clear_cache_command.rs
index c3d1eb5..abe72ec 100644
--- a/crates/shirabe/src/command/clear_cache_command.rs
+++ b/crates/shirabe/src/command/clear_cache_command.rs
@@ -15,7 +15,6 @@ use crate::command::base_command::base_command_initialize;
use crate::config::Config;
use crate::console::input::InputOption;
use crate::factory::Factory;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
#[derive(Debug)]
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs
index 308d557..7bf7d1b 100644
--- a/crates/shirabe/src/command/config_command.rs
+++ b/crates/shirabe/src/command/config_command.rs
@@ -10,31 +10,23 @@ 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, JsonObject, PhpMixed, RuntimeException, array_filter,
- array_filter_use_key, array_is_list, array_map, array_merge, array_unique, count,
+ InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge,
escapeshellcmd, exec, explode, file_exists, file_get_contents, implode, in_array, is_array,
- is_bool, is_dir, is_numeric, is_object, is_string, json_encode, sort, sprintf, str_replace,
- str_starts_with, strpos, strtolower, system, touch, var_export,
+ is_bool, is_dir, is_numeric, is_object, is_string, json_encode, str_replace, strpos,
+ strtolower, system, touch, var_export,
};
-use std::cell::RefCell;
-use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::advisory::Auditor;
use crate::command::BaseConfigCommand;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
use crate::config::Config;
use crate::config::ConfigSourceInterface;
use crate::config::JsonConfigSource;
use crate::console::input::InputArgument;
-use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
-use crate::package::base_package::{self, BasePackage};
+use crate::package::base_package::{self};
use crate::util::Filesystem;
use crate::util::Platform;
use crate::util::Silencer;
@@ -355,7 +347,7 @@ impl Command for ConfigCommand {
properties_defaults.insert("suggest".to_string(), PhpMixed::List(vec![]));
properties_defaults.insert("extra".to_string(), PhpMixed::List(vec![]));
let raw_data = config_file.borrow_mut().read()?;
- let mut data = config.borrow_mut().all(0)?;
+ let data = config.borrow_mut().all(0)?;
let mut source = config.borrow_mut().get_source_of_value(&setting_key);
let mut value: PhpMixed;
@@ -443,7 +435,7 @@ impl Command for ConfigCommand {
if value.as_array().map(|a| a.is_empty()).unwrap_or(false) {
let schema = JsonFile::parse_json(
Some(
- &file_get_contents(&JsonFile::composer_schema_path())
+ &file_get_contents(JsonFile::composer_schema_path())
.unwrap_or_default(),
),
Some("composer.schema.json"),
@@ -1468,24 +1460,24 @@ impl ConfigCommand {
String::new()
};
- let link: String;
- if k.is_some() && strpos(k.as_ref().unwrap(), "repositories") == Some(0) {
- link = "https://getcomposer.org/doc/05-repositories.md".to_string();
- } else {
- let id_source = if k.as_deref() == Some("") || k.is_none() {
- key.clone()
+ let link: String =
+ if k.is_some() && strpos(k.as_ref().unwrap(), "repositories") == Some(0) {
+ "https://getcomposer.org/doc/05-repositories.md".to_string()
} else {
- k.clone().unwrap()
+ let id_source = if k.as_deref() == Some("") || k.is_none() {
+ key.clone()
+ } else {
+ k.clone().unwrap()
+ };
+ let id = Preg::replace("{\\..*$}", "", &id_source);
+ let id = Preg::replace(
+ "{[^a-z0-9]}i",
+ "-",
+ &strtolower(&shirabe_php_shim::trim(&id, Some(" \t\n\r\0\u{0B}"))),
+ );
+ let id = Preg::replace("{-+}", "-", &id);
+ format!("https://getcomposer.org/doc/06-config.md#{}", id)
};
- let id = Preg::replace("{\\..*$}", "", &id_source);
- let id = Preg::replace(
- "{[^a-z0-9]}i",
- "-",
- &strtolower(&shirabe_php_shim::trim(&id, Some(" \t\n\r\0\u{0B}"))),
- );
- let id = Preg::replace("{-+}", "-", &id);
- link = format!("https://getcomposer.org/doc/06-config.md#{}", id);
- }
if is_string(&raw_val)
&& raw_val
.as_string()
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs
index 9969cf5..dbc98dd 100644
--- a/crates/shirabe/src/command/create_project_command.rs
+++ b/crates/shirabe/src/command/create_project_command.rs
@@ -17,11 +17,9 @@ use std::cell::RefCell;
use std::path::PathBuf;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::advisory::Auditor;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
use crate::config::Config;
use crate::config::ConfigSourceInterface;
use crate::config::JsonConfigSource;
@@ -428,7 +426,7 @@ impl CreateProjectCommand {
}
}
- let mut composer = crate::command::composer_full_mut(&composer_handle);
+ let composer = crate::command::composer_full_mut(&composer_handle);
let process = composer
.get_loop()
@@ -741,37 +739,40 @@ impl CreateProjectCommand {
if stability.is_none() {
if package_version.is_none() {
stability = Some("stable".to_string());
- } else if {
- let mut matched: IndexMap<CaptureKey, String> = IndexMap::new();
- let ok = Preg::is_match3(
- &format!(
- "{{^[^,\\s]*?@({})$}}i",
- implode(
- "|",
- &STABILITIES
- .keys()
- .map(|k| k.to_string())
- .collect::<Vec<_>>()
- )
- ),
- package_version.as_deref().unwrap_or(""),
- Some(&mut matched),
- );
- if ok {
- stability = Some(
- matched
- .get(&CaptureKey::ByIndex(1))
- .cloned()
- .unwrap_or_default(),
+ } else {
+ let ok = {
+ let mut matched: IndexMap<CaptureKey, String> = IndexMap::new();
+ let ok = Preg::is_match3(
+ &format!(
+ "{{^[^,\\s]*?@({})$}}i",
+ implode(
+ "|",
+ &STABILITIES
+ .keys()
+ .map(|k| k.to_string())
+ .collect::<Vec<_>>()
+ )
+ ),
+ package_version.as_deref().unwrap_or(""),
+ Some(&mut matched),
);
+ if ok {
+ stability = Some(
+ matched
+ .get(&CaptureKey::ByIndex(1))
+ .cloned()
+ .unwrap_or_default(),
+ );
+ }
+ ok
+ };
+ if ok {
+ // stability already set above
+ } else {
+ stability = Some(VersionParser::parse_stability(
+ package_version.as_deref().unwrap_or(""),
+ ));
}
- ok
- } {
- // stability already set above
- } else {
- stability = Some(VersionParser::parse_stability(
- package_version.as_deref().unwrap_or(""),
- ));
}
}
@@ -1032,7 +1033,7 @@ impl CreateProjectCommand {
// ensure that the env var being set does not interfere with create-project
// as it is probably not meant to be used here, so we do not use it if a composer.json can be found
// in the project
- if file_exists(&format!("{}/composer.json", directory))
+ if file_exists(format!("{}/composer.json", directory))
&& Platform::get_env("COMPOSER").is_some()
{
Platform::clear_env("COMPOSER");
diff --git a/crates/shirabe/src/command/depends_command.rs b/crates/shirabe/src/command/depends_command.rs
index f7d57db..fa60a42 100644
--- a/crates/shirabe/src/command/depends_command.rs
+++ b/crates/shirabe/src/command/depends_command.rs
@@ -1,25 +1,18 @@
//! ref: composer/src/Composer/Command/DependsCommand.php
use anyhow::Result;
-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 shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::BaseDependencyCommand;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
#[derive(Debug)]
pub struct DependsCommand {
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs
index 99118cd..514671a 100644
--- a/crates/shirabe/src/command/diagnose_command.rs
+++ b/crates/shirabe/src/command/diagnose_command.rs
@@ -10,35 +10,30 @@ use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
use shirabe_external_packages::symfony::process::ExecutableFinder;
use shirabe_php_shim::{
- CURL_HTTP_VERSION_2_0, CURL_VERSION_HTTP2, CURL_VERSION_HTTP3, CURL_VERSION_ZSTD, INFO_GENERAL,
+ CURL_VERSION_HTTP2, CURL_VERSION_HTTP3, CURL_VERSION_ZSTD, INFO_GENERAL,
InvalidArgumentException, OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT, PHP_BINARY, PHP_EOL,
- PHP_VERSION, PHP_VERSION_ID, PHP_WINDOWS_VERSION_BUILD, PhpMixed, RuntimeException, count,
- curl_version, defined, disk_free_space, extension_loaded, file_exists, filter_var_boolean,
- function_exists, get_class, get_class_err, hash, implode, ini_get, ioncube_loader_iversion,
- ioncube_loader_version, is_array, is_string, ob_get_clean, ob_start, phpinfo, rtrim, sprintf,
- str_contains, str_replace, str_starts_with, strpos, strstr, strtolower, trim, version_compare,
+ PHP_VERSION, PHP_VERSION_ID, PHP_WINDOWS_VERSION_BUILD, PhpMixed, curl_version, defined,
+ disk_free_space, extension_loaded, file_exists, filter_var_boolean, function_exists,
+ get_class_err, hash, implode, ini_get, ioncube_loader_iversion, ioncube_loader_version,
+ 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;
-use crate::advisory::AuditConfig;
use crate::advisory::Auditor;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
use crate::composer;
-use crate::composer::ComposerHandle;
-use crate::composer::PartialComposerHandle;
use crate::config::Config;
use crate::downloader::TransportException;
use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::io::BufferIO;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::io::NullIO;
use crate::json::JsonFile;
use crate::json::JsonValidationException;
-use crate::package::CompletePackageInterface;
use crate::package::Locker;
use crate::package::RootPackage;
use crate::package::version::VersionParser;
@@ -149,7 +144,7 @@ impl Command for DiagnoseCommand {
config_inner.insert("secure-http".to_string(), PhpMixed::Bool(false));
let mut secure_http_wrap: IndexMap<String, PhpMixed> = IndexMap::new();
secure_http_wrap.insert("config".to_string(), PhpMixed::Array(config_inner));
- let mut config = config;
+ let config = config;
config
.borrow_mut()
.merge(&secure_http_wrap, Config::SOURCE_COMMAND);
@@ -272,7 +267,7 @@ impl Command for DiagnoseCommand {
));
if let Some(ref mut c) = composer {
- let mut c = crate::command::composer_full_mut(c);
+ let c = crate::command::composer_full_mut(c);
io.write(&format!(
"Active plugins: {}",
implode(
@@ -692,12 +687,12 @@ impl DiagnoseCommand {
let first = provider_includes_arr
.values()
.next()
- .map(|v| v.clone())
+ .cloned()
.unwrap_or(PhpMixed::Null);
let hash_val = first
.as_array()
.and_then(|a| a.get("sha256"))
- .map(|v| v.clone())
+ .cloned()
.unwrap_or(PhpMixed::Null);
let path = str_replace(
"%hash%",
@@ -828,7 +823,7 @@ impl DiagnoseCommand {
.and_then(|a| a.get("resources"))
.and_then(|v| v.as_array())
.and_then(|a| a.get("core"))
- .map(|v| v.clone())
+ .cloned()
.unwrap_or(PhpMixed::Null))
}
@@ -863,13 +858,13 @@ impl DiagnoseCommand {
let mut errors: Vec<PhpMixed> = vec![];
let io = self.get_io();
- if file_exists(&format!("{}/keys.tags.pub", home))
- && file_exists(&format!("{}/keys.dev.pub", home))
+ if file_exists(format!("{}/keys.tags.pub", home))
+ && file_exists(format!("{}/keys.dev.pub", home))
{
io.write("");
}
- if file_exists(&format!("{}/keys.tags.pub", home)) {
+ if file_exists(format!("{}/keys.tags.pub", home)) {
io.write(&format!(
"Tags Public Key Fingerprint: {}",
Keys::fingerprint(&format!("{}/keys.tags.pub", home))?
@@ -880,7 +875,7 @@ impl DiagnoseCommand {
));
}
- if file_exists(&format!("{}/keys.dev.pub", home)) {
+ if file_exists(format!("{}/keys.dev.pub", home)) {
io.write(&format!(
"Dev Public Key Fingerprint: {}",
Keys::fingerprint(&format!("{}/keys.dev.pub", home))?
@@ -1278,7 +1273,7 @@ impl DiagnoseCommand {
warnings.insert("uopz".to_string(), PhpMixed::Bool(true));
}
- let mut out_fn = |msg: &str, style: &str, output: &mut String| {
+ let out_fn = |msg: &str, style: &str, output: &mut String| {
output.push_str(&format!("<{}>{}</{}>{}", style, msg, style, PHP_EOL));
};
diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs
index fae4d76..d697e79 100644
--- a/crates/shirabe/src/command/dump_autoload_command.rs
+++ b/crates/shirabe/src/command/dump_autoload_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Command/DumpAutoloadCommand.php
use anyhow::Result;
-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;
@@ -9,15 +8,10 @@ use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists};
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs
index db91012..2fc23f0 100644
--- a/crates/shirabe/src/command/exec_command.rs
+++ b/crates/shirabe/src/command/exec_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Command/ExecCommand.php
use anyhow::Result;
-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;
@@ -9,16 +8,11 @@ use shirabe_php_shim::{PhpMixed, RuntimeException, basename, chdir, getcwd, glob
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
#[derive(Debug)]
diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs
index 5b4987f..8c43ca1 100644
--- a/crates/shirabe/src/command/fund_command.rs
+++ b/crates/shirabe/src/command/fund_command.rs
@@ -1,7 +1,5 @@
//! ref: composer/src/Composer/Command/FundCommand.php
-use std::any::Any;
-
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
@@ -15,21 +13,12 @@ use shirabe_semver::constraint::MatchAllConstraint;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
-use crate::package::AliasPackage;
-use crate::package::CompletePackage;
-use crate::package::CompletePackageInterface;
-use crate::package::PackageInterface;
-use crate::package::base_package::{self, BasePackage};
+use crate::package::base_package::{self};
use crate::repository::CompositeRepository;
use crate::repository::RepositoryInterface;
diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs
index aed142c..d0d8a31 100644
--- a/crates/shirabe/src/command/global_command.rs
+++ b/crates/shirabe/src/command/global_command.rs
@@ -3,7 +3,6 @@
use std::path::Path;
use anyhow::Result;
-use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::ArgvInput;
@@ -11,22 +10,15 @@ use shirabe_external_packages::symfony::console::input::ArrayInput;
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::PhpMixed;
-use shirabe_php_shim::{AsAny, LogicException, RuntimeException, chdir};
+use shirabe_php_shim::{LogicException, RuntimeException, chdir};
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
-use crate::io::IOInterfaceImmutable;
use crate::util::Filesystem;
use crate::util::Platform;
@@ -86,7 +78,7 @@ impl GlobalCommand {
Platform::clear_env("COMPOSER");
}
- let mut config = Factory::create_config(None, None)?;
+ let config = Factory::create_config(None, None)?;
let home = config.get("home").as_string().unwrap_or("").to_string();
if !Path::new(&home).is_dir() {
diff --git a/crates/shirabe/src/command/home_command.rs b/crates/shirabe/src/command/home_command.rs
index 081ce2d..0a0a36c 100644
--- a/crates/shirabe/src/command/home_command.rs
+++ b/crates/shirabe/src/command/home_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Command/HomeCommand.php
use anyhow::Result;
-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;
@@ -10,22 +9,14 @@ use shirabe_php_shim::filter_var_url;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::package::CompletePackageInterfaceHandle;
-use crate::package::PackageInterface;
-use crate::package::RootPackageInterface;
use crate::repository::RepositoryFactory;
-use crate::repository::RepositoryInterface;
use crate::repository::RootPackageRepository;
use crate::util::Platform;
use crate::util::ProcessExecutor;
diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs
index 557ebca..ab0e52c 100644
--- a/crates/shirabe/src/command/init_command.rs
+++ b/crates/shirabe/src/command/init_command.rs
@@ -10,30 +10,24 @@ 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::{
- FILE_IGNORE_NEW_LINES, InvalidArgumentException, PHP_EOL, PHP_SERVER, PhpMixed, array_filter,
- array_flip, array_flip_strings, array_intersect_key, array_keys, array_map, basename, empty,
- explode, file, file_exists, file_get_contents, file_put_contents, function_exists,
- get_current_user, implode, is_dir, is_string, preg_quote, realpath, sprintf, str_replace,
- strpos, strtolower, trim, ucwords,
+ FILE_IGNORE_NEW_LINES, InvalidArgumentException, PHP_EOL, PHP_SERVER, PhpMixed,
+ array_flip_strings, array_intersect_key, array_map, basename, empty, explode, file,
+ file_exists, file_get_contents, file_put_contents, get_current_user, implode, is_dir,
+ is_string, preg_quote, realpath, str_replace, strpos, strtolower, trim, ucwords,
};
use shirabe_spdx_licenses::SpdxLicenses;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::PackageDiscoveryTrait;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputOption;
use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
use crate::json::JsonValidationException;
-use crate::package::base_package::{self, BasePackage};
+use crate::package::base_package::{self};
use crate::repository::CompositeRepository;
use crate::repository::PlatformRepository;
use crate::repository::PlatformRepositoryHandle;
@@ -848,7 +842,7 @@ impl Command for InitCommand {
);
// --autoload - input and validation
- let mut autoload = input
+ let autoload = input
.borrow()
.get_option("autoload")?
.as_string()
diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs
index 53e3a6c..6a56eb0 100644
--- a/crates/shirabe/src/command/install_command.rs
+++ b/crates/shirabe/src/command/install_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Command/InstallCommand.php
use anyhow::Result;
-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;
@@ -9,18 +8,13 @@ use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::advisory::Auditor;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::installer::Installer;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
@@ -138,7 +132,7 @@ impl Command for InstallCommand {
}
let composer_handle = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer_handle);
+ let composer = crate::command::composer_full_mut(&composer_handle);
if !composer.get_locker().borrow_mut().is_locked() && !HttpDownloader::is_curl_enabled() {
io.write_error("<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>");
diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs
index f2672bd..bef15ff 100644
--- a/crates/shirabe/src/command/licenses_command.rs
+++ b/crates/shirabe/src/command/licenses_command.rs
@@ -1,7 +1,5 @@
//! ref: composer/src/Composer/Command/LicensesCommand.php
-use std::any::Any;
-
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::command::command::Command;
@@ -15,22 +13,13 @@ use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException};
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
-use crate::package::BasePackage;
-use crate::package::CompletePackage;
-use crate::package::CompletePackageInterface;
use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
-use crate::repository::CanonicalPackagesTrait;
use crate::repository::RepositoryInterface;
use crate::repository::RepositoryUtils;
use crate::util::PackageInfo;
@@ -123,7 +112,7 @@ impl Command for LicensesCommand {
.borrow_mut()
.dispatch(Some(command_event.get_name()), None);
- let mut composer = crate::command::composer_full_mut(&composer_handle);
+ let composer = crate::command::composer_full_mut(&composer_handle);
let root = composer.get_package();
let packages = if input
diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs
index 6a3c3e2..90c0f3d 100644
--- a/crates/shirabe/src/command/outdated_command.rs
+++ b/crates/shirabe/src/command/outdated_command.rs
@@ -10,16 +10,11 @@ use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
#[derive(Debug)]
pub struct OutdatedCommand {
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index bce7e9a..4a5c65b 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Command/PackageDiscoveryTrait.php
use crate::io::io_interface;
-use std::any::Any;
use anyhow::Result;
use indexmap::IndexMap;
@@ -10,13 +9,11 @@ use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
use shirabe_php_shim::{
Exception, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, array_keys,
- array_slice, array_unshift, array_values, asort, count, explode, file_get_contents, implode,
- in_array, is_array, is_file, is_numeric, is_string, json_decode, levenshtein, sprintf, strlen,
- strpos, trim,
+ array_slice, asort, explode, file_get_contents, implode, in_array, is_array, is_file,
+ is_numeric, json_decode, levenshtein, strlen, strpos, trim,
};
use crate::command::BaseCommand;
-use crate::composer::PartialComposerHandle;
use crate::factory::Factory;
use crate::filter::platform_requirement_filter::IgnoreAllPlatformRequirementFilter;
use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory;
@@ -558,7 +555,7 @@ pub trait PackageDiscoveryTrait: BaseCommand {
return Err(InvalidArgumentException {
message: format!(
"Package {} has requirements incompatible with your PHP version, PHP extensions and Composer version{}",
- name.to_string(),
+ name,
self.get_platform_exception_details(
candidate.clone(),
platform_repo,
@@ -612,7 +609,7 @@ 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.",
- name.to_string(),
+ name,
effective_minimum_stability.clone(),
),
code: 0,
@@ -654,7 +651,7 @@ 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{}{}",
- name.to_string(),
+ name,
self.get_platform_exception_details(
candidate.clone(),
platform_repo,
@@ -683,7 +680,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.",
- name.to_string(),
+ name,
),
code: 0,
}
@@ -720,7 +717,7 @@ pub trait PackageDiscoveryTrait: BaseCommand {
return Err(InvalidArgumentException {
message: format!(
"Could not find package {}.\n\nDid you mean {}?\n {}",
- name.to_string(),
+ name,
if similar.len() > 1 {
"one of these"
} else {
@@ -736,7 +733,7 @@ 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 ({}).",
- name.to_string(),
+ name,
effective_minimum_stability,
),
code: 0,
diff --git a/crates/shirabe/src/command/prohibits_command.rs b/crates/shirabe/src/command/prohibits_command.rs
index f35990a..7c034aa 100644
--- a/crates/shirabe/src/command/prohibits_command.rs
+++ b/crates/shirabe/src/command/prohibits_command.rs
@@ -1,24 +1,17 @@
//! ref: composer/src/Composer/Command/ProhibitsCommand.php
use anyhow::Result;
-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 shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseDependencyCommand;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
#[derive(Debug)]
pub struct ProhibitsCommand {
diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs
index 6e728e6..20b8895 100644
--- a/crates/shirabe/src/command/reinstall_command.rs
+++ b/crates/shirabe/src/command/reinstall_command.rs
@@ -1,32 +1,22 @@
//! ref: composer/src/Composer/Command/ReinstallCommand.php
-use std::any::Any;
-
use anyhow::Result;
-use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
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 shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
-use crate::console::input::InputDefinitionItem;
use crate::console::input::InputOption;
use crate::dependency_resolver::Transaction;
use crate::dependency_resolver::operation::InstallOperation;
use crate::dependency_resolver::operation::UninstallOperation;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::package::base_package;
use crate::plugin::CommandEvent;
diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs
index c36c5dd..60287bc 100644
--- a/crates/shirabe/src/command/remove_command.rs
+++ b/crates/shirabe/src/command/remove_command.rs
@@ -7,31 +7,23 @@ use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::exception::InvalidArgumentException;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
-use shirabe_php_shim::{PhpMixed, UnexpectedValueException, array_map, strtolower};
+use shirabe_php_shim::{PhpMixed, UnexpectedValueException, strtolower};
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::advisory::Auditor;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::config::ConfigSourceInterface;
use crate::config::JsonConfigSource;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::dependency_resolver::Request;
use crate::dependency_resolver::UpdateAllowTransitiveDeps;
use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::installer::Installer;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
-use crate::package::BasePackage;
use crate::package::base_package;
-use crate::repository::CanonicalPackagesTrait;
use crate::repository::RepositoryInterface;
#[derive(Debug)]
@@ -226,7 +218,7 @@ impl Command for RemoveCommand {
.unwrap_or(false)
{
let composer = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer);
+ let composer = crate::command::composer_full_mut(&composer);
{
let locker = composer.get_locker().clone();
let mut locker = locker.borrow_mut();
@@ -240,7 +232,7 @@ impl Command for RemoveCommand {
}
}
- let mut locked_repo = composer
+ let locked_repo = composer
.get_locker()
.borrow_mut()
.get_locked_repository(true)?;
diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs
index c8d99a5..19dfb6b 100644
--- a/crates/shirabe/src/command/repository_command.rs
+++ b/crates/shirabe/src/command/repository_command.rs
@@ -12,18 +12,13 @@ use shirabe_php_shim::{
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseConfigCommand;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
use crate::config::Config;
use crate::config::ConfigSourceInterface;
use crate::config::JsonConfigSource;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs
index 4bed4df..d2923c8 100644
--- a/crates/shirabe/src/command/require_command.rs
+++ b/crates/shirabe/src/command/require_command.rs
@@ -9,26 +9,21 @@ 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, UnexpectedValueException, array_fill_keys, array_intersect,
- array_keys, array_map, array_merge, array_unique, count, empty, file_exists, file_get_contents,
- file_put_contents, filesize, implode, is_writable, sprintf, strtolower, unlink,
+ PhpMixed, RuntimeException, array_fill_keys, array_intersect, array_keys, array_map,
+ 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;
-use crate::advisory::AuditConfig;
use crate::advisory::Auditor;
use crate::command::PackageDiscoveryTrait;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::dependency_resolver::Request;
use crate::dependency_resolver::UpdateAllowTransitiveDeps;
use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::installer::Installer;
use crate::installer::InstallerEvents;
use crate::io::IOInterface;
@@ -45,7 +40,6 @@ use crate::plugin::PluginEvents;
use crate::repository::CompositeRepository;
use crate::repository::PlatformRepository;
use crate::repository::PlatformRepositoryHandle;
-use crate::repository::RepositoryInterface;
use crate::repository::RepositorySet;
use crate::util::Filesystem;
use crate::util::PackageSorter;
@@ -269,7 +263,7 @@ impl Command for RequireCommand {
.to_string()
};
- /// @see https://github.com/composer/composer/pull/8313#issuecomment-532637955
+ // @see https://github.com/composer/composer/pull/8313#issuecomment-532637955
if package_type != "project"
&& !input.borrow().get_option("dev")?.as_bool().unwrap_or(false)
{
@@ -482,14 +476,13 @@ impl Command for RequireCommand {
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.",
package.clone(),
- remove_key.to_string(),
+ remove_key,
if input.borrow().get_option("dev")?.as_bool().unwrap_or(false) {
"with"
} else {
"without"
- }
- .to_string(),
- require_key.to_string(),
+ },
+ require_key,
);
self.get_io().warning(&warn_msg, &[]);
}
@@ -501,8 +494,7 @@ impl Command for RequireCommand {
"these requirements"
} else {
"this requirement"
- }
- .to_string(),
+ },
);
if !self.get_io().ask_confirmation(q1, false) {
let q2 = format!(
@@ -511,8 +503,7 @@ impl Command for RequireCommand {
"without"
} else {
"with"
- }
- .to_string(),
+ },
);
if !self.get_io().ask_confirmation(q2, true) {
return Ok(0);
@@ -762,7 +753,7 @@ impl RequireCommand {
// Update packages
self.reset_composer()?;
let composer_handle = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer_handle);
+ let composer = crate::command::composer_full_mut(&composer_handle);
self.dependency_resolution_completed.set(false);
// PHP: $composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC,
@@ -1065,7 +1056,7 @@ impl RequireCommand {
fixed: bool,
) -> Result<i64> {
let composer = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer);
+ let composer = crate::command::composer_full_mut(&composer);
let locker_is_locked = composer.get_locker().borrow_mut().is_locked();
let mut requirements: IndexMap<String, String> = IndexMap::new();
let mut version_selector = VersionSelector::new(
diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs
index 383c5bb..7d37959 100644
--- a/crates/shirabe/src/command/run_script_command.rs
+++ b/crates/shirabe/src/command/run_script_command.rs
@@ -10,16 +10,11 @@ use shirabe_php_shim::{InvalidArgumentException, RuntimeException};
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::script::Event as ScriptEvent;
use crate::script::ScriptEvents;
diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs
index 0fb5ce0..e429fe7 100644
--- a/crates/shirabe/src/command/script_alias_command.rs
+++ b/crates/shirabe/src/command/script_alias_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Command/ScriptAliasCommand.php
use anyhow::Result;
-use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
@@ -10,16 +9,11 @@ use shirabe_php_shim::{InvalidArgumentException, LogicException, PhpMixed, is_st
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::util::Platform;
#[derive(Debug)]
diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs
index bcd74c3..f5a85fe 100644
--- a/crates/shirabe/src/command/search_command.rs
+++ b/crates/shirabe/src/command/search_command.rs
@@ -10,15 +10,10 @@ use shirabe_php_shim::{InvalidArgumentException, PhpMixed, implode, in_array, pr
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
use crate::plugin::CommandEvent;
diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs
index aaee993..5b94058 100644
--- a/crates/shirabe/src/command/self_update_command.rs
+++ b/crates/shirabe/src/command/self_update_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Command/SelfUpdateCommand.php
use anyhow::Result;
-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;
@@ -9,16 +8,11 @@ use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::io::io_interface;
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index cfe4d3b..f65ecc7 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -20,22 +20,18 @@ use std::rc::Rc;
use shirabe_semver::constraint::AnyConstraint;
-use crate::advisory::AuditConfig;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::dependency_resolver::DefaultPolicy;
use crate::dependency_resolver::PolicyInterface;
use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
use crate::package::CompletePackageInterfaceHandle;
use crate::package::Link;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
use crate::package::base_package;
use crate::package::version::VersionParser;
@@ -224,7 +220,7 @@ impl Command for ShowCommand {
self.init_styles(output.clone());
}
- let mut composer = self.try_composer(None, None);
+ let composer = self.try_composer(None, None);
if input.borrow().get_option("installed")?.as_bool() == Some(true)
&& input.borrow().get_option("self")?.as_bool() != Some(true)
@@ -420,7 +416,7 @@ impl Command for ShowCommand {
installed_repo = RepositoryInterfaceHandle::new(ir);
}
} else if input.borrow().get_option("all")?.as_bool() == Some(true) && composer.is_some() {
- let mut composer_ref = crate::command::composer_full_mut(composer.as_ref().unwrap());
+ let composer_ref = crate::command::composer_full_mut(composer.as_ref().unwrap());
let local_repo = composer_ref
.get_repository_manager()
.borrow()
@@ -488,7 +484,7 @@ impl Command for ShowCommand {
}
.into());
}
- let mut composer_ref = crate::command::composer_full_mut(composer.as_ref().unwrap());
+ let composer_ref = crate::command::composer_full_mut(composer.as_ref().unwrap());
let locker_rc = composer_ref.get_locker().clone();
let mut locker = locker_rc.borrow_mut();
let lr = locker.get_locked_repository(
@@ -1901,7 +1897,7 @@ impl ShowCommand {
if r#type == "psr-0" || r#type == "psr-4" {
if let PhpMixed::Array(map) = autoloads {
for (name, path) in map.iter() {
- let path_str = match &*path {
+ let path_str = match path {
PhpMixed::List(l) => l
.iter()
.filter_map(|p| p.as_string().map(|s| s.to_string()))
@@ -2594,7 +2590,7 @@ impl ShowCommand {
let circular_warn = if in_array(
PhpMixed::String(require_name.clone()),
- &PhpMixed::List(current_tree.iter().cloned().collect()),
+ &PhpMixed::List(current_tree.to_vec()),
true,
) {
"(circular dependency aborted here)"
@@ -2648,7 +2644,7 @@ impl ShowCommand {
if !in_array(
PhpMixed::String(require_name.clone()),
- &PhpMixed::List(current_tree.iter().cloned().collect()),
+ &PhpMixed::List(current_tree.to_vec()),
true,
) {
current_tree.push(PhpMixed::String(require_name.clone()));
@@ -2824,21 +2820,21 @@ impl ShowCommand {
}
}
- let show_warnings_box: Box<dyn Fn(PackageInterfaceHandle) -> bool>;
- if self.get_io().is_verbose() {
- show_warnings_box = Box::new(|_p: PackageInterfaceHandle| -> bool { true });
- } else {
- let package_version = package.get_version();
- show_warnings_box = Box::new(move |candidate: PackageInterfaceHandle| -> bool {
- if candidate.get_version().starts_with("dev-")
- || package_version.starts_with("dev-")
- {
- return false;
- }
+ let show_warnings_box: Box<dyn Fn(PackageInterfaceHandle) -> bool> =
+ if self.get_io().is_verbose() {
+ Box::new(|_p: PackageInterfaceHandle| -> bool { true })
+ } else {
+ let package_version = package.get_version();
+ Box::new(move |candidate: PackageInterfaceHandle| -> bool {
+ if candidate.get_version().starts_with("dev-")
+ || package_version.starts_with("dev-")
+ {
+ return false;
+ }
- version_compare(&candidate.get_version(), &package_version, "<=")
- });
- }
+ version_compare(&candidate.get_version(), &package_version, "<=")
+ })
+ };
// TODO(phase-c): PHP passes $showWarnings (true or a closure) as the last argument, but the
// closure form requires modeling a callable inside PhpMixed; hardcoding true until then.
let _ = show_warnings_box;
diff --git a/crates/shirabe/src/command/status_command.rs b/crates/shirabe/src/command/status_command.rs
index db93e66..a8ea1ee 100644
--- a/crates/shirabe/src/command/status_command.rs
+++ b/crates/shirabe/src/command/status_command.rs
@@ -5,19 +5,13 @@ 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 shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::package::dumper::ArrayDumper;
use crate::package::version::VersionGuesser;
@@ -58,7 +52,7 @@ impl StatusCommand {
input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
) -> Result<i64> {
let composer = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer);
+ let composer = crate::command::composer_full_mut(&composer);
let io = self.get_io().clone();
let mut errors: IndexMap<String, String> = IndexMap::new();
diff --git a/crates/shirabe/src/command/suggests_command.rs b/crates/shirabe/src/command/suggests_command.rs
index 4bd0758..9abae53 100644
--- a/crates/shirabe/src/command/suggests_command.rs
+++ b/crates/shirabe/src/command/suggests_command.rs
@@ -1,15 +1,10 @@
//! ref: composer/src/Composer/Command/SuggestsCommand.php
-use crate::advisory::AuditConfig;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::installer::SuggestedPackagesReporter;
-use crate::io::IOInterface;
use crate::repository::InstalledRepository;
use crate::repository::PlatformRepository;
use crate::repository::RepositoryInterface;
@@ -119,7 +114,7 @@ impl Command for SuggestsCommand {
_output: Rc<RefCell<dyn OutputInterface>>,
) -> Result<i64> {
let composer = self.require_composer(None, None)?;
- let mut composer = crate::command::composer_full_mut(&composer);
+ let composer = crate::command::composer_full_mut(&composer);
let mut installed_repos: Vec<RepositoryInterfaceHandle> =
vec![RepositoryInterfaceHandle::new(RootPackageRepository::new(
diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs
index c6c05ba..6a74371 100644
--- a/crates/shirabe/src/command/update_command.rs
+++ b/crates/shirabe/src/command/update_command.rs
@@ -11,24 +11,18 @@ use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_filter, array_intersect,
- array_keys, array_merge_map, array_search_in_vec, count, empty, in_array, sprintf, strtolower,
+ array_keys, array_merge_map, array_search_in_vec, in_array, strtolower,
};
use shirabe_semver::Intervals;
use shirabe_semver::constraint::MultiConstraint;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
-use crate::advisory::Auditor;
use crate::command::BumpCommand;
use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
use crate::composer::PartialComposerHandle;
-use crate::config::Config;
-use crate::console::input::InputArgument;
-use crate::console::input::InputOption;
-use crate::dependency_resolver::request::{self, Request, UpdateAllowTransitiveDeps};
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
+use crate::dependency_resolver::request::UpdateAllowTransitiveDeps;
use crate::installer::Installer;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
@@ -40,7 +34,6 @@ use crate::plugin::PluginEvents;
use crate::repository::CanonicalPackagesTrait;
use crate::repository::CompositeRepository;
use crate::repository::PlatformRepository;
-use crate::repository::RepositoryInterface;
use crate::repository::RepositorySet;
use crate::util::HttpDownloader;
@@ -516,7 +509,7 @@ impl Command for UpdateCommand {
true,
io_interface::NORMAL,
);
- let mut bump_command = BumpCommand::new();
+ let bump_command = BumpCommand::new();
bump_command.set_composer(composer_handle.clone());
result = bump_command.do_bump(
io.clone(),
@@ -707,7 +700,7 @@ impl UpdateCommand {
if io.ask_confirmation(
format!(
"Would you like to continue and update the above package{} [<comment>yes</comment>]? ",
- if 1 == packages.len() { "" } else { "s" }.to_string(),
+ if 1 == packages.len() { "" } else { "s" },
),
true,
) {
diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs
index b378393..89c83eb 100644
--- a/crates/shirabe/src/command/validate_command.rs
+++ b/crates/shirabe/src/command/validate_command.rs
@@ -1,24 +1,18 @@
//! ref: composer/src/Composer/Command/ValidateCommand.php
use anyhow::Result;
-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 shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
-use crate::advisory::AuditConfig;
use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
-use crate::composer::PartialComposerHandle;
-use crate::config::Config;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::factory::Factory;
-use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::package::loader::ValidatingArrayLoader;
@@ -203,7 +197,7 @@ impl Command for ValidateCommand {
let mut lock_errors: Vec<String> = vec![];
let composer =
self.create_composer_instance(input.clone(), io.clone(), None, false, None)?;
- let mut composer = crate::command::composer_full_mut(&composer);
+ let composer = crate::command::composer_full_mut(&composer);
let check_lock = (check_lock
&& composer
.get_config()
diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs
index b3eb47d..7b4ce89 100644
--- a/crates/shirabe/src/config.rs
+++ b/crates/shirabe/src/config.rs
@@ -12,9 +12,9 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
E_USER_DEPRECATED, PHP_URL_HOST, PHP_URL_SCHEME, PhpMixed, RuntimeException, array_key_exists,
- array_merge, array_reverse, array_search_mixed, array_unique, empty, filter_var_url, implode,
- in_array, is_array, is_int, is_string, parse_url, php_to_string, rtrim, strtolower, strtoupper,
- strtr, substr, trigger_error,
+ array_merge, array_search_mixed, array_unique, empty, filter_var_url, implode, in_array,
+ is_array, is_string, parse_url, php_to_string, rtrim, strtolower, strtoupper, strtr, substr,
+ trigger_error,
};
use std::cell::RefCell;
@@ -219,7 +219,7 @@ impl Config {
/// @param bool $useEnvironment Use COMPOSER_ environment variables to replace config settings
/// @param ?string $baseDir Optional base directory of the config
pub fn new(use_environment: bool, base_dir: Option<String>) -> Self {
- let mut this = Self {
+ let this = Self {
// load defaults
config: Self::default_config(),
repositories: Self::default_repositories(),
diff --git a/crates/shirabe/src/config/json_config_source.rs b/crates/shirabe/src/config/json_config_source.rs
index 3e0d285..2509239 100644
--- a/crates/shirabe/src/config/json_config_source.rs
+++ b/crates/shirabe/src/config/json_config_source.rs
@@ -5,7 +5,7 @@ use anyhow::Result;
use indexmap::IndexMap;
use shirabe_php_shim::{
PHP_EOL, PhpMixed, RuntimeException, chmod, explode, file_get_contents, file_put_contents,
- implode, is_writable, sprintf,
+ implode, is_writable,
};
use crate::config::ConfigSourceInterface;
@@ -37,7 +37,7 @@ impl JsonConfigSource {
return Err(RuntimeException {
message: format!(
"The file \"{}\" is not writable.",
- self.file.borrow().get_path().to_string(),
+ self.file.borrow().get_path(),
),
code: 0,
}
@@ -48,7 +48,7 @@ impl JsonConfigSource {
return Err(RuntimeException {
message: format!(
"The file \"{}\" is not readable.",
- self.file.borrow().get_path().to_string(),
+ self.file.borrow().get_path(),
),
code: 0,
}
@@ -401,7 +401,7 @@ impl ConfigSourceInterface for JsonConfigSource {
return Err(RuntimeException {
message: format!(
"The referenced repository \"{}\" does not exist.",
- reference_name.to_string(),
+ reference_name,
),
code: 0,
}
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs
index 319e8dd..5092640 100644
--- a/crates/shirabe/src/console/application.rs
+++ b/crates/shirabe/src/console/application.rs
@@ -14,7 +14,6 @@ use shirabe_external_packages::symfony::console::command_loader::command_loader_
use shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput;
use shirabe_external_packages::symfony::console::completion::completion_suggestions::CompletionSuggestions;
use shirabe_external_packages::symfony::console::exception::CommandNotFoundException;
-use shirabe_external_packages::symfony::console::exception::ExceptionInterface;
use shirabe_external_packages::symfony::console::exception::invalid_argument_exception::InvalidArgumentException as ConsoleInvalidArgumentException;
use shirabe_external_packages::symfony::console::exception::invalid_option_exception::InvalidOptionException;
use shirabe_external_packages::symfony::console::exception::logic_exception::LogicException as ConsoleLogicException;
@@ -34,7 +33,6 @@ use shirabe_external_packages::symfony::console::input::InputOption;
use shirabe_external_packages::symfony::console::input::argv_input::ArgvInput;
use shirabe_external_packages::symfony::console::input::array_input::ArrayInput;
use shirabe_external_packages::symfony::console::input::input_argument::InputArgument;
-use shirabe_external_packages::symfony::console::output::ConsoleOutputInterface;
use shirabe_external_packages::symfony::console::output::console_output::ConsoleOutput;
use shirabe_external_packages::symfony::console::output::output_interface::{
self as output_interface, OutputInterface,
@@ -46,20 +44,18 @@ use shirabe_external_packages::symfony::console::terminal::Terminal;
use shirabe_external_packages::symfony::process::exception::ProcessTimedOutException;
use shirabe_php_shim::{
LogicException as ShimLogicException, PHP_BINARY, PHP_VERSION, PHP_VERSION_ID, PhpMixed,
- RuntimeException, UnexpectedValueException, array_merge, bin2hex, chdir, count,
- date_default_timezone_get, date_default_timezone_set, defined, dirname, disk_free_space,
- error_get_last, extension_loaded, file_exists, file_get_contents, file_put_contents,
- function_exists, get_class, getcwd, getmypid, glob, in_array, ini_set, is_array, is_dir,
- is_file, is_string, is_subclass_of, json_decode, memory_get_peak_usage, memory_get_usage,
- method_exists, microtime, php_uname, posix_getuid, random_bytes, realpath,
- register_shutdown_function, restore_error_handler, round, sprintf, str_contains, str_replace,
+ RuntimeException, bin2hex, chdir, date_default_timezone_get, date_default_timezone_set,
+ defined, dirname, disk_free_space, error_get_last, extension_loaded, file_exists,
+ file_get_contents, file_put_contents, function_exists, getcwd, getmypid, glob, in_array,
+ ini_set, is_array, is_dir, is_file, is_string, is_subclass_of, json_decode,
+ memory_get_peak_usage, memory_get_usage, microtime, php_uname, posix_getuid, random_bytes,
+ realpath, register_shutdown_function, restore_error_handler, round, str_contains, str_replace,
strpos, strtoupper, sys_get_temp_dir, time, unlink,
};
use crate::command::AboutCommand;
use crate::command::ArchiveCommand;
use crate::command::AuditCommand;
-use crate::command::BaseCommand;
use crate::command::BumpCommand;
use crate::command::CheckPlatformReqsCommand;
use crate::command::ClearCacheCommand;
@@ -91,7 +87,6 @@ use crate::command::SuggestsCommand;
use crate::command::UpdateCommand;
use crate::command::ValidateCommand;
use crate::composer;
-use crate::composer::ComposerHandle;
use crate::composer::PartialComposerHandle;
use crate::console::GithubActionError;
use crate::downloader::TransportException;
@@ -796,7 +791,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.", name.to_string()),
+ format!("The command \"{}\" does not exist.", name),
Vec::new(),
0,
)
@@ -808,7 +803,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()\".",
- name.to_string(),
+ name,
),
Vec::new(),
0,
@@ -911,7 +906,7 @@ impl Application {
if namespaces.is_empty() {
let mut message = format!(
"There are no commands defined in the \"{}\" namespace.",
- namespace.to_string(),
+ namespace,
);
let alternatives = self.find_alternatives(namespace, &all_namespaces);
@@ -938,7 +933,7 @@ impl Application {
return Err(NamespaceNotFoundException(CommandNotFoundException::new(
format!(
"The namespace \"{}\" is ambiguous.\nDid you mean one of these?\n{}.",
- namespace.to_string(),
+ namespace,
self.get_abbreviation_suggestions(&namespaces),
),
namespaces.clone(),
@@ -1140,8 +1135,7 @@ impl Application {
return Err(CommandNotFoundException::new(
format!(
"SymfonyCommand \"{}\" is ambiguous.\nDid you mean one of these?\n{}.",
- name.to_string(),
- suggestions,
+ name, suggestions,
),
commands.clone(),
0,
@@ -1156,7 +1150,7 @@ impl Application {
if command.borrow().is_hidden() {
return Err(CommandNotFoundException::new(
- format!("The command \"{}\" does not exist.", name.to_string()),
+ format!("The command \"{}\" does not exist.", name),
Vec::new(),
0,
)
@@ -2045,7 +2039,7 @@ impl ApplicationHandle {
&no_composer_json_commands_pm,
true,
)
- && !file_exists(&Factory::get_composer_file().unwrap_or_default())
+ && !file_exists(Factory::get_composer_file().unwrap_or_default())
&& use_parent_dir_if_no_json_available.as_bool() != Some(false)
&& (command_name.as_deref() != Some("config")
|| (!input
@@ -2069,7 +2063,7 @@ impl ApplicationHandle {
// abort when we reach the home dir or top of the filesystem
while dirname(&dir) != dir && dir != home {
- if file_exists(&format!(
+ if file_exists(format!(
"{}/{}",
dir,
Factory::get_composer_file().unwrap_or_default()
diff --git a/crates/shirabe/src/dependency_resolver/default_policy.rs b/crates/shirabe/src/dependency_resolver/default_policy.rs
index 863637c..5b0981d 100644
--- a/crates/shirabe/src/dependency_resolver/default_policy.rs
+++ b/crates/shirabe/src/dependency_resolver/default_policy.rs
@@ -4,7 +4,6 @@ use std::cell::RefCell;
use indexmap::IndexMap;
use shirabe_semver::CompilingMatcher;
-use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use crate::dependency_resolver::PolicyInterface;
diff --git a/crates/shirabe/src/dependency_resolver/pool.rs b/crates/shirabe/src/dependency_resolver/pool.rs
index 652cf43..43d959b 100644
--- a/crates/shirabe/src/dependency_resolver/pool.rs
+++ b/crates/shirabe/src/dependency_resolver/pool.rs
@@ -9,7 +9,6 @@ use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use crate::advisory::AnySecurityAdvisory;
-use crate::package::BasePackage;
use crate::package::BasePackageHandle;
use crate::package::version::VersionParser;
diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs
index 3663e43..e2c5b11 100644
--- a/crates/shirabe/src/dependency_resolver/pool_builder.rs
+++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs
@@ -5,8 +5,8 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
- LogicException, PhpMixed, array_flip, array_flip_strings, array_map, array_merge, array_search,
- array_search_mixed, count, in_array, microtime, number_format, round, sprintf, strpos,
+ LogicException, PhpMixed, array_flip_strings, array_map, in_array, microtime, number_format,
+ round, strpos,
};
use shirabe_semver::CompilingMatcher;
use shirabe_semver::Intervals;
@@ -25,16 +25,11 @@ use crate::io::IOInterfaceImmutable;
use crate::package::AliasPackageHandle;
use crate::package::BasePackageHandle;
use crate::package::CompleteAliasPackageHandle;
-use crate::package::CompletePackage;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
use crate::package::base_package;
use crate::package::version::StabilityFilter;
-use crate::plugin::PluginEvents;
-use crate::plugin::PrePoolCreateEvent;
use crate::repository::CanonicalPackagesTrait;
use crate::repository::PlatformRepository;
-use crate::repository::RepositoryInterface;
use crate::repository::RepositoryInterfaceHandle;
use crate::repository::RootPackageRepository;
diff --git a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs
index 46bed91..3cc5551 100644
--- a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs
+++ b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs
@@ -3,7 +3,7 @@
use std::rc::Rc;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, implode, ksort};
+use shirabe_php_shim::{implode, ksort};
use shirabe_semver::CompilingMatcher;
use shirabe_semver::Intervals;
use shirabe_semver::constraint::AnyConstraint;
@@ -14,7 +14,6 @@ use crate::dependency_resolver::PolicyInterface;
use crate::dependency_resolver::Pool;
use crate::dependency_resolver::Request;
use crate::package::BasePackageHandle;
-use crate::package::PackageInterface;
use crate::package::version::VersionParser;
/// Optimizes a given pool
diff --git a/crates/shirabe/src/dependency_resolver/problem.rs b/crates/shirabe/src/dependency_resolver/problem.rs
index b65a2c9..230ebc3 100644
--- a/crates/shirabe/src/dependency_resolver/problem.rs
+++ b/crates/shirabe/src/dependency_resolver/problem.rs
@@ -5,25 +5,19 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::console::formatter::OutputFormatter;
use shirabe_php_shim::{
- LogicException, PhpMixed, defined, extension_loaded, implode, in_array, php_to_string,
- phpversion, spl_object_hash, sprintf, str_replace, str_starts_with, stripos, strpos,
- strtolower, substr, substr_count, version_compare,
+ LogicException, PhpMixed, defined, extension_loaded, implode, in_array, phpversion,
+ spl_object_hash, sprintf, str_replace, str_starts_with, stripos, strpos, strtolower, substr,
+ substr_count, version_compare,
};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::MultiConstraint;
use shirabe_semver::constraint::SimpleConstraint;
-use crate::advisory::SecurityAdvisory;
use crate::dependency_resolver::Pool;
use crate::dependency_resolver::Request;
use crate::dependency_resolver::rule::{self, Rule};
-use crate::package::AliasPackage;
-use crate::package::BasePackage;
use crate::package::BasePackageHandle;
-use crate::package::CompletePackageInterface;
use crate::package::Link;
-use crate::package::PackageInterface;
-use crate::package::RootPackageInterface;
use crate::package::version::VersionParser;
use crate::repository::LockArrayRepository;
use crate::repository::PlatformRepository;
diff --git a/crates/shirabe/src/dependency_resolver/request.rs b/crates/shirabe/src/dependency_resolver/request.rs
index d391c0a..d3bcdfc 100644
--- a/crates/shirabe/src/dependency_resolver/request.rs
+++ b/crates/shirabe/src/dependency_resolver/request.rs
@@ -1,7 +1,7 @@
//! ref: composer/src/Composer/DependencyResolver/Request.php
use indexmap::IndexMap;
-use shirabe_php_shim::{LogicException, spl_object_hash, strtolower};
+use shirabe_php_shim::{LogicException, strtolower};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::MatchAllConstraint;
diff --git a/crates/shirabe/src/dependency_resolver/rule.rs b/crates/shirabe/src/dependency_resolver/rule.rs
index bc6fd95..306f633 100644
--- a/crates/shirabe/src/dependency_resolver/rule.rs
+++ b/crates/shirabe/src/dependency_resolver/rule.rs
@@ -1,14 +1,12 @@
//! ref: composer/src/Composer/DependencyResolver/Rule.php
-use std::any::Any;
use std::cell::RefCell;
use std::rc::Rc;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_php_shim::{
- LogicException, PhpMixed, RuntimeException, array_filter, array_keys, array_shift,
- array_values, implode, is_object,
+ LogicException, PhpMixed, RuntimeException, array_keys, array_shift, implode,
};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
@@ -19,12 +17,8 @@ use crate::dependency_resolver::Pool;
use crate::dependency_resolver::Problem;
use crate::dependency_resolver::Request;
use crate::dependency_resolver::Rule2Literals;
-use crate::dependency_resolver::RuleSet;
-use crate::package::AliasPackage;
-use crate::package::BasePackage;
use crate::package::BasePackageHandle;
use crate::package::Link;
-use crate::package::PackageInterface;
use crate::package::version::VersionParser;
use crate::repository::PlatformRepository;
use crate::repository::RepositoryInterface;
@@ -598,7 +592,7 @@ impl Rule {
)
}
r if r == RULE_LEARNED => {
- /// @TODO currently still generates way too much output to be helpful, and in some cases can even lead to endless recursion
+ // @TODO currently still generates way too much output to be helpful, and in some cases can even lead to endless recursion
// (PHP commented-out alternative code preserved)
let learned_string = " (conflict analysis result)";
diff --git a/crates/shirabe/src/dependency_resolver/rule_set.rs b/crates/shirabe/src/dependency_resolver/rule_set.rs
index 2d1cb78..d88f346 100644
--- a/crates/shirabe/src/dependency_resolver/rule_set.rs
+++ b/crates/shirabe/src/dependency_resolver/rule_set.rs
@@ -10,7 +10,6 @@ use crate::dependency_resolver::Pool;
use crate::dependency_resolver::Request;
use crate::dependency_resolver::Rule;
use crate::dependency_resolver::RuleSetIterator;
-use crate::package::BasePackageHandle;
use crate::repository::RepositorySet;
#[derive(Debug)]
diff --git a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs
index 5ec027b..1d9d0c4 100644
--- a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs
+++ b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs
@@ -1,12 +1,10 @@
//! ref: composer/src/Composer/DependencyResolver/RuleSetGenerator.php
-use std::any::Any;
use std::cell::RefCell;
use std::collections::VecDeque;
use std::rc::Rc;
use indexmap::IndexMap;
-use shirabe_php_shim::PhpMixed;
use crate::dependency_resolver::GenericRule;
use crate::dependency_resolver::MultiConflictRule;
diff --git a/crates/shirabe/src/dependency_resolver/solver.rs b/crates/shirabe/src/dependency_resolver/solver.rs
index cd00757..53a26ac 100644
--- a/crates/shirabe/src/dependency_resolver/solver.rs
+++ b/crates/shirabe/src/dependency_resolver/solver.rs
@@ -5,15 +5,12 @@ use std::rc::Rc;
use indexmap::IndexMap;
-use shirabe_php_shim::{
- PhpMixed, array_pop, array_shift, array_unshift, microtime, spl_object_hash, sprintf,
-};
+use shirabe_php_shim::{array_shift, array_unshift, microtime, spl_object_hash};
use shirabe_semver::constraint::AnyConstraint;
use crate::dependency_resolver::Decisions;
use crate::dependency_resolver::GenericRule;
use crate::dependency_resolver::LockTransaction;
-use crate::dependency_resolver::MultiConflictRule;
use crate::dependency_resolver::PolicyInterface;
use crate::dependency_resolver::Pool;
use crate::dependency_resolver::Problem;
diff --git a/crates/shirabe/src/downloader/archive_downloader.rs b/crates/shirabe/src/downloader/archive_downloader.rs
index e8ce9b3..b1bdee7 100644
--- a/crates/shirabe/src/downloader/archive_downloader.rs
+++ b/crates/shirabe/src/downloader/archive_downloader.rs
@@ -12,7 +12,6 @@ use std::path::{Path, PathBuf};
use crate::dependency_resolver::operation::InstallOperation;
use crate::downloader::DownloaderInterface;
use crate::downloader::FileDownloader;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::package::PackageInterfaceHandle;
use crate::util::Filesystem;
@@ -165,11 +164,8 @@ pub trait ArchiveDownloader {
}
let content_dir = get_folder_content(&temporary_dir);
- let single_dir_at_top_level = content_dir.len() == 1
- && content_dir
- .first()
- .map(|file| is_dir(file))
- .unwrap_or(false);
+ let single_dir_at_top_level =
+ content_dir.len() == 1 && content_dir.first().map(is_dir).unwrap_or(false);
if rename_as_one {
// if the target $path is clear, we can rename the whole package in one go instead of looping over the contents
diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs
index 15275a9..183813d 100644
--- a/crates/shirabe/src/downloader/download_manager.rs
+++ b/crates/shirabe/src/downloader/download_manager.rs
@@ -6,8 +6,8 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_keys,
- array_reverse, array_shift, dirname, get_class, implode, in_array, preg_quote, rtrim, sprintf,
- str_replace, strtolower, usort,
+ array_reverse, array_shift, dirname, implode, in_array, preg_quote, rtrim, str_replace,
+ strtolower, usort,
};
use crate::downloader::DownloaderInterface;
@@ -162,7 +162,7 @@ impl DownloadManager {
shirabe_php_shim::get_class_obj(&*downloader.borrow()),
downloader_installation_source,
installation_source.clone().unwrap_or_default(),
- package.to_string(),
+ package,
),
code: 0,
}
diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs
index 6b2162a..b03db38 100644
--- a/crates/shirabe/src/downloader/file_downloader.rs
+++ b/crates/shirabe/src/downloader/file_downloader.rs
@@ -26,13 +26,9 @@ use crate::event_dispatcher::EventDispatcher;
use crate::exception::IrrecoverableDownloadException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::io::IOInterfaceMutable;
use crate::io::NullIO;
use crate::package::PackageInterfaceHandle;
use crate::package::comparer::Comparer;
-use crate::plugin::PluginEvents;
-use crate::plugin::PostFileDownloadEvent;
-use crate::plugin::PreFileDownloadEvent;
use crate::util::Filesystem;
use crate::util::HttpDownloader;
use crate::util::Platform;
@@ -111,7 +107,7 @@ impl FileDownloader {
))))
});
- let mut this = Self {
+ let this = Self {
io,
config,
http_downloader,
@@ -123,10 +119,12 @@ impl FileDownloader {
additional_cleanup_paths: IndexMap::new(),
};
- if this.cache.is_some() && this.cache.as_ref().unwrap().borrow().gc_is_necessary() {
+ if let Some(cache) = &this.cache
+ && cache.borrow().gc_is_necessary()
+ {
// PHP: writeError('Running cache garbage collection', true, io_interface::VERY_VERBOSE)
this.io.write_error("Running cache garbage collection");
- this.cache.as_ref().unwrap().borrow_mut().gc(
+ cache.borrow_mut().gc(
this.config
.borrow_mut()
.get("cache-files-ttl")
@@ -537,8 +535,8 @@ impl DownloaderInterface for FileDownloader {
}
self.filesystem.borrow_mut().ensure_directory_exists(path)?;
self.filesystem.borrow_mut().rename(
- &self.get_file_name(package.clone(), path),
- &format!(
+ self.get_file_name(package.clone(), path),
+ format!(
"{}/{}",
path,
self.get_dist_path(package.clone(), PATHINFO_BASENAME)
@@ -626,10 +624,10 @@ impl ChangeReportInterface for FileDownloader {
// httpDownloader->wait() / process->wait(); the single-threaded sync bridge block_on's the
// download/install futures, so a rejection surfaces directly as the Err captured below.
let result: Result<String> = (|| -> Result<String> {
- if is_dir(&format!("{}_compare", target_dir)) {
+ if is_dir(format!("{}_compare", target_dir)) {
self.filesystem
.borrow_mut()
- .remove_directory(&format!("{}_compare", target_dir))?;
+ .remove_directory(format!("{}_compare", target_dir))?;
}
tokio::runtime::Runtime::new()
@@ -655,7 +653,7 @@ impl ChangeReportInterface for FileDownloader {
let output = comparer.get_changed_as_string(true, false);
self.filesystem
.borrow_mut()
- .remove_directory(&format!("{}_compare", target_dir))?;
+ .remove_directory(format!("{}_compare", target_dir))?;
Ok(output)
})();
@@ -710,9 +708,11 @@ impl FileDownloader {
pub(crate) fn clear_last_cache_write(&self, package: PackageInterfaceHandle) {
let mut last_cache_writes = self.last_cache_writes.lock().unwrap();
- if self.cache.is_some() && last_cache_writes.contains_key(&package.get_name()) {
+ if let Some(cache) = &self.cache
+ && last_cache_writes.contains_key(&package.get_name())
+ {
let key = last_cache_writes.get(&package.get_name()).unwrap().clone();
- self.cache.as_ref().unwrap().borrow_mut().remove(&key);
+ cache.borrow_mut().remove(&key);
last_cache_writes.shift_remove(&package.get_name());
}
}
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs
index a3666d0..fd044f8 100644
--- a/crates/shirabe/src/downloader/git_downloader.rs
+++ b/crates/shirabe/src/downloader/git_downloader.rs
@@ -6,7 +6,7 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
PhpMixed, RuntimeException, array_map, basename, dirname, implode, in_array, is_dir,
- preg_quote, realpath, rtrim, sprintf, strlen, strpos, substr, trim, version_compare,
+ preg_quote, realpath, rtrim, strlen, strpos, substr, trim, version_compare,
};
use crate::cache::Cache;
@@ -18,7 +18,6 @@ use crate::downloader::VcsDownloader;
use crate::downloader::VcsDownloaderBase;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
use crate::util::Filesystem;
use crate::util::Git as GitUtil;
@@ -1395,7 +1394,7 @@ impl VcsDownloader for GitDownloader {
fn has_metadata_repository(&self, path: &str) -> bool {
let path = self.normalize_path(path);
- is_dir(&format!("{}/.git", path))
+ is_dir(format!("{}/.git", path))
}
}
diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs
index 35c3709..694f758 100644
--- a/crates/shirabe/src/downloader/path_downloader.rs
+++ b/crates/shirabe/src/downloader/path_downloader.rs
@@ -4,7 +4,6 @@ use crate::io::io_interface;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::filesystem::Filesystem as SymfonyFilesystem;
-use shirabe_external_packages::symfony::filesystem::exception::IOException;
use shirabe_php_shim::{
DIRECTORY_SEPARATOR, PHP_WINDOWS_VERSION_MAJOR, PHP_WINDOWS_VERSION_MINOR, PhpMixed,
RuntimeException, file_exists, function_exists, is_dir, realpath,
@@ -14,7 +13,6 @@ use crate::cache::Cache;
use crate::config::Config;
use crate::dependency_resolver::operation::InstallOperation;
use crate::dependency_resolver::operation::UninstallOperation;
-use crate::downloader::ChangeReportInterface;
use crate::downloader::DownloaderInterface;
use crate::downloader::FileDownloader;
use crate::downloader::VcsCapableDownloaderInterface;
diff --git a/crates/shirabe/src/downloader/perforce_downloader.rs b/crates/shirabe/src/downloader/perforce_downloader.rs
index 687b7ef..f93cfa8 100644
--- a/crates/shirabe/src/downloader/perforce_downloader.rs
+++ b/crates/shirabe/src/downloader/perforce_downloader.rs
@@ -8,7 +8,6 @@ use crate::downloader::VcsDownloader;
use crate::downloader::VcsDownloaderBase;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
use crate::repository::VcsRepository;
use crate::util::Filesystem;
@@ -17,7 +16,6 @@ use crate::util::ProcessExecutor;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
-use std::any::Any;
#[derive(Debug)]
pub struct PerforceDownloader {
@@ -48,8 +46,8 @@ impl PerforceDownloader {
}
pub fn init_perforce(&mut self, package: PackageInterfaceHandle, path: String, url: String) {
- if self.perforce.is_some() {
- self.perforce.as_mut().unwrap().initialize_path(&path);
+ if let Some(perforce) = self.perforce.as_mut() {
+ perforce.initialize_path(&path);
return;
}
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs
index 1a7d81d..8c13a05 100644
--- a/crates/shirabe/src/downloader/svn_downloader.rs
+++ b/crates/shirabe/src/downloader/svn_downloader.rs
@@ -447,7 +447,7 @@ impl VcsDownloader for SvnDownloader {
}
fn has_metadata_repository(&self, path: &str) -> bool {
- is_dir(&format!("{}/.svn", path))
+ is_dir(format!("{}/.svn", path))
}
}
diff --git a/crates/shirabe/src/downloader/vcs_downloader.rs b/crates/shirabe/src/downloader/vcs_downloader.rs
index 78b3ae7..8084c37 100644
--- a/crates/shirabe/src/downloader/vcs_downloader.rs
+++ b/crates/shirabe/src/downloader/vcs_downloader.rs
@@ -4,9 +4,8 @@ use crate::io::io_interface;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_php_shim::{
- InvalidArgumentException, PhpMixed, RuntimeException, array_map, array_shift, count, explode,
- get_class, get_class_err, implode, rawurldecode, realpath, str_replace, strlen, strpos, substr,
- trim,
+ InvalidArgumentException, PhpMixed, RuntimeException, array_map, array_shift, explode,
+ get_class_err, implode, rawurldecode, realpath, str_replace, strlen, strpos, substr, trim,
};
use crate::config::Config;
diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs
index 80ce6f9..6f3c6e5 100644
--- a/crates/shirabe/src/downloader/zip_downloader.rs
+++ b/crates/shirabe/src/downloader/zip_downloader.rs
@@ -2,9 +2,7 @@
use crate::downloader::ArchiveDownloader;
use crate::downloader::ChangeReportInterface;
-use crate::downloader::DownloaderInterface;
use crate::downloader::FileDownloader;
-use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::package::PackageInterfaceHandle;
use crate::util::IniHelper;
@@ -13,7 +11,6 @@ use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::process::ExecutableFinder;
-use shirabe_external_packages::symfony::process::Process;
use shirabe_php_shim::{
DIRECTORY_SEPARATOR, ErrorException, PhpMixed, RuntimeException, UnexpectedValueException,
ZipArchive, bin2hex, class_exists, file_exists, file_get_contents, filesize, function_exists,
@@ -290,69 +287,69 @@ impl ZipDownloader {
zip_archive.open(file, 0)
};
- if retval.is_ok() {
- let archive_size = filesize(file);
- let total_files = zip_archive.count();
- if total_files > 0 {
- let mut total_size: i64 = 0;
- let mut inspect_all = false;
- let mut files_to_inspect = total_files.min(5);
- let mut i: i64 = 0;
- while i < files_to_inspect {
- let stat_index = if inspect_all {
- i
- } else {
- random_int(0..total_files)
- };
- if let Some(stat) = zip_archive.stat_index(stat_index) {
- let size = stat.get("size").and_then(|v| v.as_int()).unwrap_or(0);
- let comp_size =
- stat.get("comp_size").and_then(|v| v.as_int()).unwrap_or(0);
- total_size += size;
- if !inspect_all && size > comp_size * 200 {
- total_size = 0;
- inspect_all = true;
- i = -1;
- files_to_inspect = total_files;
+ match retval {
+ Ok(_) => {
+ let archive_size = filesize(file);
+ let total_files = zip_archive.count();
+ if total_files > 0 {
+ let mut total_size: i64 = 0;
+ let mut inspect_all = false;
+ let mut files_to_inspect = total_files.min(5);
+ let mut i: i64 = 0;
+ while i < files_to_inspect {
+ let stat_index = if inspect_all {
+ i
+ } else {
+ random_int(0..total_files)
+ };
+ if let Some(stat) = zip_archive.stat_index(stat_index) {
+ let size = stat.get("size").and_then(|v| v.as_int()).unwrap_or(0);
+ let comp_size =
+ stat.get("comp_size").and_then(|v| v.as_int()).unwrap_or(0);
+ total_size += size;
+ if !inspect_all && size > comp_size * 200 {
+ total_size = 0;
+ inspect_all = true;
+ i = -1;
+ files_to_inspect = total_files;
+ }
}
+ i += 1;
}
- i += 1;
- }
- if let Some(archive_sz) = archive_size
- && total_size > archive_sz * 100
- && total_size > 50 * 1024 * 1024
- {
- return Err(RuntimeException {
+ if let Some(archive_sz) = archive_size
+ && total_size > archive_sz * 100
+ && total_size > 50 * 1024 * 1024
+ {
+ return Err(RuntimeException {
message: format!(
"Invalid zip file for \"{}\" with compression ratio >99% (possible zip bomb)",
package.get_name(),
),
code: 0,
}.into());
+ }
}
- }
- let extract_result = zip_archive.extract_to(path)?;
+ let extract_result = zip_archive.extract_to(path)?;
- if extract_result {
- zip_archive.close();
- return Ok(None);
- }
+ if extract_result {
+ zip_archive.close();
+ return Ok(None);
+ }
- Err(RuntimeException {
- message: format!(
- "There was an error extracting the ZIP file for \"{}\", it is either corrupted or using an invalid format.",
- package.get_name(),
- ),
- code: 0,
- }.into())
- } else {
- let code = retval.unwrap_err();
- Err(UnexpectedValueException {
+ Err(RuntimeException {
+ message: format!(
+ "There was an error extracting the ZIP file for \"{}\", it is either corrupted or using an invalid format.",
+ package.get_name(),
+ ),
+ code: 0,
+ }.into())
+ }
+ Err(code) => Err(UnexpectedValueException {
message: self.get_error_message(code, file).trim_end().to_string(),
code,
}
- .into())
+ .into()),
}
})();
diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
index 2441be6..f74b4a2 100644
--- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
+++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
@@ -6,13 +6,12 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::process::ExecutableFinder;
use shirabe_external_packages::symfony::process::PhpExecutableFinder;
use shirabe_php_shim::{
- Exception, InvalidArgumentException, LogicException, PATH_SEPARATOR, PHP_VERSION_ID, PhpMixed,
- RuntimeException, array_pop, array_push, array_search_in_vec, array_splice, class_exists,
- count_mixed, defined, file_exists, get_class, hash, implode, ini_get, is_a, is_array,
- is_callable, is_object, is_string, krsort, method_exists, preg_quote, realpath,
- spl_autoload_functions, spl_autoload_register, spl_autoload_unregister, spl_object_hash,
- sprintf, str_contains, str_ends_with, str_replace, str_starts_with, strlen, strpos, strtoupper,
- substr, trim,
+ InvalidArgumentException, PATH_SEPARATOR, PhpMixed, RuntimeException, array_pop, array_push,
+ array_search_in_vec, array_splice, class_exists, defined, file_exists, get_class, hash,
+ implode, ini_get, is_a, is_array, is_callable, is_object, is_string, krsort, preg_quote,
+ realpath, spl_autoload_functions, spl_autoload_register, spl_autoload_unregister,
+ spl_object_hash, str_contains, str_ends_with, str_replace, str_starts_with, strlen, strpos,
+ strtoupper, substr, trim,
};
use crate::autoload::ClassLoader;
@@ -27,11 +26,8 @@ use crate::event_dispatcher::ScriptExecutionException;
use crate::installer::BinaryInstaller;
use crate::installer::InstallerEvent;
use crate::installer::PackageEvent;
-use crate::io::ConsoleIO;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::plugin::CommandEvent;
-use crate::plugin::PreCommandRunEvent;
use crate::repository::RepositoryInterface;
use crate::script::Event as ScriptEvent;
use crate::util::Platform;
@@ -366,9 +362,10 @@ impl EventDispatcher {
};
self.io.write_error3(
&format!(
- "> {}: {}",
+ "> {}: {}->{}",
formatted_event_name_with_args.clone(),
- format!("{}->{}", prefix, method_name),
+ prefix,
+ method_name,
),
true,
crate::io::VERBOSE,
@@ -441,7 +438,7 @@ impl EventDispatcher {
self.io.write_error3(&format!(
"<error>Script {} handling the {} event returned with error code {}</error>",
callable_str.clone(),
- event.get_name().to_string(),
+ event.get_name(),
exit_code
), true, crate::io::QUIET);
@@ -494,7 +491,7 @@ impl EventDispatcher {
&format!(
"<error>Script {} was called via {}</error>",
callable_str.clone(),
- event.get_name().to_string(),
+ event.get_name(),
),
true,
crate::io::QUIET,
@@ -538,7 +535,7 @@ impl EventDispatcher {
&format!(
"<error>Script {} handling the {} event terminated with an exception</error>",
callable_str.clone(),
- event.get_name().to_string(),
+ event.get_name(),
),
true,
crate::io::QUIET,
@@ -637,7 +634,7 @@ impl EventDispatcher {
if self.io.is_verbose() {
self.io.write_error3(
- &format!("> {}: {}", event.get_name().to_string(), exec.clone()),
+ &format!("> {}: {}", event.get_name(), exec.clone()),
true,
crate::io::NORMAL,
);
@@ -762,7 +759,7 @@ impl EventDispatcher {
self.io.write_error3(&format!(
"<error>Script {} handling the {} event returned with error code {}</error>",
callable_str.clone(),
- event.get_name().to_string(),
+ event.get_name(),
exit_code
), true, crate::io::QUIET);
@@ -863,18 +860,13 @@ impl EventDispatcher {
) -> anyhow::Result<PhpMixed> {
if self.io.is_verbose() {
self.io.write_error3(
- &format!(
- "> {}: {}::{}",
- event.get_name().to_string(),
- class_name.to_string(),
- method_name.to_string(),
- ),
+ &format!("> {}: {}::{}", event.get_name(), class_name, method_name,),
true,
crate::io::NORMAL,
);
} else if self.event_needs_to_output(event) {
self.io.write_error3(
- &format!("> {}::{}", class_name.to_string(), method_name.to_string()),
+ &format!("> {}::{}", class_name, method_name),
true,
crate::io::NORMAL,
);
@@ -1211,8 +1203,8 @@ impl EventDispatcher {
shirabe_php_shim::PhpMixed::Bool(false),
);
- if self.loader.is_some() {
- self.loader.as_mut().unwrap().unregister();
+ if let Some(loader) = self.loader.as_mut() {
+ loader.unregister();
}
let vendor_dir = composer
@@ -1222,7 +1214,7 @@ impl EventDispatcher {
.as_string()
.map(|s| s.to_string())
.unwrap_or_default();
- let mut loader = generator.create_loader(&map, Some(vendor_dir.clone()));
+ let loader = generator.create_loader(&map, Some(vendor_dir.clone()));
loader.register(false);
self.loader = Some(loader);
Ok(())
diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs
index 0c83d5d..8a97313 100644
--- a/crates/shirabe/src/factory.rs
+++ b/crates/shirabe/src/factory.rs
@@ -7,11 +7,10 @@ use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle
use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyleInterface;
use shirabe_external_packages::symfony::console::output::ConsoleOutput;
use shirabe_php_shim::{
- InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, Phar, PhpMixed,
- RuntimeException, UnexpectedValueException, ZipArchive, array_keys, array_replace_recursive,
- class_exists, dirname, extension_loaded, file_exists, file_get_contents, file_put_contents,
- implode, in_array, is_array, is_dir, is_file, is_string, json_decode, mkdir, pathinfo,
- realpath, rename, str_replace, strpos, strtr, substr, trim,
+ InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, PhpMixed, RuntimeException,
+ UnexpectedValueException, array_replace_recursive, class_exists, dirname, extension_loaded,
+ file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file, json_decode,
+ mkdir, pathinfo, realpath, rename, strpos, strtr, substr, trim,
};
use crate::autoload::AutoloadGenerator;
@@ -40,16 +39,11 @@ use crate::event_dispatcher::EventDispatcher;
use crate::exception::NoSslException;
use crate::installer::BinaryInstaller;
use crate::installer::InstallationManager;
-use crate::installer::LibraryInstaller;
-use crate::installer::MetapackageInstaller;
-use crate::installer::PluginInstaller;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::io::IOInterfaceMutable;
use crate::json::JsonFile;
use crate::json::JsonValidationException;
use crate::package::Locker;
-use crate::package::RootPackageInterface;
use crate::package::RootPackageInterfaceHandle;
use crate::package::archiver::ArchiveManager;
use crate::package::archiver::PharArchiver;
@@ -178,8 +172,8 @@ impl Factory {
let user_dir = Self::get_user_dir()?;
if PHP_OS == "Darwin" {
// Migrate existing cache dir in old location if present
- if is_dir(&format!("{}/cache", home))
- && !is_dir(&format!("{}/Library/Caches/composer", user_dir))
+ if is_dir(format!("{}/cache", home))
+ && !is_dir(format!("{}/Library/Caches/composer", user_dir))
{
let from = format!("{}/cache", home);
let to = format!("{}/Library/Caches/composer", user_dir);
@@ -189,8 +183,7 @@ impl Factory {
return Ok(format!("{}/Library/Caches/composer", user_dir));
}
- if home == format!("{}/.composer", user_dir).as_str() && is_dir(&format!("{}/cache", home))
- {
+ if home == format!("{}/.composer", user_dir).as_str() && is_dir(format!("{}/cache", home)) {
return Ok(format!("{}/cache", home));
}
@@ -303,7 +296,7 @@ impl Factory {
config.get_str("data-dir")?,
];
for dir in &dirs {
- if !file_exists(&format!("{}/.htaccess", dir)) {
+ if !file_exists(format!("{}/.htaccess", dir)) {
if !is_dir(dir) {
let dir_owned = dir.clone();
let _ = Silencer::call(|| {
diff --git a/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs b/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs
index 1ceaa56..854a4f6 100644
--- a/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs
+++ b/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs
@@ -9,7 +9,7 @@ use shirabe_semver::constraint::MultiConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface;
-use crate::package::base_package::{self, BasePackage};
+use crate::package::base_package::{self};
use crate::repository::PlatformRepository;
#[derive(Debug)]
diff --git a/crates/shirabe/src/installed_versions.rs b/crates/shirabe/src/installed_versions.rs
index fb93172..0e22e06 100644
--- a/crates/shirabe/src/installed_versions.rs
+++ b/crates/shirabe/src/installed_versions.rs
@@ -450,7 +450,7 @@ impl InstalledVersions {
.cloned();
if let Some(cached) = cached {
installed.push(cached);
- } else if is_file(&format!("{}/composer/installed.php", vendor_dir)) {
+ } else if is_file(format!("{}/composer/installed.php", vendor_dir)) {
let required =
require_php_file(&format!("{}/composer/installed.php", vendor_dir));
let required_map: IndexMap<String, PhpMixed> =
diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs
index 7445931..2590b49 100644
--- a/crates/shirabe/src/installer.rs
+++ b/crates/shirabe/src/installer.rs
@@ -35,9 +35,8 @@ use indexmap::IndexMap;
use shirabe_external_packages::seld::json_lint::ParsingException;
use shirabe_php_shim::{
- PhpMixed, RuntimeException, array_flip, array_map, array_merge, array_unique, array_values,
- clone, count, defined, gc_collect_cycles, gc_disable, gc_enable, get_class, implode, in_array,
- intval, is_dir, is_numeric, is_string, sprintf, strcmp, strpos, strtolower, touch, usort,
+ PhpMixed, RuntimeException, array_map, array_unique, defined, gc_collect_cycles, gc_disable,
+ gc_enable, implode, intval, is_dir, is_numeric, strcmp, strpos, strtolower, touch, usort,
};
use shirabe_semver;
@@ -51,17 +50,12 @@ use crate::dependency_resolver::DefaultPolicy;
use crate::dependency_resolver::LocalRepoTransaction;
use crate::dependency_resolver::LockTransaction;
use crate::dependency_resolver::PolicyInterface;
-use crate::dependency_resolver::Pool;
use crate::dependency_resolver::PoolOptimizer;
use crate::dependency_resolver::Request;
use crate::dependency_resolver::SecurityAdvisoryPoolFilter;
use crate::dependency_resolver::Solver;
-use crate::dependency_resolver::SolverProblemsException;
use crate::dependency_resolver::UpdateAllowTransitiveDeps;
-use crate::dependency_resolver::operation::InstallOperation;
use crate::dependency_resolver::operation::OperationInterface;
-use crate::dependency_resolver::operation::UninstallOperation;
-use crate::dependency_resolver::operation::UpdateOperation;
use crate::downloader::DownloadManager;
use crate::downloader::TransportException;
use crate::event_dispatcher::EventDispatcher;
@@ -72,16 +66,11 @@ use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::package::AliasPackageHandle;
use crate::package::CompleteAliasPackageHandle;
-use crate::package::CompletePackage;
-use crate::package::CompletePackageInterface;
use crate::package::Link;
use crate::package::Locker;
-use crate::package::Package;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
-use crate::package::RootPackageInterface;
use crate::package::RootPackageInterfaceHandle;
-use crate::package::base_package::{self, BasePackage};
+use crate::package::base_package;
use crate::package::dumper::ArrayDumper;
use crate::package::loader::ArrayLoader;
use crate::package::loader::LoaderInterface;
@@ -91,7 +80,6 @@ use crate::repository::CanonicalPackagesTrait;
use crate::repository::CompositeRepository;
use crate::repository::InstalledArrayRepository;
use crate::repository::InstalledRepository;
-use crate::repository::InstalledRepositoryInterface;
use crate::repository::PlatformRepository;
use crate::repository::PlatformRepositoryHandle;
use crate::repository::RepositoryInterface;
@@ -581,7 +569,7 @@ impl Installer {
let mut locked_repository: Option<crate::repository::LockArrayRepositoryHandle> = None;
- let mut try_load_locked = || -> anyhow::Result<
+ let try_load_locked = || -> anyhow::Result<
Result<Option<crate::repository::LockArrayRepositoryHandle>, ParsingException>,
> {
if self.locker.borrow_mut().is_locked() {
@@ -961,7 +949,7 @@ impl Installer {
return Ok(0);
}
- let mut result_repo = ArrayRepository::new(vec![])?;
+ let result_repo = ArrayRepository::new(vec![])?;
let loader = ArrayLoader::new(None, true);
let dumper = ArrayDumper::new();
for pkg in lock_transaction.get_new_lock_packages(false, false) {
@@ -1506,9 +1494,12 @@ impl Installer {
}
let mut preferred_versions: Option<IndexMap<String, String>> = None;
- if for_update && self.minimal_update && locked_repo.is_some() {
+ if for_update
+ && self.minimal_update
+ && let Some(locked_repo) = locked_repo
+ {
let mut versions: IndexMap<String, String> = IndexMap::new();
- let pkgs = locked_repo.unwrap().borrow_mut().get_canonical_packages()?;
+ let pkgs = locked_repo.borrow_mut().get_canonical_packages()?;
for pkg in pkgs {
if pkg.as_alias().is_some()
|| (self.update_allow_list.is_some()
diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs
index 8e7ade5..a76f69e 100644
--- a/crates/shirabe/src/installer/binary_installer.rs
+++ b/crates/shirabe/src/installer/binary_installer.rs
@@ -147,10 +147,8 @@ impl BinaryInstaller {
// still checking for symlinks here for legacy support
self.filesystem.borrow_mut().unlink(&link);
}
- if is_file(&format!("{}.bat", link)) {
- self.filesystem
- .borrow_mut()
- .unlink(&format!("{}.bat", link));
+ if is_file(format!("{}.bat", link)) {
+ self.filesystem.borrow_mut().unlink(format!("{}.bat", link));
}
}
diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs
index e149b41..ac5f8e4 100644
--- a/crates/shirabe/src/installer/installation_manager.rs
+++ b/crates/shirabe/src/installer/installation_manager.rs
@@ -5,8 +5,8 @@ use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::seld::signal::SignalHandler;
use shirabe_php_shim::{
- InvalidArgumentException, PhpMixed, array_search_mixed, array_splice, array_unshift, count,
- http_build_query, json_encode, str_contains, str_replace, strpos, strtolower, ucfirst,
+ InvalidArgumentException, PhpMixed, array_splice, array_unshift, http_build_query, json_encode,
+ str_contains, str_replace, strpos, strtolower,
};
use crate::dependency_resolver::operation::InstallOperation;
@@ -17,14 +17,10 @@ use crate::dependency_resolver::operation::UninstallOperation;
use crate::dependency_resolver::operation::UpdateOperation;
use crate::downloader::FileDownloader;
use crate::event_dispatcher::EventDispatcher;
-use crate::installer::BinaryPresenceInterface;
use crate::installer::InstallerInterface;
use crate::installer::PackageEvents;
-use crate::installer::PluginInstaller;
-use crate::io::ConsoleIO;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
use crate::repository::InstalledRepositoryInterface;
use crate::util::Platform;
diff --git a/crates/shirabe/src/installer/library_installer.rs b/crates/shirabe/src/installer/library_installer.rs
index d716814..e2c6c0c 100644
--- a/crates/shirabe/src/installer/library_installer.rs
+++ b/crates/shirabe/src/installer/library_installer.rs
@@ -1,7 +1,5 @@
//! ref: composer/src/Composer/Installer/LibraryInstaller.php
-use std::any::Any;
-
use anyhow::Result;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
diff --git a/crates/shirabe/src/installer/plugin_installer.rs b/crates/shirabe/src/installer/plugin_installer.rs
index 2644639..cd4de0a 100644
--- a/crates/shirabe/src/installer/plugin_installer.rs
+++ b/crates/shirabe/src/installer/plugin_installer.rs
@@ -13,7 +13,7 @@ use crate::repository::InstalledRepositoryInterface;
use crate::util::Filesystem;
use crate::util::Platform;
use anyhow::Result;
-use shirabe_php_shim::{LogicException, PhpMixed, UnexpectedValueException, empty};
+use shirabe_php_shim::{PhpMixed, UnexpectedValueException, empty};
#[derive(Debug)]
pub struct PluginInstaller {
diff --git a/crates/shirabe/src/installer/suggested_packages_reporter.rs b/crates/shirabe/src/installer/suggested_packages_reporter.rs
index 979b4bb..adbfebe 100644
--- a/crates/shirabe/src/installer/suggested_packages_reporter.rs
+++ b/crates/shirabe/src/installer/suggested_packages_reporter.rs
@@ -166,8 +166,10 @@ impl SuggestedPackagesReporter {
) -> anyhow::Result<Vec<IndexMap<String, String>>> {
let suggested_packages = self.get_packages();
let mut installed_names: Vec<String> = Vec::new();
- if installed_repo.is_some() && !suggested_packages.is_empty() {
- for package in installed_repo.unwrap().get_packages()? {
+ if let Some(installed_repo) = installed_repo
+ && !suggested_packages.is_empty()
+ {
+ for package in installed_repo.get_packages()? {
installed_names.extend(package.get_names(true));
}
}
diff --git a/crates/shirabe/src/io/buffer_io.rs b/crates/shirabe/src/io/buffer_io.rs
index 75de4c7..5c93d72 100644
--- a/crates/shirabe/src/io/buffer_io.rs
+++ b/crates/shirabe/src/io/buffer_io.rs
@@ -10,8 +10,8 @@ use shirabe_external_packages::symfony::console::input::StringInput;
use shirabe_external_packages::symfony::console::output::OutputInterface;
use shirabe_external_packages::symfony::console::output::StreamOutput;
use shirabe_php_shim::{
- AsAny, PHP_EOL, PhpMixed, PhpResource, RuntimeException, SEEK_SET, fopen, fseek, fwrite,
- rewind, stream_get_contents, strip_tags,
+ PHP_EOL, PhpMixed, PhpResource, RuntimeException, SEEK_SET, fopen, fseek, fwrite, rewind,
+ stream_get_contents, strip_tags,
};
#[derive(Debug)]
diff --git a/crates/shirabe/src/io/console_io.rs b/crates/shirabe/src/io/console_io.rs
index 1876db4..d14d730 100644
--- a/crates/shirabe/src/io/console_io.rs
+++ b/crates/shirabe/src/io/console_io.rs
@@ -18,8 +18,8 @@ use shirabe_external_packages::symfony::console::question::ChoiceQuestion;
use shirabe_external_packages::symfony::console::question::Question;
use shirabe_external_packages::symfony::console::question::QuestionInterface;
use shirabe_php_shim::{
- AsAny, PhpMixed, array_search, function_exists, implode, in_array, is_array, is_string,
- mb_check_encoding, mb_convert_encoding, microtime, sprintf, str_repeat, strip_tags, strlen,
+ 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;
diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs
index 5da1a27..27540fe 100644
--- a/crates/shirabe/src/json/json_file.rs
+++ b/crates/shirabe/src/json/json_file.rs
@@ -338,7 +338,7 @@ impl JsonFile {
schema_file: Option<&str>,
) -> Result<bool> {
let mut is_composer_schema_file = false;
- let mut schema_file = match schema_file {
+ let schema_file = match schema_file {
Some(f) => f.into(),
None => {
if schema == Self::LOCK_SCHEMA {
diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs
index 71530d4..c62e31e 100644
--- a/crates/shirabe/src/json/json_manipulator.rs
+++ b/crates/shirabe/src/json/json_manipulator.rs
@@ -5,9 +5,9 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
InvalidArgumentException, LogicException, PhpMixed, addcslashes, array_key_exists, array_keys,
- array_reverse, count, empty, explode, implode, in_array, is_array, is_int, is_numeric,
- json_decode, preg_quote, rtrim, str_contains, str_repeat, str_replace, strlen, strnatcmp,
- strpos, substr, trim, uksort,
+ array_reverse, empty, explode, implode, in_array, is_array, is_int, is_numeric, json_decode,
+ preg_quote, rtrim, str_contains, str_repeat, str_replace, strlen, strnatcmp, strpos, substr,
+ trim, uksort,
};
use crate::json::JsonFile;
@@ -838,7 +838,7 @@ impl JsonManipulator {
// no node or empty node
let main_node_value = decoded.as_array().and_then(|a| a.get(main_node));
- if main_node_value.map(|v| empty(v)).unwrap_or(true) {
+ if main_node_value.map(empty).unwrap_or(true) {
return Ok(true);
}
@@ -1220,7 +1220,7 @@ impl JsonManipulator {
// no node or empty node
let main_node_value = decoded.as_array().and_then(|a| a.get(main_node));
- if main_node_value.map(|v| empty(v)).unwrap_or(true) {
+ if main_node_value.map(empty).unwrap_or(true) {
return Ok(true);
}
diff --git a/crates/shirabe/src/package/alias_package.rs b/crates/shirabe/src/package/alias_package.rs
index 1cc899d..b05387d 100644
--- a/crates/shirabe/src/package/alias_package.rs
+++ b/crates/shirabe/src/package/alias_package.rs
@@ -3,7 +3,6 @@
use chrono::{DateTime, Utc};
use indexmap::IndexMap;
use shirabe_php_shim::{PhpMixed, in_array};
-use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use crate::package::BasePackage;
diff --git a/crates/shirabe/src/package/archiver/archive_manager.rs b/crates/shirabe/src/package/archiver/archive_manager.rs
index 2c9eb35..139eb9a 100644
--- a/crates/shirabe/src/package/archiver/archive_manager.rs
+++ b/crates/shirabe/src/package/archiver/archive_manager.rs
@@ -9,9 +9,7 @@ use shirabe_php_shim::{
use crate::downloader::DownloadManager;
use crate::json::JsonFile;
-use crate::package::CompletePackageInterface;
use crate::package::CompletePackageInterfaceHandle;
-use crate::package::RootPackageInterface;
use crate::package::archiver::ArchiverInterface;
use crate::package::archiver::PharArchiver;
use crate::package::archiver::ZipArchiver;
diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs
index 20280e0..b86f1de 100644
--- a/crates/shirabe/src/package/loader/array_loader.rs
+++ b/crates/shirabe/src/package/loader/array_loader.rs
@@ -6,7 +6,7 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
E_USER_DEPRECATED, PhpMixed, UnexpectedValueException, is_scalar, is_string, json_encode,
- ltrim, sprintf, stripos, strpos, strtolower, strval, substr, trigger_error, trim,
+ ltrim, stripos, strpos, strtolower, strval, substr, trigger_error, trim,
};
use crate::package::CompleteAliasPackageHandle;
@@ -21,9 +21,9 @@ use crate::package::PackageInterfaceHandle;
use crate::package::RootAliasPackageHandle;
use crate::package::RootPackage;
use crate::package::RootPackageHandle;
+use crate::package::SUPPORTED_LINK_TYPES;
use crate::package::loader::LoaderInterface;
use crate::package::version::VersionParser;
-use crate::package::{BasePackage, SUPPORTED_LINK_TYPES};
#[derive(Debug)]
pub struct ArrayLoader {
@@ -100,7 +100,7 @@ fn php_to_map(value: &PhpMixed) -> IndexMap<String, PhpMixed> {
fn php_to_string_vec(value: &PhpMixed) -> Vec<String> {
match value {
PhpMixed::List(l) => l.iter().map(strval).collect(),
- PhpMixed::Array(m) => m.values().map(|v| strval(v)).collect(),
+ PhpMixed::Array(m) => m.values().map(strval).collect(),
_ => Vec::new(),
}
}
@@ -389,8 +389,7 @@ impl ArrayLoader {
config
.get("name")
.and_then(|v| v.as_string())
- .unwrap_or("")
- .to_string(),
+ .unwrap_or(""),
json_encode(&source).unwrap_or_default(),
),
code: 0,
@@ -400,15 +399,15 @@ impl ArrayLoader {
let source_map = source_map.unwrap();
package
.package_mut()
- .set_source_type(source_map.get("type").map(|v| strval(v)));
+ .set_source_type(source_map.get("type").map(strval));
package
.package_mut()
- .set_source_url(source_map.get("url").map(|v| strval(v)));
+ .set_source_url(source_map.get("url").map(strval));
package.package_mut().set_source_reference(
source_map
.get("reference")
.filter(|v| !v.is_null())
- .map(|v| strval(v)),
+ .map(strval),
);
if let Some(mirrors) = source_map.get("mirrors") {
package
@@ -434,8 +433,7 @@ impl ArrayLoader {
config
.get("name")
.and_then(|v| v.as_string())
- .unwrap_or("")
- .to_string(),
+ .unwrap_or(""),
json_encode(&dist).unwrap_or_default(),
),
code: 0,
@@ -445,19 +443,19 @@ impl ArrayLoader {
let dist_map = dist_map.unwrap();
package
.package_mut()
- .set_dist_type(dist_map.get("type").map(|v| strval(v)));
+ .set_dist_type(dist_map.get("type").map(strval));
package
.package_mut()
- .set_dist_url(dist_map.get("url").map(|v| strval(v)));
+ .set_dist_url(dist_map.get("url").map(strval));
package.package_mut().set_dist_reference(
dist_map
.get("reference")
.filter(|v| !v.is_null())
- .map(|v| strval(v)),
+ .map(strval),
);
package
.package_mut()
- .set_dist_sha1_checksum(dist_map.get("shasum").map(|v| strval(v)));
+ .set_dist_sha1_checksum(dist_map.get("shasum").map(strval));
if let Some(mirrors) = dist_map.get("mirrors") {
package
.package_mut()
@@ -598,7 +596,7 @@ impl ArrayLoader {
{
let keywords_vec: Vec<String> = match keywords {
PhpMixed::List(list) => list.iter().map(strval).collect(),
- PhpMixed::Array(map) => map.values().map(|v| strval(v)).collect(),
+ PhpMixed::Array(map) => map.values().map(strval).collect(),
_ => vec![],
};
package.complete_mut().set_keywords(keywords_vec);
diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs
index 308706f..556f36e 100644
--- a/crates/shirabe/src/package/loader/root_package_loader.rs
+++ b/crates/shirabe/src/package/loader/root_package_loader.rs
@@ -2,22 +2,17 @@
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{
- LogicException, PhpMixed, RuntimeException, UnexpectedValueException, strtolower, ucfirst,
-};
+use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException, strtolower};
use crate::config::Config;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::package::CompletePackageInterface;
-use crate::package::PackageInterface;
-use crate::package::RootPackageInterface;
use crate::package::loader::ArrayLoader;
use crate::package::loader::LoaderInterface;
use crate::package::loader::ValidatingArrayLoader;
use crate::package::version::VersionGuesser;
use crate::package::version::VersionParser;
-use crate::package::{BasePackage, RootPackage, STABILITIES, SUPPORTED_LINK_TYPES};
+use crate::package::{RootPackage, STABILITIES, SUPPORTED_LINK_TYPES};
use crate::repository::RepositoryFactory;
use crate::repository::RepositoryManager;
use crate::util::Platform;
diff --git a/crates/shirabe/src/package/loader/validating_array_loader.rs b/crates/shirabe/src/package/loader/validating_array_loader.rs
index 6a85e37..14500a6 100644
--- a/crates/shirabe/src/package/loader/validating_array_loader.rs
+++ b/crates/shirabe/src/package/loader/validating_array_loader.rs
@@ -1,25 +1,23 @@
//! ref: composer/src/Composer/Package/Loader/ValidatingArrayLoader.php
-use chrono::TimeZone;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
E_USER_DEPRECATED, PHP_EOL, PhpMixed, array_intersect_key, array_values, filter_var_email,
get_debug_type, is_array, is_bool, is_int, is_numeric, is_scalar, is_string, json_encode,
- parse_url_all, php_to_string, sprintf, str_replace, strcasecmp, strtolower, strtotime, substr,
+ parse_url_all, php_to_string, str_replace, strcasecmp, strtolower, strtotime, substr,
trigger_error, trim, var_export,
};
use shirabe_semver::Intervals;
use shirabe_semver::constraint::AnyConstraint;
-use shirabe_semver::constraint::MatchNoneConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use shirabe_spdx_licenses::SpdxLicenses;
use crate::package::loader::InvalidPackageException;
use crate::package::loader::LoaderInterface;
use crate::package::version::VersionParser;
-use crate::package::{BasePackage, STABILITIES, SUPPORTED_LINK_TYPES};
+use crate::package::{STABILITIES, SUPPORTED_LINK_TYPES};
use crate::repository::PlatformRepository;
#[derive(Debug)]
diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs
index 8e6f3fb..926429a 100644
--- a/crates/shirabe/src/package/locker.rs
+++ b/crates/shirabe/src/package/locker.rs
@@ -8,7 +8,7 @@ use shirabe_external_packages::seld::json_lint::ParsingException;
use shirabe_php_shim::{
DATE_RFC3339, LogicException, PhpMixed, RuntimeException, array_intersect, array_keys,
array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array, is_int,
- ksort, realpath, sprintf, strcmp, strtolower, touch2, trim, usort,
+ ksort, realpath, strcmp, strtolower, touch2, trim, usort,
};
use crate::installer::InstallationManager;
@@ -18,14 +18,13 @@ use crate::json::JsonFile;
use crate::package::BasePackageHandle;
use crate::package::CompleteAliasPackageHandle;
use crate::package::Link;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
use crate::package::RootPackageInterfaceHandle;
use crate::package::dumper::ArrayDumper;
use crate::package::loader::ArrayLoader;
use crate::package::loader::LoaderInterface;
use crate::package::version::VersionParser;
-use crate::plugin::plugin_interface::{self, PluginInterface};
+use crate::plugin::plugin_interface::{self};
use crate::repository::FindPackageConstraint;
use crate::repository::InstalledRepository;
use crate::repository::LockArrayRepository;
@@ -161,15 +160,19 @@ impl Locker {
};
let content_hash = lock_map.get("content-hash");
- if content_hash.is_some() && !shirabe_php_shim::empty(content_hash.unwrap()) {
+ if let Some(content_hash) = content_hash
+ && !shirabe_php_shim::empty(content_hash)
+ {
// There is a content hash key, use that instead of the file hash
- return Ok(self.content_hash == content_hash.unwrap().as_string().unwrap_or(""));
+ return Ok(self.content_hash == content_hash.as_string().unwrap_or(""));
}
// BC support for old lock files without content-hash
let lock_hash = lock_map.get("hash");
- if lock_hash.is_some() && !shirabe_php_shim::empty(lock_hash.unwrap()) {
- return Ok(self.hash == lock_hash.unwrap().as_string().unwrap_or(""));
+ if let Some(lock_hash) = lock_hash
+ && !shirabe_php_shim::empty(lock_hash)
+ {
+ return Ok(self.hash == lock_hash.as_string().unwrap_or(""));
}
// should not be reached unless the lock file is corrupted, so assume it's out of date
@@ -301,12 +304,14 @@ impl Locker {
let mut requirements: IndexMap<String, Link> = IndexMap::new();
let platform_value = lock_data.get("platform");
- if platform_value.is_some() && !shirabe_php_shim::empty(platform_value.unwrap()) {
+ if let Some(platform_value) = platform_value
+ && !shirabe_php_shim::empty(platform_value)
+ {
requirements = self.loader.parse_links(
"__root__",
"1.0.0",
Link::TYPE_REQUIRE,
- match platform_value.unwrap() {
+ match platform_value {
PhpMixed::Array(m) => m.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
_ => IndexMap::new(),
},
@@ -315,14 +320,14 @@ impl Locker {
let platform_dev_value = lock_data.get("platform-dev");
if with_dev_reqs
- && platform_dev_value.is_some()
- && !shirabe_php_shim::empty(platform_dev_value.unwrap())
+ && let Some(platform_dev_value) = platform_dev_value
+ && !shirabe_php_shim::empty(platform_dev_value)
{
let dev_requirements = self.loader.parse_links(
"__root__",
"1.0.0",
Link::TYPE_REQUIRE,
- match platform_dev_value.unwrap() {
+ match platform_dev_value {
PhpMixed::Array(m) => m.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
_ => IndexMap::new(),
},
@@ -730,7 +735,7 @@ impl Locker {
return Err(LogicException {
message: format!(
"Package \"{}\" has no version or name and can not be locked",
- package.to_string(),
+ package,
),
code: 0,
}
@@ -953,14 +958,11 @@ impl Locker {
for provider_link in provider_links.values() {
if provider_link.get_target() == link.get_target() {
description = format!(
- "{} as {} by {}",
+ "{} as {} by {} {}",
verb,
- provider_link.get_pretty_constraint().to_string(),
- format!(
- "{} {}",
- provider.get_pretty_name(),
- provider.get_pretty_version()
- ),
+ provider_link.get_pretty_constraint(),
+ provider.get_pretty_name(),
+ provider.get_pretty_version(),
);
break 'outer;
}
diff --git a/crates/shirabe/src/package/version/version_guesser.rs b/crates/shirabe/src/package/version/version_guesser.rs
index 5745d68..c5bf4c2 100644
--- a/crates/shirabe/src/package/version/version_guesser.rs
+++ b/crates/shirabe/src/package/version/version_guesser.rs
@@ -3,13 +3,11 @@
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_external_packages::symfony::process::Process;
use shirabe_php_shim::{
PHP_INT_MAX, PhpMixed, RuntimeException, array_keys, array_map, array_merge, empty,
function_exists, implode, is_string, json_encode, preg_quote, str_replace, strlen,
strnatcasecmp, strpos, substr, trim, usort,
};
-use shirabe_semver::VersionParser as SemverVersionParser;
use crate::config::Config;
use crate::io::IOInterface;
@@ -415,7 +413,7 @@ impl VersionGuesser {
array_map(|k: &String| k.clone(), &array_keys(&driver.get_branches()?));
// try to find the best (nearest) version branch to assume this feature's version
- let mut result = self.guess_feature_version(
+ let result = self.guess_feature_version(
package_config,
Some(version.clone()),
branches,
@@ -687,16 +685,13 @@ impl VersionGuesser {
let m1 = matches.get(1).cloned().unwrap_or_default();
let m2 = matches.get(2).cloned();
let m3 = matches.get(3).cloned();
- if m2.is_some()
- && m3.is_some()
- && (branches_path == *m2.as_ref().unwrap()
- || tags_path == *m2.as_ref().unwrap())
+ if let Some(m2) = m2.as_ref()
+ && let Some(m3) = m3.as_ref()
+ && (branches_path == *m2 || tags_path == *m2)
{
// we are in a branches path
- let version = self
- .version_parser
- .normalize_branch(m3.as_deref().unwrap())?;
- let pretty_version = format!("dev-{}", m3.as_ref().unwrap());
+ let version = self.version_parser.normalize_branch(m3)?;
+ let pretty_version = format!("dev-{}", m3);
return Ok(Some(VersionData {
version: Some(version),
diff --git a/crates/shirabe/src/package/version/version_selector.rs b/crates/shirabe/src/package/version/version_selector.rs
index 0d69132..793dd4e 100644
--- a/crates/shirabe/src/package/version/version_selector.rs
+++ b/crates/shirabe/src/package/version/version_selector.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Package/Version/VersionSelector.php
use crate::io::io_interface;
-use std::any::Any;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
@@ -139,7 +138,7 @@ impl VersionSelector {
let mut already_seen_names: IndexMap<String, bool> = IndexMap::new();
let mut found_package: Option<crate::package::PackageInterfaceHandle> = None;
- 'pkgs: for pkg in candidates.iter() {
+ for pkg in candidates.iter() {
let reqs = pkg.get_requires();
let mut skip = false;
'reqs: for (name, link) in &reqs {
diff --git a/crates/shirabe/src/phpstan/mod.rs b/crates/shirabe/src/phpstan/mod.rs
index 2893a48..5c48ac7 100644
--- a/crates/shirabe/src/phpstan/mod.rs
+++ b/crates/shirabe/src/phpstan/mod.rs
@@ -1,5 +1,2 @@
pub mod config_return_type_extension;
pub mod rule_reason_data_return_type_extension;
-
-pub use config_return_type_extension::*;
-pub use rule_reason_data_return_type_extension::*;
diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs
index 3d9c461..c1cd38e 100644
--- a/crates/shirabe/src/plugin/plugin_manager.rs
+++ b/crates/shirabe/src/plugin/plugin_manager.rs
@@ -9,35 +9,27 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
E_USER_DEPRECATED, PhpMixed, RuntimeException, UnexpectedValueException, array_key_exists,
- array_reverse, array_search, clone, get_class, get_class_obj, implode, in_array, is_a,
- is_array, is_string, ksort, preg_quote, str_replace, strrpos, strtr, substr, trigger_error,
- trim, var_export, var_export_str, version_compare,
+ get_class_obj, implode, ksort, trigger_error, trim, var_export_str, version_compare,
};
-use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use crate::composer::PartialComposerHandle;
use crate::composer::{ComposerHandle, ComposerWeakHandle};
-use crate::event_dispatcher::EventSubscriberInterface;
use crate::factory::DisablePlugins;
use crate::installer::InstallerInterface;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::package::CompletePackage;
-use crate::package::Link;
use crate::package::Locker;
use crate::package::PackageInterfaceHandle;
use crate::package::RootPackageInterfaceHandle;
-use crate::package::base_package::{self, BasePackage};
+use crate::package::base_package::{self};
use crate::package::version::VersionParser;
-use crate::plugin::Capable;
use crate::plugin::PluginBlockedException;
use crate::plugin::capability::Capability;
use crate::plugin::plugin_interface::{self, PluginInterface};
use crate::repository::InstalledRepository;
use crate::repository::RepositoryInterface;
use crate::repository::RepositoryUtils;
-use crate::repository::RootPackageRepository;
use crate::util::PackageSorter;
#[derive(Debug)]
@@ -413,30 +405,37 @@ impl PluginManager {
return Ok(());
}
- if source_package.is_none() {
- trigger_error(
- "Calling PluginManager::addPlugin without $sourcePackage is deprecated, if you are using this please get in touch with us to explain the use case",
- E_USER_DEPRECATED,
- );
- } else {
- let sp = source_package.as_ref().unwrap();
- let plugin_optional = sp
- .get_extra()
- .get("plugin-optional")
- .map(|v| v.as_bool() == Some(true))
- .unwrap_or(false);
- if !self.is_plugin_allowed(&sp.get_name(), is_global_plugin, plugin_optional, true)? {
- self.io.write_error(&format!(
- "Skipped loading \"{} from {}\" {} as it is not in config.allow-plugins",
- get_class_obj(&*plugin),
- sp.get_name(),
- if is_global_plugin || self.running_in_global_dir {
- "(installed globally) "
- } else {
- ""
- }
- ));
- return Ok(());
+ match &source_package {
+ None => {
+ trigger_error(
+ "Calling PluginManager::addPlugin without $sourcePackage is deprecated, if you are using this please get in touch with us to explain the use case",
+ E_USER_DEPRECATED,
+ );
+ }
+ Some(sp) => {
+ let plugin_optional = sp
+ .get_extra()
+ .get("plugin-optional")
+ .map(|v| v.as_bool() == Some(true))
+ .unwrap_or(false);
+ if !self.is_plugin_allowed(
+ &sp.get_name(),
+ is_global_plugin,
+ plugin_optional,
+ true,
+ )? {
+ self.io.write_error(&format!(
+ "Skipped loading \"{} from {}\" {} as it is not in config.allow-plugins",
+ get_class_obj(&*plugin),
+ sp.get_name(),
+ if is_global_plugin || self.running_in_global_dir {
+ "(installed globally) "
+ } else {
+ ""
+ }
+ ));
+ return Ok(());
+ }
}
}
diff --git a/crates/shirabe/src/question/strict_confirmation_question.rs b/crates/shirabe/src/question/strict_confirmation_question.rs
index a464d65..5141eb5 100644
--- a/crates/shirabe/src/question/strict_confirmation_question.rs
+++ b/crates/shirabe/src/question/strict_confirmation_question.rs
@@ -111,13 +111,13 @@ impl QuestionInterface for StrictConfirmationQuestion {
self.inner.get_autocompleter_values()
}
- fn get_autocompleter_callback(&self) -> Option<&(dyn Fn(&str) -> Option<Vec<PhpMixed>>)> {
+ fn get_autocompleter_callback(&self) -> Option<&dyn Fn(&str) -> Option<Vec<PhpMixed>>> {
self.inner.get_autocompleter_callback()
}
fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)> {
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>> {
self.inner.get_validator()
}
@@ -125,7 +125,7 @@ impl QuestionInterface for StrictConfirmationQuestion {
self.inner.get_max_attempts()
}
- fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)> {
+ fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed> {
self.inner.get_normalizer()
}
diff --git a/crates/shirabe/src/repository/advisory_provider_interface.rs b/crates/shirabe/src/repository/advisory_provider_interface.rs
index 9d0c5ac..f1e639a 100644
--- a/crates/shirabe/src/repository/advisory_provider_interface.rs
+++ b/crates/shirabe/src/repository/advisory_provider_interface.rs
@@ -1,6 +1,6 @@
//! ref: composer/src/Composer/Repository/AdvisoryProviderInterface.php
-use crate::advisory::{AnySecurityAdvisory, PartialSecurityAdvisory, SecurityAdvisory};
+use crate::advisory::AnySecurityAdvisory;
use indexmap::IndexMap;
use shirabe_semver::constraint::AnyConstraint;
diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs
index 7f99c1c..e1f8806 100644
--- a/crates/shirabe/src/repository/array_repository.rs
+++ b/crates/shirabe/src/repository/array_repository.rs
@@ -1,6 +1,5 @@
//! ref: composer/src/Composer/Repository/ArrayRepository.php
-use std::any::Any;
use std::cell::RefCell;
use std::rc::Weak;
diff --git a/crates/shirabe/src/repository/artifact_repository.rs b/crates/shirabe/src/repository/artifact_repository.rs
index 9a28d65..01612a4 100644
--- a/crates/shirabe/src/repository/artifact_repository.rs
+++ b/crates/shirabe/src/repository/artifact_repository.rs
@@ -11,7 +11,6 @@ use shirabe_php_shim::{
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
-use crate::package::BasePackage;
use crate::package::loader::ArrayLoader;
use crate::package::loader::LoaderInterface;
use crate::repository::ArrayRepository;
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index 3314ebd..4042a9b 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -24,9 +24,8 @@ use crate::io::IOInterfaceImmutable;
use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::package::BasePackageHandle;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
-use crate::package::base_package::{self, BasePackage};
+use crate::package::base_package;
use crate::package::loader::ArrayLoader;
use crate::package::version::StabilityFilter;
use crate::package::version::VersionParser;
@@ -789,7 +788,7 @@ impl ComposerRepository {
r"{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i",
&query,
Some(&mut match_groups),
- ) && self.list_url.is_some()
+ ) && let Some(list_url) = self.list_url.as_ref()
{
let q = match_groups
.get(&CaptureKey::ByName("query".to_string()))
@@ -801,7 +800,7 @@ impl ComposerRepository {
.unwrap_or_default();
let url = format!(
"{}?vendor={}&filter={}",
- self.list_url.as_ref().unwrap(),
+ list_url,
urlencode(&vendor),
urlencode(&format!("{}*", q)),
);
@@ -1025,11 +1024,8 @@ impl ComposerRepository {
http_map.insert("header".to_string(), PhpMixed::List(arr));
}
let mut headers = match http_map.get("header") {
- Some(b) => match b {
- PhpMixed::List(l) => l.clone(),
- _ => vec![],
- },
- None => vec![],
+ Some(PhpMixed::List(l)) => l.clone(),
+ _ => vec![],
};
headers.push(PhpMixed::String(
"Content-type: application/x-www-form-urlencoded".to_string(),
@@ -1229,14 +1225,10 @@ impl ComposerRepository {
return Ok(vec![]);
}
- if self.providers_url.is_some() && self.provider_listing.is_some() {
- return Ok(self
- .provider_listing
- .as_ref()
- .unwrap()
- .keys()
- .cloned()
- .collect());
+ if self.providers_url.is_some()
+ && let Some(provider_listing) = self.provider_listing.as_ref()
+ {
+ return Ok(provider_listing.keys().cloned().collect());
}
Ok(vec![])
@@ -1292,18 +1284,14 @@ impl ComposerRepository {
let hash_opt: Option<String>;
let url: String;
let cache_key: String;
- if self.lazy_providers_url.is_some()
+ if let Some(lazy_providers_url) = self.lazy_providers_url.as_ref()
&& !self
.provider_listing
.as_ref()
.is_some_and(|m| m.contains_key(name))
{
hash_opt = None;
- url = self
- .lazy_providers_url
- .as_ref()
- .unwrap()
- .replace("%package%", name);
+ url = lazy_providers_url.replace("%package%", name);
cache_key = format!("provider-{}.json", strtr(name, "/", "$"));
use_last_modified_check = true;
} else if let Some(providers_url) = self.providers_url.clone() {
@@ -1477,7 +1465,7 @@ impl ComposerRepository {
for versions_mixed in packages_inner.iter() {
// $versions can be either array<string, array> or list<array>
let iter_versions: Vec<PhpMixed> = match versions_mixed {
- PhpMixed::Array(a) => a.values().map(|v| v.clone()).collect(),
+ PhpMixed::Array(a) => a.values().cloned().collect(),
PhpMixed::List(l) => l.clone(),
_ => continue,
};
@@ -2946,11 +2934,8 @@ impl ComposerRepository {
http_map.insert("header".to_string(), PhpMixed::List(arr));
}
let mut headers = match http_map.get("header") {
- Some(b) => match b {
- PhpMixed::List(l) => l.clone(),
- _ => vec![],
- },
- None => vec![],
+ Some(PhpMixed::List(l)) => l.clone(),
+ _ => vec![],
};
headers.push(PhpMixed::String(format!(
"If-Modified-Since: {}",
@@ -3106,11 +3091,8 @@ impl ComposerRepository {
http_map.insert("header".to_string(), PhpMixed::List(arr));
}
let mut headers = match http_map.get("header") {
- Some(b) => match b {
- PhpMixed::List(l) => l.clone(),
- _ => vec![],
- },
- None => vec![],
+ Some(PhpMixed::List(l)) => l.clone(),
+ _ => vec![],
};
headers.push(PhpMixed::String(format!(
"If-Modified-Since: {}",
diff --git a/crates/shirabe/src/repository/composite_repository.rs b/crates/shirabe/src/repository/composite_repository.rs
index 27e6bf2..d1456b1 100644
--- a/crates/shirabe/src/repository/composite_repository.rs
+++ b/crates/shirabe/src/repository/composite_repository.rs
@@ -1,7 +1,5 @@
//! ref: composer/src/Composer/Repository/CompositeRepository.php
-use std::any::Any;
-
use indexmap::IndexMap;
use shirabe_semver::constraint::AnyConstraint;
diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs
index 670bfb4..30c01e8 100644
--- a/crates/shirabe/src/repository/filesystem_repository.rs
+++ b/crates/shirabe/src/repository/filesystem_repository.rs
@@ -7,10 +7,9 @@ use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
- Exception, InvalidArgumentException, LogicException, PhpMixed, SORT_NATURAL,
- UnexpectedValueException, array_flip, dirname, r#eval, file_get_contents, get_class,
- get_class_err, get_debug_type, in_array, is_array, is_null, is_string, ksort, realpath, sort,
- sort_with_flags, str_repeat, strtr, trim, usort, var_export,
+ Exception, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException,
+ array_flip, dirname, r#eval, file_get_contents, get_class_err, get_debug_type, in_array,
+ is_array, is_null, is_string, ksort, realpath, str_repeat, trim, usort, var_export,
};
use crate::config::is_php_integer_key;
@@ -160,7 +159,7 @@ impl FilesystemRepository {
}
};
- let mut loader = ArrayLoader::new(None, true);
+ let loader = ArrayLoader::new(None, true);
if let Some(packages_list) = packages.as_list() {
for package_data in packages_list.iter() {
let cfg = package_data.as_array().cloned().unwrap_or_default();
diff --git a/crates/shirabe/src/repository/handle.rs b/crates/shirabe/src/repository/handle.rs
index 90a9090..d0ad774 100644
--- a/crates/shirabe/src/repository/handle.rs
+++ b/crates/shirabe/src/repository/handle.rs
@@ -9,9 +9,8 @@ use shirabe_semver::constraint::AnyConstraint;
use crate::package::BasePackageHandle;
use crate::package::PackageInterfaceHandle;
use crate::repository::{
- FindPackageConstraint, InstalledRepositoryInterface, LoadPackagesResult, LockArrayRepository,
- PlatformRepository, ProviderInfo, RepositoryInterface, SearchResult,
- WritableRepositoryInterface,
+ FindPackageConstraint, LoadPackagesResult, LockArrayRepository, PlatformRepository,
+ ProviderInfo, RepositoryInterface, SearchResult,
};
/// Shared reference to a repository. Corresponds to PHP `RepositoryInterface`.
diff --git a/crates/shirabe/src/repository/installed_repository.rs b/crates/shirabe/src/repository/installed_repository.rs
index cfa5a7a..b17fb27 100644
--- a/crates/shirabe/src/repository/installed_repository.rs
+++ b/crates/shirabe/src/repository/installed_repository.rs
@@ -1,7 +1,6 @@
//! ref: composer/src/Composer/Repository/InstalledRepository.php
use indexmap::IndexMap;
-use shirabe_php_shim::LogicException;
use shirabe_php_shim::array_merge_map;
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::MatchAllConstraint;
@@ -12,7 +11,6 @@ use crate::package::Link;
use crate::package::PackageInterfaceHandle;
use crate::package::version::VersionParser;
use crate::repository::CompositeRepository;
-use crate::repository::InstalledRepositoryInterface;
use crate::repository::LockArrayRepository;
use crate::repository::PlatformRepository;
use crate::repository::RootPackageRepository;
@@ -118,7 +116,7 @@ impl InstalledRepository {
};
let mut results: Vec<DependentsEntry> = vec![];
- let mut packages_found = packages_found.unwrap_or_else(|| needles.clone());
+ let packages_found = packages_found.unwrap_or_else(|| needles.clone());
let mut root_package: Option<BasePackageHandle> = None;
for package in self.inner.get_packages()? {
diff --git a/crates/shirabe/src/repository/package_repository.rs b/crates/shirabe/src/repository/package_repository.rs
index fb340f5..fe10a57 100644
--- a/crates/shirabe/src/repository/package_repository.rs
+++ b/crates/shirabe/src/repository/package_repository.rs
@@ -1,6 +1,5 @@
//! ref: composer/src/Composer/Repository/PackageRepository.php
-use crate::advisory::SecurityAdvisory;
use crate::advisory::{AnySecurityAdvisory, PartialSecurityAdvisory};
use crate::package::BasePackageHandle;
use crate::package::PackageInterfaceHandle;
diff --git a/crates/shirabe/src/repository/path_repository.rs b/crates/shirabe/src/repository/path_repository.rs
index 2f99ceb..e5dff0e 100644
--- a/crates/shirabe/src/repository/path_repository.rs
+++ b/crates/shirabe/src/repository/path_repository.rs
@@ -276,7 +276,7 @@ impl PathRepository {
args
});
if reference == "auto"
- && shirabe_php_shim::is_dir(&format!("{}/.git", path.trim_end_matches('/')))
+ && shirabe_php_shim::is_dir(format!("{}/.git", path.trim_end_matches('/')))
&& self
.process
.borrow_mut()
diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs
index 26005e2..981ad8d 100644
--- a/crates/shirabe/src/repository/platform_repository.rs
+++ b/crates/shirabe/src/repository/platform_repository.rs
@@ -7,15 +7,13 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::composer::xdebug_handler::XdebugHandler;
use shirabe_php_shim::{
- InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn, array_slice,
- array_slice_strs, explode, get_class, implode, in_array, is_string, sprintf, str_replace,
+ InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn,
+ array_slice_strs, explode, get_class, implode, in_array, is_string, str_replace,
str_starts_with, strpos, strtolower, var_export,
};
-use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use crate::composer;
-use crate::composer::ComposerHandle;
use crate::package::CompletePackage;
use crate::package::CompletePackageHandle;
use crate::package::CompletePackageInterface;
@@ -27,7 +25,7 @@ use crate::package::version::VersionParser;
use crate::platform::HhvmDetector;
use crate::platform::Runtime;
use crate::platform::Version;
-use crate::plugin::plugin_interface::{self, PluginInterface};
+use crate::plugin::plugin_interface::{self};
use crate::repository::ArrayRepository;
use crate::repository::RepositoryInterface;
use crate::util::Silencer;
diff --git a/crates/shirabe/src/repository/repository_factory.rs b/crates/shirabe/src/repository/repository_factory.rs
index 9cc4e4d..db8185e 100644
--- a/crates/shirabe/src/repository/repository_factory.rs
+++ b/crates/shirabe/src/repository/repository_factory.rs
@@ -11,7 +11,6 @@ use crate::config::Config;
use crate::event_dispatcher::EventDispatcher;
use crate::factory::Factory;
use crate::io::IOInterface;
-use crate::io::IOInterfaceMutable;
use crate::json::JsonFile;
use crate::repository::FilesystemRepository;
use crate::repository::RepositoryInterfaceHandle;
@@ -84,7 +83,7 @@ impl RepositoryFactory {
if repository.starts_with('{') {
let parsed = JsonFile::parse_json(Some(repository), None)?;
let repo_config: IndexMap<String, PhpMixed> =
- parsed.as_array().map(|m| m.clone()).unwrap_or_default();
+ parsed.as_array().cloned().unwrap_or_default();
return Ok(repo_config);
}
diff --git a/crates/shirabe/src/repository/repository_set.rs b/crates/shirabe/src/repository/repository_set.rs
index 40e7f22..ba6373a 100644
--- a/crates/shirabe/src/repository/repository_set.rs
+++ b/crates/shirabe/src/repository/repository_set.rs
@@ -1,18 +1,14 @@
//! ref: composer/src/Composer/Repository/RepositorySet.php
-use std::any::Any;
-
use anyhow::Result;
use indexmap::IndexMap;
-use shirabe_php_shim::{
- LogicException, PhpMixed, RuntimeException, array_merge, ksort, strtolower,
-};
+use shirabe_php_shim::{LogicException, RuntimeException, ksort, strtolower};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::MatchAllConstraint;
use shirabe_semver::constraint::MultiConstraint;
use shirabe_semver::constraint::SimpleConstraint;
-use crate::advisory::{AnySecurityAdvisory, PartialSecurityAdvisory, SecurityAdvisory};
+use crate::advisory::AnySecurityAdvisory;
use crate::dependency_resolver::Pool;
use crate::dependency_resolver::PoolBuilder;
use crate::dependency_resolver::PoolOptimizer;
@@ -27,13 +23,11 @@ use crate::package::BasePackageHandle;
use crate::package::CompleteAliasPackageHandle;
use crate::package::PackageInterfaceHandle;
use crate::package::version::StabilityFilter;
-use crate::repository::AdvisoryProviderInterface;
use crate::repository::CompositeRepository;
use crate::repository::InstalledRepository;
-use crate::repository::InstalledRepositoryInterface;
use crate::repository::LockArrayRepositoryHandle;
use crate::repository::PlatformRepository;
-use crate::repository::{FindPackageConstraint, RepositoryInterface, RepositoryInterfaceHandle};
+use crate::repository::{FindPackageConstraint, RepositoryInterfaceHandle};
#[derive(Debug, Clone)]
pub struct RootAliasEntry {
diff --git a/crates/shirabe/src/repository/repository_utils.rs b/crates/shirabe/src/repository/repository_utils.rs
index 38c5016..40cb4d2 100644
--- a/crates/shirabe/src/repository/repository_utils.rs
+++ b/crates/shirabe/src/repository/repository_utils.rs
@@ -5,7 +5,6 @@ use crate::repository::CompositeRepository;
use crate::repository::FilterRepository;
use crate::repository::RepositoryInterfaceHandle;
use indexmap::IndexMap;
-use std::any::Any;
pub struct RepositoryUtils;
diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
index 18f1cf1..4d66f37 100644
--- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs
+++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs
@@ -5,7 +5,7 @@ use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- DATE_RFC3339, PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode,
+ PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode,
};
use crate::cache::Cache;
@@ -17,7 +17,6 @@ use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
use crate::repository::vcs::VcsDriverBase;
-use crate::repository::vcs::VcsDriverInterface;
use crate::util::Forgejo;
use crate::util::ForgejoRepositoryData;
use crate::util::ForgejoUrl;
@@ -341,7 +340,7 @@ impl ForgejoDriver {
let composer = if self.inner.should_cache(identifier) {
if let Some(res) = self.inner.cache.as_mut().and_then(|c| c.read(identifier)) {
let parsed = JsonFile::parse_json(Some(res.as_str()), None)?;
- parsed.as_array().map(|m| m.clone())
+ parsed.as_array().cloned()
} else {
let file_content = self.get_file_content("composer.json", identifier)?;
let c = VcsDriverBase::finish_base_composer_information(
diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs
index ebc0ac4..be3beff 100644
--- a/crates/shirabe/src/repository/vcs/fossil_driver.rs
+++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs
@@ -4,9 +4,7 @@ use crate::io::io_interface;
use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
-use shirabe_php_shim::{
- DATE_RFC3339, PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable,
-};
+use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable};
use crate::cache::Cache;
use crate::config::Config;
diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
index b5469ec..7a570bc 100644
--- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
+++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs
@@ -6,9 +6,9 @@ use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- DATE_RFC3339, InvalidArgumentException, LogicException, PhpMixed, RuntimeException,
- array_key_exists, array_search_mixed, extension_loaded, http_build_query_mixed, implode,
- in_array, is_array, sprintf, strpos,
+ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists,
+ array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array, is_array,
+ strpos,
};
use crate::cache::Cache;
@@ -257,9 +257,7 @@ impl GitBitbucketDriver {
if self.inner.should_cache(identifier) && {
let res = self.inner.cache.as_mut().and_then(|c| c.read(identifier));
if let Some(res) = res {
- composer = JsonFile::parse_json(Some(&res), None)?
- .as_array()
- .map(|m| m.clone());
+ composer = JsonFile::parse_json(Some(&res), None)?.as_array().cloned();
true
} else {
false
@@ -343,30 +341,35 @@ impl GitBitbucketDriver {
let support_entry = composer_map
.entry("support".to_string())
.or_insert(PhpMixed::Array(IndexMap::new()));
- if hash.is_none() {
- if let PhpMixed::Array(support_map) = support_entry {
- support_map.insert(
- "source".to_string(),
- PhpMixed::String(format!(
- "https://{}/{}/{}/src",
- self.inner.origin_url.clone(),
- self.owner.clone(),
- self.repository.clone(),
- )),
- );
+ match &hash {
+ None => {
+ if let PhpMixed::Array(support_map) = support_entry {
+ support_map.insert(
+ "source".to_string(),
+ PhpMixed::String(format!(
+ "https://{}/{}/{}/src",
+ self.inner.origin_url.clone(),
+ self.owner.clone(),
+ self.repository.clone(),
+ )),
+ );
+ }
+ }
+ Some(hash) => {
+ if let PhpMixed::Array(support_map) = support_entry {
+ support_map.insert(
+ "source".to_string(),
+ PhpMixed::String(format!(
+ "https://{}/{}/{}/src/{}/?at={}",
+ self.inner.origin_url.clone(),
+ self.owner.clone(),
+ self.repository.clone(),
+ hash,
+ label.clone(),
+ )),
+ );
+ }
}
- } else if let PhpMixed::Array(support_map) = support_entry {
- support_map.insert(
- "source".to_string(),
- PhpMixed::String(format!(
- "https://{}/{}/{}/src/{}/?at={}",
- self.inner.origin_url.clone(),
- self.owner.clone(),
- self.repository.clone(),
- hash.unwrap(),
- label.clone(),
- )),
- );
}
}
let support_has_issues = composer_map
@@ -432,7 +435,7 @@ impl GitBitbucketDriver {
self.owner.clone(),
self.repository.clone(),
identifier,
- file.to_string(),
+ file,
);
Ok(self
@@ -500,7 +503,7 @@ impl GitBitbucketDriver {
"https://bitbucket.org/{}/{}/get/{}.zip",
self.owner.clone(),
self.repository.clone(),
- identifier.to_string(),
+ identifier,
);
let mut m: IndexMap<String, String> = IndexMap::new();
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 7c50a7e..e45096d 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -6,10 +6,9 @@ use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- DATE_RFC3339, InvalidArgumentException, PhpMixed, RuntimeException, array_diff,
- array_key_exists, array_map, array_search_mixed, base64_decode, basename, count, empty,
- explode, extension_loaded, in_array, parse_url_all, sprintf, strpos, strtolower, substr, trim,
- urlencode,
+ InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_key_exists, array_map,
+ array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array,
+ parse_url_all, strpos, strtolower, substr, trim, urlencode,
};
use crate::cache::Cache;
@@ -21,7 +20,6 @@ use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
use crate::repository::vcs::VcsDriverBase;
-use crate::repository::vcs::VcsDriverInterface;
use crate::util::GitHub;
use crate::util::http::Response;
@@ -279,7 +277,7 @@ impl GitHubDriver {
.and_then(|c| c.read(identifier))
.unwrap_or_default();
let parsed = JsonFile::parse_json(Some(&res), None)?;
- parsed.as_array().map(|m| m.clone())
+ parsed.as_array().cloned()
} else {
let file_content = self.get_file_content("composer.json", identifier)?;
let composer = VcsDriverBase::finish_base_composer_information(
diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
index 7e8073d..a9a2fdb 100644
--- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs
+++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs
@@ -6,9 +6,9 @@ use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- DATE_RFC3339, InvalidArgumentException, LogicException, PhpMixed, RuntimeException,
- array_search_mixed, array_shift, ctype_alnum, empty, explode, extension_loaded, implode,
- in_array, is_array, is_string, ord, sprintf, strpos, strtolower,
+ InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed,
+ array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array, is_array,
+ is_string, ord, strpos, strtolower,
};
use crate::cache::Cache;
@@ -20,7 +20,6 @@ use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::GitDriver;
use crate::repository::vcs::VcsDriverBase;
-use crate::repository::vcs::VcsDriverInterface;
use crate::util::GitLab;
use crate::util::HttpDownloader;
use crate::util::http::Response;
@@ -284,9 +283,7 @@ impl GitLabDriver {
.as_mut()
.and_then(|c| c.read(identifier))
.unwrap_or_default();
- JsonFile::parse_json(Some(&res), None)?
- .as_array()
- .map(|m| m.clone())
+ JsonFile::parse_json(Some(&res), None)?.as_array().cloned()
} else {
let file_content = self.get_file_content("composer.json", identifier)?;
let composer = VcsDriverBase::finish_base_composer_information(
diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs
index 641e3e8..b668a2c 100644
--- a/crates/shirabe/src/repository/vcs/hg_driver.rs
+++ b/crates/shirabe/src/repository/vcs/hg_driver.rs
@@ -5,7 +5,6 @@ use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
-use crate::io::io_interface;
use crate::repository::vcs::VcsDriverBase;
use crate::util::Filesystem;
use crate::util::Hg as HgUtils;
@@ -13,7 +12,7 @@ use crate::util::Url;
use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{DATE_RFC3339, PhpMixed, RuntimeException, dirname, is_dir, is_writable};
+use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_writable};
#[derive(Debug)]
pub struct HgDriver {
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index dd2d26d..087ed9d 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -5,8 +5,7 @@ use chrono::{DateTime, FixedOffset, Utc};
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- PhpMixed, RuntimeException, array_key_exists, is_array, sprintf, stripos, strrpos, strtr,
- substr, trim,
+ PhpMixed, RuntimeException, array_key_exists, stripos, strrpos, strtr, substr, trim,
};
use crate::cache::Cache;
@@ -187,8 +186,7 @@ impl SvnDriver {
}
let parsed = JsonFile::parse_json(Some(res.as_str()), None)?;
- let composer: Option<IndexMap<String, PhpMixed>> =
- parsed.as_array().map(|m| m.clone());
+ let composer: Option<IndexMap<String, PhpMixed>> = parsed.as_array().cloned();
self.inner
.info_cache
.insert(identifier.to_string(), composer.clone());
@@ -380,10 +378,10 @@ impl SvnDriver {
if self.branches.is_none() {
let mut branches: IndexMap<String, String> = IndexMap::new();
- let trunk_parent = if self.trunk_path.is_none() {
- format!("{}/", self.base_url)
+ let trunk_parent = if let Some(trunk_path) = self.trunk_path.as_ref() {
+ format!("{}/{}", self.base_url, trunk_path)
} else {
- format!("{}/{}", self.base_url, self.trunk_path.as_ref().unwrap())
+ format!("{}/", self.base_url)
};
let output = self.execute(
diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs
index 249e53f..5e0715c 100644
--- a/crates/shirabe/src/repository/vcs/vcs_driver.rs
+++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs
@@ -12,7 +12,6 @@ use crate::io::IOInterface;
use crate::json::JsonEncodeOptions;
use crate::json::JsonFile;
use crate::repository::vcs::VcsDriverInterface;
-use crate::util::Filesystem;
use crate::util::HttpDownloader;
use crate::util::ProcessExecutor;
use crate::util::http::Response;
@@ -150,7 +149,7 @@ impl VcsDriverBase {
&& let Some(res) = self.cache.as_mut().and_then(|c| c.read(identifier))
{
let parsed = JsonFile::parse_json(Some(&res), None)?;
- let composer: Option<IndexMap<String, PhpMixed>> = parsed.as_array().map(|m| m.clone());
+ let composer: Option<IndexMap<String, PhpMixed>> = parsed.as_array().cloned();
self.info_cache
.insert(identifier.to_string(), composer.clone());
return Ok(Some(composer));
diff --git a/crates/shirabe/src/repository/vcs_repository.rs b/crates/shirabe/src/repository/vcs_repository.rs
index 7a143eb..c4e89bc 100644
--- a/crates/shirabe/src/repository/vcs_repository.rs
+++ b/crates/shirabe/src/repository/vcs_repository.rs
@@ -5,7 +5,6 @@ use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{InvalidArgumentException, PhpMixed, in_array, str_replace, strpos};
-use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use crate::config::Config;
diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs
index f386b1e..584ce69 100644
--- a/crates/shirabe/src/util/auth_helper.rs
+++ b/crates/shirabe/src/util/auth_helper.rs
@@ -6,8 +6,8 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
PHP_URL_HOST, PHP_URL_PATH, PHP_URL_SCHEME, PhpMixed, RuntimeException, base64_encode, explode,
- in_array, is_array, is_string, json_decode, parse_url, sprintf, str_replace, strpos,
- strtolower, substr, trim,
+ in_array, is_array, is_string, json_decode, parse_url, str_replace, strpos, strtolower, substr,
+ trim,
};
use crate::config::Config;
@@ -475,7 +475,7 @@ impl AuthHelper {
.and_then(|h| h.get("header"))
.and_then(|v| v.as_list())
{
- Some(list) => list.iter().cloned().collect(),
+ Some(list) => list.to_vec(),
None => vec![],
};
@@ -496,7 +496,9 @@ impl AuthHelper {
username,
)));
} else if password == "custom-headers" {
+ // TODO:
// Handle custom HTTP headers from auth.json
+ #[allow(unused_assignments)]
let mut custom_headers: PhpMixed = PhpMixed::Null;
// PHP: if (is_string($auth['username']))
// username field is always String in our IndexMap representation
diff --git a/crates/shirabe/src/util/bitbucket.rs b/crates/shirabe/src/util/bitbucket.rs
index 9c8d59b..8a1127a 100644
--- a/crates/shirabe/src/util/bitbucket.rs
+++ b/crates/shirabe/src/util/bitbucket.rs
@@ -451,7 +451,7 @@ impl Bitbucket {
return false;
}
- let access_token = match origin_config.get("access-token").map(|v| v.clone()) {
+ let access_token = match origin_config.get("access-token").cloned() {
Some(t) => t,
None => return false,
};
diff --git a/crates/shirabe/src/util/error_handler.rs b/crates/shirabe/src/util/error_handler.rs
index d883556..45ad28a 100644
--- a/crates/shirabe/src/util/error_handler.rs
+++ b/crates/shirabe/src/util/error_handler.rs
@@ -4,7 +4,7 @@ use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
use shirabe_php_shim::{
E_ALL, E_DEPRECATED, E_USER_DEPRECATED, E_USER_WARNING, E_WARNING, ErrorException, PHP_EOL,
- PhpMixed, STDERR, debug_backtrace, error_reporting, filter_var_boolean, fwrite, ini_get,
+ STDERR, debug_backtrace, error_reporting, filter_var_boolean, fwrite, ini_get,
set_error_handler,
};
use std::cell::{Cell, RefCell};
diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs
index ec1e65a..6dd2ab9 100644
--- a/crates/shirabe/src/util/filesystem.rs
+++ b/crates/shirabe/src/util/filesystem.rs
@@ -4,14 +4,13 @@ use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::filesystem::exception::IOException;
use shirabe_external_packages::symfony::finder::Finder;
use shirabe_php_shim::{
- DIRECTORY_SEPARATOR, ErrorException, InvalidArgumentException, LogicException, PhpMixed,
- RuntimeException, UnexpectedValueException, array_pop, basename, chdir, clearstatcache,
- clearstatcache2, copy, count, dirname, error_get_last, explode, fclose, feof, file_exists,
- file_get_contents, file_put_contents, fileatime, filemtime, filesize, fopen, fread,
- function_exists, fwrite, implode, is_array, is_dir, is_file, is_link, is_readable, lstat,
- mkdir, react_promise_resolve, rename, rmdir, rtrim, sprintf, str_contains, str_repeat,
- str_replace, str_starts_with, strlen, strpos, strtolower, strtoupper, strtr, substr,
- substr_count, symlink, touch, unlink, usleep, var_export,
+ DIRECTORY_SEPARATOR, ErrorException, LogicException, PhpMixed, RuntimeException, array_pop,
+ basename, chdir, clearstatcache, clearstatcache2, copy, dirname, error_get_last, explode,
+ fclose, feof, file_exists, file_get_contents, file_put_contents, fileatime, filemtime,
+ filesize, fopen, fread, function_exists, fwrite, implode, is_dir, is_file, is_link,
+ is_readable, lstat, mkdir, rename, rmdir, rtrim, str_contains, str_repeat, str_replace,
+ str_starts_with, strlen, strpos, strtoupper, strtr, substr, substr_count, symlink, touch,
+ unlink, usleep, var_export,
};
use std::path::Path;
@@ -246,9 +245,9 @@ impl Filesystem {
for file in &ri {
if file.is_dir() {
- self.rmdir(&file.get_pathname())?;
+ self.rmdir(file.get_pathname())?;
} else {
- self.unlink(&file.get_pathname())?;
+ self.unlink(file.get_pathname())?;
}
}
diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs
index 4ea15b7..f30f9f7 100644
--- a/crates/shirabe/src/util/git.rs
+++ b/crates/shirabe/src/util/git.rs
@@ -7,10 +7,9 @@ use std::sync::Mutex;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map,
- array_merge_recursive, clearstatcache, count, explode, implode, in_array, is_array,
- is_callable, is_dir, preg_quote, rawurldecode, rawurlencode, str_contains, str_ends_with,
- str_replace, str_replace_array, strlen, strpos, substr, trim, version_compare,
+ InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map, clearstatcache,
+ explode, implode, in_array, is_callable, is_dir, preg_quote, rawurldecode, rawurlencode,
+ str_contains, str_ends_with, str_replace_array, strlen, strpos, substr, trim, version_compare,
};
use crate::config::Config;
@@ -175,10 +174,10 @@ impl Git {
let cwd_string = cwd.map(|s| s.to_string());
// PHP closure: $runCommands = function ($url) use (...) { ... };
- let mut run_commands_inline = |url_arg: &str,
- this_process: &mut ProcessExecutor,
- last_cmd: &mut PhpMixed,
- command_output: Option<&mut PhpMixed>|
+ let run_commands_inline = |url_arg: &str,
+ this_process: &mut ProcessExecutor,
+ last_cmd: &mut PhpMixed,
+ command_output: Option<&mut PhpMixed>|
-> i64 {
let collect_outputs = !command_output
.as_ref()
@@ -656,7 +655,7 @@ impl Git {
}
} else if let Some(m) = self.get_authentication_failure(url) {
// private non-github/gitlab/bitbucket repo that failed to authenticate
- let mut m1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
+ let m1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
let mut m2 = m.get(&CaptureKey::ByIndex(2)).cloned().unwrap_or_default();
let m3 = m.get(&CaptureKey::ByIndex(3)).cloned().unwrap_or_default();
let mut auth_parts: Option<String> = None;
@@ -746,7 +745,7 @@ impl Git {
username,
Some(password),
);
- let mut auth_helper = AuthHelper::new(self.io.clone(), self.config.clone());
+ let auth_helper = AuthHelper::new(self.io.clone(), self.config.clone());
let store_auth_enum = match &store_auth {
PhpMixed::String(s) if s == "prompt" => StoreAuth::Prompt,
PhpMixed::Bool(b) => StoreAuth::Bool(*b),
@@ -776,7 +775,6 @@ impl Git {
}
_ => last_command.as_string().unwrap_or("").to_string(),
};
- let mut error_msg = self.process.borrow().get_error_output().to_string();
if (credentials.len() as i64) > 0 {
last_command_str = self.mask_credentials(&last_command_str, &credentials);
error_msg = self.mask_credentials(&error_msg, &credentials);
@@ -923,9 +921,10 @@ impl Git {
pretty_version: Option<&str>,
) -> Result<bool> {
if self.check_ref_is_in_mirror(dir, r#ref)? {
- if Preg::is_match(r"{^[a-f0-9]{40}$}", r#ref) && pretty_version.is_some() {
- let branch =
- Preg::replace(r"{(?:^dev-|(?:\.x)?-dev$)}i", "", pretty_version.unwrap());
+ if Preg::is_match(r"{^[a-f0-9]{40}$}", r#ref)
+ && let Some(pretty_version) = pretty_version
+ {
+ let branch = Preg::replace(r"{(?:^dev-|(?:\.x)?-dev$)}i", "", pretty_version);
let mut branches: Option<String> = None;
let mut tags: Option<String> = None;
let mut output = String::new();
diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs
index ab5efea..dae4954 100644
--- a/crates/shirabe/src/util/github.rs
+++ b/crates/shirabe/src/util/github.rs
@@ -6,7 +6,6 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{PhpMixed, date, stripos, strtolower};
use crate::config::Config;
-use crate::downloader::TransportException;
use crate::factory::Factory;
use crate::io::IOInterface;
use crate::io::IOInterfaceImmutable;
diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs
index b49adf7..66ca326 100644
--- a/crates/shirabe/src/util/http/curl_downloader.rs
+++ b/crates/shirabe/src/util/http/curl_downloader.rs
@@ -406,12 +406,11 @@ impl CurlDownloader {
if curl_response.inner.get_status_code() >= 300
&& curl_response.inner.get_header("content-type").as_deref()
== Some("application/json")
+ && let Some(body) = curl_response.inner.get_body()
{
- if let Some(body) = curl_response.inner.get_body() {
- let decoded = shirabe_php_shim::json_decode(body, true)?;
- if let PhpMixed::Array(a) = decoded {
- HttpDownloader::output_warnings(self.io.clone(), &origin, &a)?;
- }
+ let decoded = shirabe_php_shim::json_decode(body, true)?;
+ if let PhpMixed::Array(a) = decoded {
+ HttpDownloader::output_warnings(self.io.clone(), &origin, &a)?;
}
}
@@ -527,7 +526,7 @@ impl CurlDownloader {
// Atomic rename of the `~` temp file to its final name (file mode).
if let Some(filename) = &filename {
- rename(&format!("{}~", filename), filename);
+ rename(format!("{}~", filename), filename);
}
self.resolve_job(id, curl_response.inner);
diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs
index 9057899..a6b62d7 100644
--- a/crates/shirabe/src/util/http_downloader.rs
+++ b/crates/shirabe/src/util/http_downloader.rs
@@ -10,11 +10,9 @@ use shirabe_php_shim::{
extension_loaded, file_get_contents, function_exists, implode, is_numeric, rawurldecode,
stream_context_create, stripos, strpos, substr, ucfirst,
};
-use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use crate::composer;
-use crate::composer::ComposerHandle;
use crate::config::Config;
use crate::downloader::TransportException;
use crate::io::IOInterface;
diff --git a/crates/shirabe/src/util/package_sorter.rs b/crates/shirabe/src/util/package_sorter.rs
index 8361dcc..6e0af01 100644
--- a/crates/shirabe/src/util/package_sorter.rs
+++ b/crates/shirabe/src/util/package_sorter.rs
@@ -4,7 +4,6 @@ use indexmap::IndexMap;
use shirabe_php_shim::{strnatcasecmp, version_compare};
use crate::package::Link;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
pub struct PackageSorter;
diff --git a/crates/shirabe/src/util/perforce.rs b/crates/shirabe/src/util/perforce.rs
index 11d8cc5..4d4ddef 100644
--- a/crates/shirabe/src/util/perforce.rs
+++ b/crates/shirabe/src/util/perforce.rs
@@ -6,7 +6,7 @@ use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::process::ExecutableFinder;
use shirabe_external_packages::symfony::process::Process;
use shirabe_php_shim::{
- Exception, PHP_EOL, PhpMixed, PhpResource, chdir, count, date, explode, fclose, feof, fgets,
+ Exception, PHP_EOL, PhpMixed, PhpResource, chdir, date, explode, fclose, feof, fgets,
file_get_contents, fopen, fwrite, gethostname, json_decode, str_replace_array, strcmp, strlen,
strpos, strrpos, substr, time, trim,
};
@@ -390,7 +390,7 @@ impl Perforce {
p4_create_client_command,
None,
None,
- file_get_contents(&self.get_p4_client_spec())
+ file_get_contents(self.get_p4_client_spec())
.map(PhpMixed::String)
.unwrap_or(PhpMixed::Null),
None,
diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs
index fb486e3..98c3186 100644
--- a/crates/shirabe/src/util/process_executor.rs
+++ b/crates/shirabe/src/util/process_executor.rs
@@ -12,10 +12,9 @@ use shirabe_external_packages::symfony::process::Process;
use shirabe_external_packages::symfony::process::exception::ProcessSignaledException;
use shirabe_external_packages::symfony::process::exception::RuntimeException as SymfonyProcessRuntimeException;
use shirabe_php_shim::{
- LogicException, PHP_EOL, PhpMixed, RuntimeException, array_intersect, array_map,
- call_user_func, defined, escapeshellarg, explode, implode, in_array, is_array, is_dir,
- is_numeric, is_string, rtrim, sprintf, str_replace, strcspn, strlen, strpbrk, strtolower,
- strtr_array, substr_replace, trim, usleep,
+ LogicException, PHP_EOL, PhpMixed, array_intersect, array_map, call_user_func, escapeshellarg,
+ explode, implode, in_array, is_array, is_dir, is_numeric, is_string, rtrim, sprintf,
+ str_replace, strcspn, strlen, strpbrk, strtolower, strtr_array, substr_replace, trim, usleep,
};
use crate::io::IOInterface;
@@ -102,23 +101,13 @@ impl MockExpectation {
/// The `{return, stdout, stderr}` default-handler triple used for unmatched commands in non-strict
/// mode (`$defaultHandler` in PHP).
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Default)]
pub struct MockHandler {
pub r#return: i64,
pub stdout: String,
pub stderr: String,
}
-impl Default for MockHandler {
- fn default() -> Self {
- Self {
- r#return: 0,
- stdout: String::new(),
- stderr: String::new(),
- }
- }
-}
-
struct Job {
id: i64,
status: i64,
@@ -232,7 +221,7 @@ impl ProcessExecutor {
cwd: Option<&str>,
env: Option<IndexMap<String, String>>,
tty: bool,
- mut output: O,
+ output: O,
) -> Result<Option<i64>>
where
O: IntoExecOutput<'o>,
@@ -323,7 +312,7 @@ impl ProcessExecutor {
Err(mut output) => {
let capture_output = self.capture_output;
let mut io = self.io.clone();
- let mut callback = move |r#type: &str, buffer: &str| {
+ let callback = move |r#type: &str, buffer: &str| {
Self::output_handler(capture_output, &mut io, r#type, buffer);
false
};
@@ -381,19 +370,21 @@ impl ProcessExecutor {
let mut env: Option<IndexMap<String, String>> = None;
let requires_git_dir_env = self.requires_git_dir_env(&command);
- if cwd.is_some() && requires_git_dir_env {
- let is_bare_repository = !is_dir(&format!("{}/.git", rtrim(cwd.unwrap(), Some("/"))));
+ if let Some(cwd) = cwd
+ && requires_git_dir_env
+ {
+ let is_bare_repository = !is_dir(format!("{}/.git", rtrim(cwd, Some("/"))));
if is_bare_repository {
let mut config_value = PhpMixed::String(String::new());
let mut git_env: IndexMap<String, String> = IndexMap::new();
- git_env.insert("GIT_DIR".to_string(), cwd.unwrap().to_string());
+ git_env.insert("GIT_DIR".to_string(), cwd.to_string());
self.run_process(
PhpMixed::List(vec![
PhpMixed::String("git".to_string()),
PhpMixed::String("config".to_string()),
PhpMixed::String("safe.bareRepository".to_string()),
]),
- cwd,
+ Some(cwd),
Some(git_env.clone()),
tty,
&mut config_value,
@@ -419,7 +410,7 @@ impl ProcessExecutor {
&mut self,
command: PhpMixed,
cwd: Option<&str>,
- mut output: O,
+ output: O,
) -> Result<i64>
where
O: IntoExecOutput<'o>,
@@ -688,7 +679,7 @@ impl ProcessExecutor {
self.output_command_run(&command, cwd.as_deref(), true);
- let process_result: Result<Process> = (if is_string(&command) {
+ let process_result: Result<Process> = if is_string(&command) {
Process::from_shell_commandline(
command.as_string().unwrap_or(""),
cwd.as_deref(),
@@ -712,7 +703,7 @@ impl ProcessExecutor {
code: 0,
}
.into())
- });
+ };
let process = match process_result {
Ok(p) => p,
Err(e) => {
@@ -908,7 +899,7 @@ impl ProcessExecutor {
} else if let PhpMixed::List(list) = command {
let parts: Vec<String> = array_map(
|v| Self::escape(v.as_string().unwrap_or("")),
- &list.iter().cloned().collect::<Vec<_>>(),
+ &list.to_vec(),
);
implode(" ", &parts)
} else {
diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs
index 5bd9036..ca818fc 100644
--- a/crates/shirabe/src/util/remote_filesystem.rs
+++ b/crates/shirabe/src/util/remote_filesystem.rs
@@ -8,7 +8,7 @@ use shirabe_php_shim::{
STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS,
array_replace_recursive, base64_encode, explode, extension_loaded, file_put_contents,
filter_var_boolean, gethostbyname, http_clear_last_response_headers,
- http_get_last_response_headers, ini_get, json_decode, parse_url, preg_quote, sprintf, strpos,
+ http_get_last_response_headers, ini_get, json_decode, parse_url, preg_quote, strpos,
strtolower, strtr, substr, trim, zlib_decode,
};
diff --git a/crates/shirabe/src/util/stream_context_factory.rs b/crates/shirabe/src/util/stream_context_factory.rs
index db48122..1747cd6 100644
--- a/crates/shirabe/src/util/stream_context_factory.rs
+++ b/crates/shirabe/src/util/stream_context_factory.rs
@@ -4,12 +4,11 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::ca_bundle::CaBundle;
use shirabe_php_shim::{
HHVM_VERSION, PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PhpMixed,
- RuntimeException, array_replace_recursive, curl_version, extension_loaded, function_exists,
- php_uname, stream_context_create, stripos, uasort,
+ array_replace_recursive, curl_version, extension_loaded, function_exists, php_uname,
+ stream_context_create, stripos, uasort,
};
use crate::composer;
-use crate::composer::ComposerHandle;
use crate::downloader::TransportException;
use crate::repository::PlatformRepository;
use crate::util::Filesystem;
diff --git a/crates/shirabe/src/util/svn.rs b/crates/shirabe/src/util/svn.rs
index 5375447..096d8c3 100644
--- a/crates/shirabe/src/util/svn.rs
+++ b/crates/shirabe/src/util/svn.rs
@@ -381,7 +381,7 @@ impl Svn {
let auth_for_host = auth_config
.as_array()
.and_then(|m| m.get(host_str))
- .map(|v| v.clone());
+ .cloned();
if let Some(entry) = auth_for_host
&& let Some(entry_arr) = entry.as_array()
{
@@ -416,19 +416,13 @@ impl Svn {
return false;
}
};
- let user_val = uri_arr
- .get("user")
- .map(|v| v.clone())
- .unwrap_or(PhpMixed::Null);
+ let user_val = uri_arr.get("user").cloned().unwrap_or(PhpMixed::Null);
if empty(&user_val) {
self.has_auth = Some(false);
return false;
}
- let pass_val = uri_arr
- .get("pass")
- .map(|v| v.clone())
- .unwrap_or(PhpMixed::Null);
+ let pass_val = uri_arr.get("pass").cloned().unwrap_or(PhpMixed::Null);
self.credentials = Some(SvnCredentials {
username: user_val.as_string().unwrap_or("").to_string(),
password: if !empty(&pass_val) {