aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-27 03:52:05 +0900
committernsfisis <nsfisis@gmail.com>2026-06-27 04:21:34 +0900
commit2b51554ff59d1e5cbf8dd2db65d278b0202a9102 (patch)
treef4d9b0abf4df9b5e363e3bd65511d70e3d5ada00 /crates
parentcc07b5abb83a40d678401c335bdc49bb81b72c5f (diff)
downloadphp-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.tar.gz
php-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.tar.zst
php-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.zip
refactor: fix compiler warnings and clippy warnings
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe-class-map-generator/src/class_map_generator.rs13
-rw-r--r--crates/shirabe-class-map-generator/src/php_file_parser.rs2
-rw-r--r--crates/shirabe-external-packages/src/composer/ca_bundle/ca_bundle.rs16
-rw-r--r--crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs82
-rw-r--r--crates/shirabe-external-packages/src/seld/json_lint/lexer.rs2
-rw-r--r--crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs4
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/command.rs11
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs3
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs1
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs11
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs10
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs29
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs15
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs4
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs2
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs39
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs4
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/table.rs10
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs20
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/array_input.rs23
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/input.rs8
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs32
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs3
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/question/question.rs26
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs8
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/process/process.rs71
-rw-r--r--crates/shirabe-external-packages/src/symfony/string/code_point_string.rs2
-rw-r--r--crates/shirabe-php-shim/src/array.rs55
-rw-r--r--crates/shirabe-php-shim/src/env.rs10
-rw-r--r--crates/shirabe-php-shim/src/fs.rs43
-rw-r--r--crates/shirabe-php-shim/src/hash.rs1
-rw-r--r--crates/shirabe-php-shim/src/json.rs1
-rw-r--r--crates/shirabe-php-shim/src/lib.rs6
-rw-r--r--crates/shirabe-php-shim/src/phar.rs3
-rw-r--r--crates/shirabe-php-shim/src/preg.rs2
-rw-r--r--crates/shirabe-php-shim/src/process.rs15
-rw-r--r--crates/shirabe-php-shim/src/rar.rs3
-rw-r--r--crates/shirabe-php-shim/src/stream.rs12
-rw-r--r--crates/shirabe-php-shim/src/string.rs20
-rw-r--r--crates/shirabe-php-shim/src/xml.rs4
-rw-r--r--crates/shirabe-php-shim/src/zip.rs16
-rw-r--r--crates/shirabe-semver/src/semver.rs1
-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
-rw-r--r--crates/shirabe/tests/autoload/autoload_generator_test.rs4
-rw-r--r--crates/shirabe/tests/command/base_dependency_command_test.rs12
-rw-r--r--crates/shirabe/tests/command/global_command_test.rs2
-rw-r--r--crates/shirabe/tests/command/init_command_test.rs2
-rw-r--r--crates/shirabe/tests/command/licenses_command_test.rs2
-rw-r--r--crates/shirabe/tests/command/remove_command_test.rs10
-rw-r--r--crates/shirabe/tests/command/show_command_test.rs2
-rw-r--r--crates/shirabe/tests/command/suggests_command_test.rs28
-rw-r--r--crates/shirabe/tests/dependency_resolver/pool_builder_test.rs45
-rw-r--r--crates/shirabe/tests/dependency_resolver/pool_test.rs2
-rw-r--r--crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs2
-rw-r--r--crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs2
-rw-r--r--crates/shirabe/tests/installer/binary_installer_test.rs2
-rw-r--r--crates/shirabe/tests/installer/library_installer_test.rs2
-rw-r--r--crates/shirabe/tests/io/console_io_test.rs2
-rw-r--r--crates/shirabe/tests/package/loader/validating_array_loader_test.rs4
-rw-r--r--crates/shirabe/tests/repository/array_repository_test.rs6
-rw-r--r--crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs2
-rw-r--r--crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs4
-rw-r--r--crates/shirabe/tests/repository/vcs_repository_test.rs5
-rw-r--r--crates/shirabe/tests/util/auth_helper_test.rs6
-rw-r--r--crates/shirabe/tests/util/filesystem_test.rs4
-rw-r--r--crates/shirabe/tests/util/gitlab_test.rs2
-rw-r--r--crates/shirabe/tests/util/perforce_test.rs2
-rw-r--r--crates/shirabe/tests/util/stream_context_factory_test.rs22
197 files changed, 1006 insertions, 1437 deletions
diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs
index f591811..cb49487 100644
--- a/crates/shirabe-class-map-generator/src/class_map_generator.rs
+++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs
@@ -9,8 +9,8 @@ use shirabe_external_packages::symfony::finder::Finder;
use shirabe_php_shim::{
DIRECTORY_SEPARATOR, InvalidArgumentException, LogicException, PATHINFO_EXTENSION, PHP_INT_MAX,
PhpMixed, RuntimeException, explode, getcwd, implode, in_array, is_dir, is_file, is_string,
- pathinfo, preg_quote, realpath, sprintf, str_replace, str_starts_with, stream_get_wrappers,
- strlen, strpos, strrpos, strtr, substr,
+ pathinfo, preg_quote, realpath, str_replace, str_starts_with, stream_get_wrappers, strlen,
+ strpos, strrpos, strtr, substr,
};
use std::path::PathBuf;
@@ -89,8 +89,7 @@ impl ClassMapGenerator {
}));
}
- let base_path: Option<String>;
- if autoload_type != "classmap" {
+ let base_path: Option<String> = if autoload_type != "classmap" {
if !is_string(&path) {
return Err(anyhow::anyhow!(InvalidArgumentException {
message:
@@ -105,10 +104,10 @@ impl ClassMapGenerator {
code: 0,
}));
}
- base_path = path.as_string().map(|s| s.to_string());
+ path.as_string().map(|s| s.to_string())
} else {
- base_path = None;
- }
+ None
+ };
let files: Vec<PathBuf> = if is_string(&path) {
let path_str = path.as_string().unwrap_or("");
diff --git a/crates/shirabe-class-map-generator/src/php_file_parser.rs b/crates/shirabe-class-map-generator/src/php_file_parser.rs
index 7d7c722..8d64dbd 100644
--- a/crates/shirabe-class-map-generator/src/php_file_parser.rs
+++ b/crates/shirabe-class-map-generator/src/php_file_parser.rs
@@ -6,7 +6,7 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
HHVM_VERSION, PHP_EOL, PHP_VERSION_ID, RuntimeException, error_get_last, file_exists,
- file_get_contents, function_exists, is_file, is_readable, ltrim, php_strip_whitespace, sprintf,
+ file_get_contents, function_exists, is_file, is_readable, ltrim, php_strip_whitespace,
str_replace_array, strrpos, substr, trim, version_compare,
};
use std::sync::OnceLock;
diff --git a/crates/shirabe-external-packages/src/composer/ca_bundle/ca_bundle.rs b/crates/shirabe-external-packages/src/composer/ca_bundle/ca_bundle.rs
index 187950a..3c372cb 100644
--- a/crates/shirabe-external-packages/src/composer/ca_bundle/ca_bundle.rs
+++ b/crates/shirabe-external-packages/src/composer/ca_bundle/ca_bundle.rs
@@ -23,10 +23,10 @@ impl CaBundle {
// not consult OpenSSL's default cert locations, does not validate the
// candidate before returning it, and has no bundled cacert.pem fallback.
pub fn get_system_ca_root_bundle_path(_logger: ()) -> String {
- if let Ok(file) = std::env::var("SSL_CERT_FILE") {
- if std::path::Path::new(&file).is_file() {
- return file;
- }
+ if let Ok(file) = std::env::var("SSL_CERT_FILE")
+ && std::path::Path::new(&file).is_file()
+ {
+ return file;
}
const CA_FILE_PATHS: &[&str] = &[
@@ -49,10 +49,10 @@ impl CaBundle {
}
}
- if let Ok(dir) = std::env::var("SSL_CERT_DIR") {
- if std::path::Path::new(&dir).is_dir() {
- return dir;
- }
+ if let Ok(dir) = std::env::var("SSL_CERT_DIR")
+ && std::path::Path::new(&dir).is_dir()
+ {
+ return dir;
}
const CA_DIR_PATHS: &[&str] = &["/etc/pki/tls/certs", "/etc/ssl/certs"];
diff --git a/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs b/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs
index 6607938..7cdf73b 100644
--- a/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs
+++ b/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs
@@ -182,7 +182,7 @@ impl JsonParser {
let mut symbol: Option<i64> = None;
let mut pre_error_symbol: Option<i64> = None;
- let mut err_str: Option<String> = None;
+ let err_str: Option<String> = None;
loop {
let mut state = state_.stack[state_.stack.len() - 1];
@@ -241,28 +241,26 @@ impl JsonParser {
message = Some(msg);
}
- let mut errstr = format!("Parse error on line {}:\n", yylineno + 1);
- errstr.push_str(&lexer.show_position());
- errstr.push('\n');
+ let mut err_str = format!("Parse error on line {}:\n", yylineno + 1);
+ err_str.push_str(&lexer.show_position());
+ err_str.push('\n');
if let Some(msg) = &message {
- errstr.push_str(msg);
+ err_str.push_str(msg);
} else {
- errstr.push_str(if expected.len() > 1 {
+ err_str.push_str(if expected.len() > 1 {
"Expected one of: "
} else {
"Expected: "
});
- errstr.push_str(&expected.join(", "));
+ err_str.push_str(&expected.join(", "));
}
let past = lexer.get_past_input();
let trimmed = trim_bytes(&past);
if trimmed.last() == Some(&b',') {
- errstr.push_str(" - It appears you have an extra trailing comma");
+ err_str.push_str(" - It appears you have an extra trailing comma");
}
- err_str = Some(errstr.clone());
-
let token = if let Some(name) = self.terminals_.get(&sym) {
super::parsing_exception::ParsingExceptionToken::Name(name.to_string())
} else {
@@ -275,7 +273,7 @@ impl JsonParser {
loc: Some(yyloc_to_loc(&yyloc)),
expected: Some(expected.clone()),
};
- return Err(ParsingException::new(errstr, details).into());
+ return Err(ParsingException::new(err_str, details).into());
}
// recovery path (recovering != 0). Not reachable for this grammar because the error
@@ -396,7 +394,7 @@ impl JsonParser {
fn fail_on_bom(&self, input: &str) -> Result<(), ParsingException> {
let bom = [0xEF, 0xBB, 0xBF];
- if input.as_bytes().len() >= 3 && input.as_bytes()[0..3] == bom {
+ if input.len() >= 3 && input.as_bytes()[0..3] == bom {
return Err(ParsingException::new(
"BOM detected, make sure your input does not include a Unicode Byte-Order-Mark"
.to_string(),
@@ -500,9 +498,9 @@ impl ParseState {
// PHP inserts $this->lexer->showPosition() here; the lexer is owned by parse()
// and not reachable from this method, so the position line is omitted. Only the
// "Duplicate key" body is read by ConfigValidator (DETECT_KEY_CONFLICTS).
- let mut errstr = format!("Parse error on line {}:\n", yylineno + 1);
- errstr.push('\n');
- errstr.push_str(&format!("Duplicate key: {key}"));
+ let mut err_str = format!("Parse error on line {}:\n", yylineno + 1);
+ err_str.push('\n');
+ err_str.push_str(&format!("Duplicate key: {key}"));
let mut details: IndexMap<String, PhpMixed> = IndexMap::new();
// PHP details: array('line' => $yylineno+1); the 'key' entry is read by
// ConfigValidator, so include it as well (PHP DuplicateKeyException stores the
@@ -510,7 +508,7 @@ impl ParseState {
details.insert("key".to_string(), PhpMixed::String(key.clone()));
details.insert("line".to_string(), PhpMixed::Int(yylineno + 1));
return Err(DuplicateKeyException {
- message: errstr,
+ message: err_str,
code: 0,
details,
}
@@ -641,11 +639,11 @@ fn string_interpolation_all(input: &str) -> String {
&& bytes[i + 2..i + 6].iter().all(|b| b.is_ascii_hexdigit()) =>
{
let hex = &input[i + 2..i + 6];
- if let Ok(cp) = u32::from_str_radix(hex, 16) {
- if let Some(c) = char::from_u32(cp) {
- let mut buf = [0u8; 4];
- out.extend_from_slice(c.encode_utf8(&mut buf).as_bytes());
- }
+ if let Ok(cp) = u32::from_str_radix(hex, 16)
+ && let Some(c) = char::from_u32(cp)
+ {
+ let mut buf = [0u8; 4];
+ out.extend_from_slice(c.encode_utf8(&mut buf).as_bytes());
}
i += 6;
continue;
@@ -714,29 +712,27 @@ fn detect_unescaped_backslash(input: &[u8]) -> Option<String> {
// `.` cannot cross a newline; PCRE `.+?` would stop — no match across lines here.
return None;
}
- if c == b'\\' {
- if consumed_one {
- let next = input.get(i + 1).copied();
- let bad = match next {
- None => true, // `[^...]` requires a char; if none, no match
- Some(b) => !valid_escape(b) && b != b'\n',
- };
- if next.is_some() && bad {
- // capture group 1: the `\`, the disallowed char, then up to 3 more (...)?
- let start = i;
- let mut end = i + 2; // backslash + the [^...] char
- // (...)? = exactly 3 chars if present
- let mut extra = 0;
- let mut k = end;
- while extra < 3 && k < n && input[k] != b'\n' {
- k += 1;
- extra += 1;
- }
- if extra == 3 {
- end = k;
- }
- return Some(String::from_utf8_lossy(&input[start..end]).into_owned());
+ if c == b'\\' && consumed_one {
+ let next = input.get(i + 1).copied();
+ let bad = match next {
+ None => true, // `[^...]` requires a char; if none, no match
+ Some(b) => !valid_escape(b) && b != b'\n',
+ };
+ if next.is_some() && bad {
+ // capture group 1: the `\`, the disallowed char, then up to 3 more (...)?
+ let start = i;
+ let mut end = i + 2; // backslash + the [^...] char
+ // (...)? = exactly 3 chars if present
+ let mut extra = 0;
+ let mut k = end;
+ while extra < 3 && k < n && input[k] != b'\n' {
+ k += 1;
+ extra += 1;
+ }
+ if extra == 3 {
+ end = k;
}
+ return Some(String::from_utf8_lossy(&input[start..end]).into_owned());
}
}
consumed_one = true;
diff --git a/crates/shirabe-external-packages/src/seld/json_lint/lexer.rs b/crates/shirabe-external-packages/src/seld/json_lint/lexer.rs
index 96263ef..b959486 100644
--- a/crates/shirabe-external-packages/src/seld/json_lint/lexer.rs
+++ b/crates/shirabe-external-packages/src/seld/json_lint/lexer.rs
@@ -170,7 +170,7 @@ impl Lexer {
let past_length = self.offset as i64 - self.match_.len() as i64;
let prefix = if past_length > 20 { "..." } else { "" };
let start = (past_length - 20).max(0) as usize;
- let len = past_length.min(20).max(0) as usize;
+ let len = past_length.clamp(0, 20) as usize;
let slice = substr_bytes(&self.input, start, len);
let mut out = prefix.as_bytes().to_vec();
out.extend_from_slice(&slice);
diff --git a/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs b/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs
index ebcc8e0..867f18e 100644
--- a/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs
+++ b/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs
@@ -27,7 +27,7 @@ pub struct ParsingExceptionDetails {
pub struct ParsingException {
pub message: String,
pub code: i64,
- pub(crate) details: ParsingExceptionDetails,
+ pub(crate) details: Box<ParsingExceptionDetails>,
}
impl ParsingException {
@@ -35,7 +35,7 @@ impl ParsingException {
Self {
message,
code: 0,
- details,
+ details: Box::new(details),
}
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/command.rs b/crates/shirabe-external-packages/src/symfony/console/command/command.rs
index 89f4ae2..527f0c5 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/command.rs
@@ -406,7 +406,7 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
self.merge_application_definition(true);
// bind the input against the command specific arguments/options
- match input.borrow_mut().bind(&*self.get_definition()) {
+ match input.borrow_mut().bind(&self.get_definition()) {
Ok(()) => {}
Err(e) => {
if !self.get_ignore_validation_errors() {
@@ -458,17 +458,16 @@ pub trait Command: std::fmt::Debug + shirabe_php_shim::AsAny {
input.borrow_mut().validate()?;
- let status_code: PhpMixed;
- if self.get_code().is_some() {
+ let status_code: PhpMixed = if self.get_code().is_some() {
let code = self.get_code();
let code = code.as_ref().unwrap();
- status_code = code(&mut *input.borrow_mut(), &mut *output.borrow_mut());
+ code(&mut *input.borrow_mut(), &mut *output.borrow_mut())
} else {
let executed = self.execute(input.clone(), output.clone())?;
- status_code = PhpMixed::from(executed);
// PHP also raises \TypeError when execute() does not return int; in this
// strongly-typed port execute() already returns an int, so the check is moot.
- }
+ PhpMixed::from(executed)
+ };
// is_numeric($statusCode) ? (int) $statusCode : 0
Ok(shirabe_php_shim::is_numeric_to_int(&status_code))
diff --git a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
index da59a75..3ed968e 100644
--- a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs
@@ -1,7 +1,6 @@
//! ref: composer/vendor/symfony/console/Command/CompleteCommand.php
use indexmap::IndexMap;
-use shirabe_php_shim::AsAny;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
@@ -327,7 +326,7 @@ impl Command for CompleteCommand {
}
Some(command) => {
command.borrow().merge_application_definition(false);
- completion_input.bind(&*command.borrow().get_definition())?;
+ completion_input.bind(&command.borrow().get_definition())?;
if CompletionInput::TYPE_OPTION_NAME == completion_input.get_completion_type() {
self.log(&format!(
diff --git a/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs b/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs
index bd51b8e..fe979cd 100644
--- a/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs
@@ -1,6 +1,5 @@
//! ref: composer/vendor/symfony/console/Completion/CompletionInput.php
-use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
use crate::symfony::console::input::argv_input::ArgvInput;
diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
index 4961bd8..8e54d9e 100644
--- a/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
@@ -62,7 +62,7 @@ impl TextDescriptor {
self.write_text(
&format!(
" <info>{}</info> {}{}{}",
- argument.get_name().to_string(),
+ argument.get_name(),
shirabe_php_shim::str_repeat(" ", spacing_width as usize),
// + 4 = 2 spaces before <info>, 2 spaces after </info>
Preg::replace(
@@ -114,14 +114,14 @@ impl TextDescriptor {
let synopsis = format!(
"{}{}",
if option.get_shortcut().is_some() {
- format!("-{}, ", option.get_shortcut().unwrap().to_string())
+ format!("-{}, ", option.get_shortcut().unwrap())
} else {
" ".to_string()
},
if option.is_negatable() {
format!("--{0}|--no-{0}", option.get_name().to_string())
} else {
- format!("--{0}{1}", option.get_name().to_string(), value.clone())
+ format!("--{0}{1}", option.get_name(), value.clone())
}
);
@@ -400,10 +400,11 @@ impl TextDescriptor {
};
self.write_text(
&format!(
- " <info>{}</info>{}{}",
+ " <info>{}</info>{}{}{}",
name.clone(),
shirabe_php_shim::str_repeat(" ", spacing_width as usize),
- format!("{}{}", command_aliases, command.get_description()),
+ command_aliases,
+ command.get_description(),
),
&options,
);
diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs
index 77fca93..c2770a4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/descriptor/xml_descriptor.rs
@@ -336,14 +336,8 @@ impl XmlDescriptor {
/// getInputOptionDocument when the default is an array (returns it verbatim).
fn default_values_as_strings(&self, default: &PhpMixed) -> Vec<String> {
match default {
- PhpMixed::List(list) => list
- .iter()
- .map(|v| shirabe_php_shim::php_to_string(v))
- .collect(),
- PhpMixed::Array(arr) => arr
- .values()
- .map(|v| shirabe_php_shim::php_to_string(v))
- .collect(),
+ PhpMixed::List(list) => list.iter().map(shirabe_php_shim::php_to_string).collect(),
+ PhpMixed::Array(arr) => arr.values().map(shirabe_php_shim::php_to_string).collect(),
_ => vec![],
}
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs
index d528b4a..030fda4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs
@@ -56,8 +56,8 @@ impl DebugFormatterHelper {
format!(
"{}<bg=blue;fg=white> {} </> <fg=blue>{}</>\n",
self.get_border(id),
- prefix.to_string(),
- message.to_string(),
+ prefix,
+ message,
)
}
@@ -81,7 +81,7 @@ impl DebugFormatterHelper {
message.push_str(&format!(
"{}<bg=red;fg=white> {} </> ",
self.get_border(id),
- error_prefix.to_string(),
+ error_prefix,
));
self.started.get_mut(id).unwrap().err = true;
}
@@ -91,7 +91,7 @@ impl DebugFormatterHelper {
&format!(
"\n{}<bg=red;fg=white> {} </> ",
self.get_border(id),
- error_prefix.to_string(),
+ error_prefix,
),
buffer,
));
@@ -104,7 +104,7 @@ impl DebugFormatterHelper {
message.push_str(&format!(
"{}<bg=green;fg=white> {} </> ",
self.get_border(id),
- prefix.to_string(),
+ prefix,
));
self.started.get_mut(id).unwrap().out = true;
}
@@ -114,7 +114,7 @@ impl DebugFormatterHelper {
&format!(
"\n{}<bg=green;fg=white> {} </> ",
self.get_border(id),
- prefix.to_string(),
+ prefix,
),
buffer,
));
@@ -134,19 +134,19 @@ impl DebugFormatterHelper {
if successful {
return format!(
"{}{}<bg=green;fg=white> {} </> <fg=green>{}</>\n",
- trailing_eol.to_string(),
+ trailing_eol,
self.get_border(id),
- prefix.to_string(),
- message.to_string(),
+ prefix,
+ message,
);
}
let message = format!(
"{}{}<bg=red;fg=white> {} </> <fg=red>{}</>\n",
- trailing_eol.to_string(),
+ trailing_eol,
self.get_border(id),
- prefix.to_string(),
- message.to_string(),
+ prefix,
+ message,
);
if let Some(session) = self.started.get_mut(id) {
@@ -158,10 +158,7 @@ impl DebugFormatterHelper {
}
fn get_border(&self, id: &str) -> String {
- format!(
- "<bg={}> </>",
- COLORS[self.started[id].border as usize].to_string(),
- )
+ format!("<bg={}> </>", COLORS[self.started[id].border as usize],)
}
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs
index 8a6c97f..e1dbd1e 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs
@@ -16,13 +16,7 @@ pub struct FormatterHelper {
impl FormatterHelper {
/// Formats a message within a section.
pub fn format_section(&self, section: &str, message: &str, style: &str) -> String {
- format!(
- "<{}>[{}]</{}> {}",
- style.to_string(),
- section.to_string(),
- style.to_string(),
- message.to_string(),
- )
+ format!("<{}>[{}]</{}> {}", style, section, style, message,)
}
/// Formats a message as a block of text.
@@ -66,12 +60,7 @@ impl FormatterHelper {
let mut i = 0;
while i < messages.len() {
- messages[i] = format!(
- "<{}>{}</{}>",
- style.to_string(),
- messages[i].clone(),
- style.to_string(),
- );
+ messages[i] = format!("<{}>{}</{}>", style, messages[i].clone(), style,);
i += 1;
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs
index c59eed0..10fff08 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/process_helper.rs
@@ -4,7 +4,6 @@ use crate::symfony::console::helper::debug_formatter_helper::DebugFormatterHelpe
use crate::symfony::console::helper::helper::Helper;
use crate::symfony::console::helper::helper_interface::HelperInterface;
use crate::symfony::console::helper::helper_set::HelperSet;
-use crate::symfony::console::output::console_output_interface::ConsoleOutputInterface;
use crate::symfony::console::output::output_interface::{self, OutputInterface};
use crate::symfony::process::exception::process_failed_exception::ProcessFailedException;
use crate::symfony::process::process::Process;
@@ -221,7 +220,8 @@ impl ProcessHelper {
&self,
output: Rc<RefCell<dyn OutputInterface>>,
process: &Process,
- mut callback: Option<Box<dyn FnMut(&str, &str)>>,
+ // TODO: remove allow(unused_mut) once todo!() is resolved.
+ #[allow(unused_mut)] mut callback: Option<Box<dyn FnMut(&str, &str)>>,
) -> Box<dyn FnMut(&str, &str)> {
// PHP: `if ($output instanceof ConsoleOutputInterface) { $output =
// $output->getErrorOutput(); }`. Downcasting a shared `dyn
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs b/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
index ab97d2e..aa7e326 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
@@ -584,7 +584,7 @@ impl ProgressBar {
Box::new(
|bar: &ProgressBar, output: &Rc<RefCell<dyn OutputInterface>>| {
let complete_bars = bar.get_bar_offset();
- let mut display = shirabe_php_shim::str_repeat(
+ let display = shirabe_php_shim::str_repeat(
&bar.get_bar_character(),
complete_bars as usize,
);
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
index 281069e..b6d096a 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/question_helper.rs
@@ -19,7 +19,6 @@ use crate::symfony::console::question::ChoiceQuestion;
use crate::symfony::console::question::QuestionInterface;
use crate::symfony::console::terminal::Terminal;
use crate::symfony::string::s;
-use shirabe_php_shim::AsAny;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
@@ -126,10 +125,23 @@ impl QuestionHelper {
let autocomplete = question.get_autocompleter_callback();
let ret: PhpMixed;
- if autocomplete.is_none()
- || !STTY.load(std::sync::atomic::Ordering::SeqCst)
- || !Terminal::has_stty_available()
+
+ if let Some(autocomplete) = autocomplete
+ && STTY.load(std::sync::atomic::Ordering::SeqCst)
+ && Terminal::has_stty_available()
{
+ let callback = autocomplete;
+ // The autocompleter callback yields an iterable (Option here); PHP
+ // treats a null result as an empty list of suggestions.
+ let callback = move |input: &str| callback(input).unwrap_or_default();
+ let autocomplete =
+ self.autocomplete(Rc::clone(&output), question, &input_stream, &callback);
+ ret = PhpMixed::String(if question.is_trimmable() {
+ shirabe_php_shim::trim(&autocomplete, None)
+ } else {
+ autocomplete
+ });
+ } else {
let mut r: PhpMixed = PhpMixed::Bool(false);
if question.is_hidden() {
match self.get_hidden_response(
@@ -182,18 +194,6 @@ impl QuestionHelper {
}
}
ret = r;
- } else {
- let callback = autocomplete.unwrap();
- // The autocompleter callback yields an iterable (Option here); PHP
- // treats a null result as an empty list of suggestions.
- let callback = move |input: &str| callback(input).unwrap_or_default();
- let autocomplete =
- self.autocomplete(Rc::clone(&output), question, &input_stream, &callback);
- ret = PhpMixed::String(if question.is_trimmable() {
- shirabe_php_shim::trim(&autocomplete, None)
- } else {
- autocomplete
- });
}
let mut ret = ret;
@@ -318,12 +318,12 @@ impl QuestionHelper {
) {
let message = if let Some(helper_set) = self.get_helper_set() {
let formatter = helper_set.borrow().get_formatter();
- let message = formatter.borrow().format_block(
+
+ formatter.borrow().format_block(
FormatBlockMessages::String(error.message.clone()),
"error",
false,
- );
- message
+ )
} else {
format!("<error>{}</error>", error.message)
};
@@ -476,7 +476,6 @@ impl QuestionHelper {
)
})
.collect();
- num_matches = matches.len() as i64;
ofs = -1;
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs
index ea7a322..a5118f4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/symfony_question_helper.rs
@@ -6,7 +6,6 @@ use crate::symfony::console::output::output_interface;
use crate::symfony::console::output::output_interface::OutputInterface;
use crate::symfony::console::question::QuestionInterface;
use crate::symfony::console::style::symfony_style::SymfonyStyle;
-use shirabe_php_shim::AsAny;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::ops::{Deref, DerefMut};
@@ -46,8 +45,7 @@ impl SymfonyQuestionHelper {
"yes"
} else {
"no"
- }
- .to_string(),
+ },
);
} else if let Some(choice_question) = question.as_choice().filter(|q| q.is_multiselect()) {
let choices = choice_question.get_choices();
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
index 59da457..04d5f1f 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
@@ -14,7 +14,6 @@ use crate::symfony::console::helper::table_style::TableStyle;
use crate::symfony::console::output::console_section_output::ConsoleSectionOutput;
use crate::symfony::console::output::output_interface::OutputInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::AsAny;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;
@@ -509,8 +508,7 @@ impl Table {
/// Renders table to output.
pub fn render(&mut self) {
- let rows: Vec<Row>;
- if self.horizontal {
+ let rows: Vec<Row> = if self.horizontal {
let mut horizontal_rows: IndexMap<i64, Vec<Cell>> = IndexMap::new();
let header0 = self.headers.first().map(|h| h.cells()).unwrap_or_default();
for (i, header) in header0.into_iter().enumerate() {
@@ -538,13 +536,13 @@ impl Table {
}
}
}
- rows = horizontal_rows.into_values().map(Row::Cells).collect();
+ horizontal_rows.into_values().map(Row::Cells).collect()
} else {
let mut merged = self.headers.clone();
merged.push(Row::HeaderDivider);
merged.extend(self.rows.clone());
- rows = merged;
- }
+ merged
+ };
self.calculate_number_of_columns(&rows);
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs b/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs
index 54a5f3a..c1a708a 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs
@@ -270,10 +270,10 @@ impl ArgvInput {
format!(
"No arguments expected for \"{}\" command, got \"{}\".",
symfony_command_name.clone().unwrap(),
- token.to_string(),
+ token,
)
} else {
- format!("No arguments expected, got \"{}\".", token.to_string())
+ format!("No arguments expected, got \"{}\".", token)
};
return Err(
@@ -288,7 +288,7 @@ impl ArgvInput {
fn add_short_option(&mut self, shortcut: &str, value: PhpMixed) -> anyhow::Result<()> {
if !self.inner.definition.has_shortcut(shortcut) {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!("The \"-{}\" option does not exist.", shortcut.to_string()),
+ message: format!("The \"-{}\" option does not exist.", shortcut),
code: 0,
})
.into());
@@ -308,7 +308,7 @@ impl ArgvInput {
if !self.inner.definition.has_option(name) {
if !self.inner.definition.has_negation(name) {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!("The \"--{}\" option does not exist.", name.to_string()),
+ message: format!("The \"--{}\" option does not exist.", name),
code: 0,
})
.into());
@@ -317,10 +317,7 @@ impl ArgvInput {
let option_name = self.inner.definition.negation_to_name(name)?;
if !matches!(value, PhpMixed::Null) {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!(
- "The \"--{}\" option does not accept a value.",
- name.to_string(),
- ),
+ message: format!("The \"--{}\" option does not accept a value.", name,),
code: 0,
})
.into());
@@ -336,10 +333,7 @@ impl ArgvInput {
if !matches!(value, PhpMixed::Null) && !option.accept_value() {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!(
- "The \"--{}\" option does not accept a value.",
- name.to_string(),
- ),
+ message: format!("The \"--{}\" option does not accept a value.", name,),
code: 0,
})
.into());
@@ -364,7 +358,7 @@ impl ArgvInput {
if matches!(value, PhpMixed::Null) {
if option.is_value_required() {
return Err(RuntimeException(shirabe_php_shim::RuntimeException {
- message: format!("The \"--{}\" option requires a value.", name.to_string()),
+ message: format!("The \"--{}\" option requires a value.", name),
code: 0,
})
.into());
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs b/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs
index 384bc6d..051d8bd 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs
@@ -216,7 +216,7 @@ impl ArrayInput {
if !self.inner.definition.has_shortcut(shortcut) {
return Err(InvalidOptionException(InvalidArgumentException(
shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"-{}\" option does not exist.", shortcut.to_string()),
+ message: format!("The \"-{}\" option does not exist.", shortcut),
code: 0,
},
))
@@ -238,7 +238,7 @@ impl ArrayInput {
if !self.inner.definition.has_negation(name) {
return Err(InvalidOptionException(InvalidArgumentException(
shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"--{}\" option does not exist.", name.to_string()),
+ message: format!("The \"--{}\" option does not exist.", name),
code: 0,
},
))
@@ -257,18 +257,13 @@ impl ArrayInput {
if matches!(value, PhpMixed::Null) {
if option.is_value_required() {
- return Err(
- InvalidOptionException(InvalidArgumentException(
- shirabe_php_shim::InvalidArgumentException {
- message: format!(
- "The \"--{}\" option requires a value.",
- name.to_string(),
- ),
- code: 0,
- },
- ))
- .into(),
- );
+ return Err(InvalidOptionException(InvalidArgumentException(
+ shirabe_php_shim::InvalidArgumentException {
+ message: format!("The \"--{}\" option requires a value.", name,),
+ code: 0,
+ },
+ ))
+ .into());
}
if !option.is_value_optional() {
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/input.rs b/crates/shirabe-external-packages/src/symfony/console/input/input.rs
index 5e5a12b..70b6185 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/input.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/input.rs
@@ -115,7 +115,7 @@ impl Input {
{
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"{}\" argument does not exist.", name.to_string()),
+ message: format!("The \"{}\" argument does not exist.", name),
code: 0,
})
.into(),
@@ -139,7 +139,7 @@ impl Input {
{
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"{}\" argument does not exist.", name.to_string()),
+ message: format!("The \"{}\" argument does not exist.", name),
code: 0,
})
.into(),
@@ -176,7 +176,7 @@ impl Input {
if !self.definition.has_option(name) {
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"{}\" option does not exist.", name.to_string()),
+ message: format!("The \"{}\" option does not exist.", name),
code: 0,
})
.into(),
@@ -200,7 +200,7 @@ impl Input {
} else if !self.definition.has_option(name) {
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"{}\" option does not exist.", name.to_string()),
+ message: format!("The \"{}\" option does not exist.", name),
code: 0,
})
.into(),
diff --git a/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs b/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs
index 56f685c..a1d3d30 100644
--- a/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs
@@ -114,7 +114,7 @@ impl InputDefinition {
return Err(LogicException(shirabe_php_shim::LogicException {
message: format!(
"An argument with name \"{}\" already exists.",
- argument.get_name().to_string(),
+ argument.get_name(),
),
code: 0,
})
@@ -125,8 +125,8 @@ impl InputDefinition {
return Err(LogicException(shirabe_php_shim::LogicException {
message: format!(
"Cannot add a required argument \"{}\" after an array argument \"{}\".",
- argument.get_name().to_string(),
- last_array_argument.get_name().to_string(),
+ argument.get_name(),
+ last_array_argument.get_name(),
),
code: 0,
})
@@ -139,8 +139,8 @@ impl InputDefinition {
return Err(LogicException(shirabe_php_shim::LogicException {
message: format!(
"Cannot add a required argument \"{}\" after an optional one \"{}\".",
- argument.get_name().to_string(),
- last_optional_argument.get_name().to_string(),
+ argument.get_name(),
+ last_optional_argument.get_name(),
),
code: 0,
})
@@ -260,20 +260,14 @@ impl InputDefinition {
&& !option.equals(existing)
{
return Err(LogicException(shirabe_php_shim::LogicException {
- message: format!(
- "An option named \"{}\" already exists.",
- option.get_name().to_string(),
- ),
+ message: format!("An option named \"{}\" already exists.", option.get_name(),),
code: 0,
})
.into());
}
if self.negations.contains_key(option.get_name()) {
return Err(LogicException(shirabe_php_shim::LogicException {
- message: format!(
- "An option named \"{}\" already exists.",
- option.get_name().to_string(),
- ),
+ message: format!("An option named \"{}\" already exists.", option.get_name(),),
code: 0,
})
.into());
@@ -329,7 +323,7 @@ impl InputDefinition {
if !self.has_option(name) {
return Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"--{}\" option does not exist.", name.to_string()),
+ message: format!("The \"--{}\" option does not exist.", name),
code: 0,
})
.into(),
@@ -381,7 +375,7 @@ impl InputDefinition {
match self.shortcuts.get(shortcut) {
None => Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"-{}\" option does not exist.", shortcut.to_string()),
+ message: format!("The \"-{}\" option does not exist.", shortcut),
code: 0,
})
.into(),
@@ -395,7 +389,7 @@ impl InputDefinition {
match self.negations.get(negation) {
None => Err(
InvalidArgumentException(shirabe_php_shim::InvalidArgumentException {
- message: format!("The \"--{}\" option does not exist.", negation.to_string()),
+ message: format!("The \"--{}\" option does not exist.", negation),
code: 0,
})
.into(),
@@ -432,19 +426,19 @@ impl InputDefinition {
let shortcut = match option.get_shortcut() {
Some(shortcut) => {
- format!("-{}|", shortcut.to_string())
+ format!("-{}|", shortcut)
}
None => String::new(),
};
let negation = if option.is_negatable() {
- format!("|--no-{}", option.get_name().to_string())
+ format!("|--no-{}", option.get_name())
} else {
String::new()
};
elements.push(format!(
"[{}--{}{}{}]",
shortcut,
- option.get_name().to_string(),
+ option.get_name(),
value,
negation,
));
diff --git a/crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs b/crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs
index 6c405a0..b42f2a4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/output/trimmed_buffer_output.rs
@@ -25,8 +25,7 @@ impl TrimmedBufferOutput {
shirabe_php_shim::InvalidArgumentException {
message: format!(
"\"{}()\" expects a strictly positive maxLength. Got {}.",
- "Symfony\\Component\\Console\\Output\\TrimmedBufferOutput::__construct"
- .to_string(),
+ "Symfony\\Component\\Console\\Output\\TrimmedBufferOutput::__construct",
max_length,
),
code: 0,
diff --git a/crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs b/crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs
index 6c44966..a8cde91 100644
--- a/crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/question/choice_question.rs
@@ -265,13 +265,13 @@ impl QuestionInterface for ChoiceQuestion {
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()
}
@@ -279,7 +279,7 @@ impl QuestionInterface for ChoiceQuestion {
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-external-packages/src/symfony/console/question/confirmation_question.rs b/crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs
index 74039d0..4a05046 100644
--- a/crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/question/confirmation_question.rs
@@ -85,13 +85,13 @@ impl QuestionInterface for ConfirmationQuestion {
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()
}
@@ -99,7 +99,7 @@ impl QuestionInterface for ConfirmationQuestion {
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-external-packages/src/symfony/console/question/question.rs b/crates/shirabe-external-packages/src/symfony/console/question/question.rs
index 2ff5f62..a96c315 100644
--- a/crates/shirabe-external-packages/src/symfony/console/question/question.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/question/question.rs
@@ -26,15 +26,15 @@ pub trait QuestionInterface: std::fmt::Debug {
fn get_autocompleter_values(&self) -> Option<Vec<PhpMixed>>;
- fn get_autocompleter_callback(&self) -> Option<&(dyn Fn(&str) -> Option<Vec<PhpMixed>>)>;
+ fn get_autocompleter_callback(&self) -> Option<&dyn Fn(&str) -> Option<Vec<PhpMixed>>>;
fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)>;
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>>;
fn get_max_attempts(&self) -> Option<i64>;
- fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)>;
+ fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed>;
fn is_trimmable(&self) -> bool;
@@ -178,13 +178,13 @@ impl Question {
// array_merge(array_keys($values), array_values($values))
let mut merged: Vec<PhpMixed> =
array.keys().map(|k| PhpMixed::String(k.clone())).collect();
- merged.extend(array.values().map(|v| v.clone()));
+ merged.extend(array.values().cloned());
merged
} else {
// array_values($values)
match &values {
- PhpMixed::List(list) => list.iter().cloned().collect(),
- PhpMixed::Array(array) => array.values().map(|v| v.clone()).collect(),
+ PhpMixed::List(list) => list.to_vec(),
+ PhpMixed::Array(array) => array.values().cloned().collect(),
_ => unreachable!(),
}
};
@@ -200,7 +200,7 @@ impl Question {
// list/array elements, otherwise treat as an empty iterator.
let cached: Vec<PhpMixed> = match values {
PhpMixed::List(list) => list.into_iter().collect(),
- PhpMixed::Array(array) => array.into_values().map(|v| v).collect(),
+ PhpMixed::Array(array) => array.into_values().collect(),
_ => Vec::new(),
};
Some(Box::new(move |_input: &str| Some(cached.clone())))
@@ -212,7 +212,7 @@ impl Question {
}
/// Gets the callback function used for the autocompleter.
- pub fn get_autocompleter_callback(&self) -> Option<&(dyn Fn(&str) -> Option<Vec<PhpMixed>>)> {
+ pub fn get_autocompleter_callback(&self) -> Option<&dyn Fn(&str) -> Option<Vec<PhpMixed>>> {
self.autocompleter_callback.as_deref()
}
@@ -251,7 +251,7 @@ impl Question {
/// Gets the validator for the question.
pub fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)> {
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>> {
self.validator.as_deref()
}
@@ -299,7 +299,7 @@ impl Question {
/// Gets the normalizer for the response.
///
/// The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
- pub fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)> {
+ pub fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed> {
self.normalizer.as_deref()
}
@@ -352,13 +352,13 @@ impl QuestionInterface for Question {
self.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.get_autocompleter_callback()
}
fn get_validator(
&self,
- ) -> Option<&(dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>)> {
+ ) -> Option<&dyn Fn(Option<PhpMixed>) -> Result<PhpMixed, InvalidArgumentException>> {
self.get_validator()
}
@@ -366,7 +366,7 @@ impl QuestionInterface for Question {
self.get_max_attempts()
}
- fn get_normalizer(&self) -> Option<&(dyn Fn(PhpMixed) -> PhpMixed)> {
+ fn get_normalizer(&self) -> Option<&dyn Fn(PhpMixed) -> PhpMixed> {
self.get_normalizer()
}
diff --git a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
index 2f7c7cb..425c815 100644
--- a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
@@ -9,7 +9,6 @@ use crate::symfony::console::helper::ProgressBar;
use crate::symfony::console::helper::SymfonyQuestionHelper;
use crate::symfony::console::helper::Table;
use crate::symfony::console::helper::TableCell;
-use crate::symfony::console::helper::TableSeparator;
use crate::symfony::console::helper::table::{Cell, Row};
use crate::symfony::console::input::InputInterface;
use crate::symfony::console::output::ConsoleOutputInterface;
@@ -429,7 +428,7 @@ impl SymfonyStyle {
));
if let Some(style) = style {
- *line = format!("<{}>{}</>", style.to_string(), line.clone());
+ *line = format!("<{}>{}</>", style, line.clone());
}
}
@@ -722,8 +721,7 @@ impl StyleInterface for SymfonyStyle {
default: Option<PhpMixed>,
) -> PhpMixed {
let default = if let Some(default) = default {
- let values =
- shirabe_php_shim::array_flip(&PhpMixed::List(choices.iter().cloned().collect()));
+ let values = shirabe_php_shim::array_flip(&PhpMixed::List(choices.to_vec()));
// $default = $values[$default] ?? $default;
let resolved = match &values {
PhpMixed::Array(map) => map.get(&default.to_string()).cloned(),
diff --git a/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs b/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs
index ba5b764..3a1b1b0 100644
--- a/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs
+++ b/crates/shirabe-external-packages/src/symfony/filesystem/filesystem.rs
@@ -721,10 +721,10 @@ impl Filesystem {
if scheme.is_none() || scheme.as_deref() == Some("file") || scheme.as_deref() == Some("gs")
{
if let Some(tmp_file) = shirabe_php_shim::tempnam(&hierarchy, prefix) {
- if let Some(scheme) = &scheme {
- if scheme != "gs" {
- return Ok(format!("{}://{}", scheme, tmp_file));
- }
+ if let Some(scheme) = &scheme
+ && scheme != "gs"
+ {
+ return Ok(format!("{}://{}", scheme, tmp_file));
}
return Ok(tmp_file);
}
diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
index bafd146..43a6567 100644
--- a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs
@@ -15,7 +15,7 @@ pub struct AbstractPipes {
impl AbstractPipes {
pub fn new(input: PhpMixed) -> Self {
- let mut input_buffer = String::new();
+ let input_buffer;
let stored_input;
// TODO(plugin): `$input instanceof \Iterator` is not modeled. The PHP `is_resource($input)`
// branch never applies: a PhpMixed is never a resource, so input is never stored as-is here.
@@ -81,9 +81,7 @@ impl AbstractPipes {
let mut w: Vec<PhpResource> = vec![stdin.clone()];
// let's have a look if something changed in streams
- if php::stream_select(&mut r, &mut w, &mut e, 0, Some(0)).is_none() {
- return None;
- }
+ php::stream_select(&mut r, &mut w, &mut e, 0, Some(0))?;
if !self.input_buffer.is_empty() {
let written = php::fwrite(&stdin, &self.input_buffer, None).unwrap_or(0) as usize;
diff --git a/crates/shirabe-external-packages/src/symfony/process/process.rs b/crates/shirabe-external-packages/src/symfony/process/process.rs
index 1b58972..fbf2da7 100644
--- a/crates/shirabe-external-packages/src/symfony/process/process.rs
+++ b/crates/shirabe-external-packages/src/symfony/process/process.rs
@@ -1045,28 +1045,26 @@ impl Process {
return Ok(());
}
- if let Some(timeout) = self.timeout {
- if timeout < php::microtime() - self.starttime.unwrap_or(0.0) {
- self.stop(0.0, None);
+ if let Some(timeout) = self.timeout
+ && timeout < php::microtime() - self.starttime.unwrap_or(0.0)
+ {
+ self.stop(0.0, None);
- return Err(ProcessTimedOutException::new(
- self,
- ProcessTimedOutException::TYPE_GENERAL,
- )
- .into());
- }
+ return Err(ProcessTimedOutException::new(
+ self,
+ ProcessTimedOutException::TYPE_GENERAL,
+ )
+ .into());
}
- if let Some(idle_timeout) = self.idle_timeout {
- if idle_timeout < php::microtime() - self.last_output_time.unwrap_or(0.0) {
- self.stop(0.0, None);
+ if let Some(idle_timeout) = self.idle_timeout
+ && idle_timeout < php::microtime() - self.last_output_time.unwrap_or(0.0)
+ {
+ self.stop(0.0, None);
- return Err(ProcessTimedOutException::new(
- self,
- ProcessTimedOutException::TYPE_IDLE,
- )
- .into());
- }
+ return Err(
+ ProcessTimedOutException::new(self, ProcessTimedOutException::TYPE_IDLE).into(),
+ );
}
Ok(())
@@ -1242,13 +1240,14 @@ impl Process {
self.cached_exit_code = exitcode;
}
- if let Some(cached) = self.cached_exit_code {
- if !running && exitcode == Some(-1) {
- self.process_information
- .as_mut()
- .unwrap()
- .insert("exitcode".to_string(), PhpMixed::Int(cached));
- }
+ if let Some(cached) = self.cached_exit_code
+ && !running
+ && exitcode == Some(-1)
+ {
+ self.process_information
+ .as_mut()
+ .unwrap()
+ .insert("exitcode".to_string(), PhpMixed::Int(cached));
}
}
@@ -1386,11 +1385,11 @@ impl Process {
if signaled && termsig > 0 {
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
self.exitcode = Some(128 + termsig);
- } else if self.is_sigchild_enabled() {
- if let Some(i) = self.process_information.as_mut() {
- i.insert("signaled".to_string(), PhpMixed::Bool(true));
- i.insert("termsig".to_string(), PhpMixed::Int(-1));
- }
+ } else if self.is_sigchild_enabled()
+ && let Some(i) = self.process_information.as_mut()
+ {
+ i.insert("signaled".to_string(), PhpMixed::Bool(true));
+ i.insert("termsig".to_string(), PhpMixed::Int(-1));
}
}
@@ -1659,13 +1658,11 @@ impl Process {
key, commandline
))
.into()),
- Some(v) if matches!(v, PhpMixed::Bool(false)) => {
- Err(InvalidArgumentException::new(format!(
- "Command line is missing a value for parameter \"{}\": {}",
- key, commandline
- ))
- .into())
- }
+ Some(PhpMixed::Bool(false)) => Err(InvalidArgumentException::new(format!(
+ "Command line is missing a value for parameter \"{}\": {}",
+ key, commandline
+ ))
+ .into()),
Some(v) => Ok(self.escape_argument(Some(&to_php_string(v)))),
}
},
diff --git a/crates/shirabe-external-packages/src/symfony/string/code_point_string.rs b/crates/shirabe-external-packages/src/symfony/string/code_point_string.rs
index ce67428..15a6cfc 100644
--- a/crates/shirabe-external-packages/src/symfony/string/code_point_string.rs
+++ b/crates/shirabe-external-packages/src/symfony/string/code_point_string.rs
@@ -157,7 +157,7 @@ fn php_wordwrap(text: &str, linelength: i64, breakchar: &str, docut: bool) -> St
out.extend_from_slice(&text[laststart as usize..lastspace as usize]);
out.extend_from_slice(breakchar);
laststart = lastspace + 1;
- lastspace = lastspace + 1;
+ lastspace += 1;
}
current += 1;
}
diff --git a/crates/shirabe-php-shim/src/array.rs b/crates/shirabe-php-shim/src/array.rs
index ace6a72..6c2004c 100644
--- a/crates/shirabe-php-shim/src/array.rs
+++ b/crates/shirabe-php-shim/src/array.rs
@@ -86,12 +86,12 @@ pub fn array_merge(array1: PhpMixed, array2: PhpMixed) -> PhpMixed {
}
PhpMixed::Array(map) => {
for (key, value) in map {
- if let Ok(n) = key.parse::<i64>() {
- if n.to_string() == key {
- result.insert(next_int.to_string(), value);
- next_int += 1;
- continue;
- }
+ if let Ok(n) = key.parse::<i64>()
+ && n.to_string() == key
+ {
+ result.insert(next_int.to_string(), value);
+ next_int += 1;
+ continue;
}
result.insert(key, value);
}
@@ -123,12 +123,12 @@ pub fn array_merge_map<V>(
let mut next_int: i64 = 0;
for array in [array1, array2] {
for (key, value) in array {
- if let Ok(n) = key.parse::<i64>() {
- if n.to_string() == key {
- result.insert(next_int.to_string(), value);
- next_int += 1;
- continue;
- }
+ if let Ok(n) = key.parse::<i64>()
+ && n.to_string() == key
+ {
+ result.insert(next_int.to_string(), value);
+ next_int += 1;
+ continue;
}
result.insert(key, value);
}
@@ -437,10 +437,10 @@ fn merge_entries(value: PhpMixed) -> Vec<(MergeKey, PhpMixed)> {
}
fn merge_parse_key(key: String) -> MergeKey {
- if let Ok(n) = key.parse::<i64>() {
- if n.to_string() == key {
- return MergeKey::Int(n);
- }
+ if let Ok(n) = key.parse::<i64>()
+ && n.to_string() == key
+ {
+ return MergeKey::Int(n);
}
MergeKey::Str(key)
}
@@ -561,10 +561,10 @@ pub fn array_diff_key(
/// Map a PHP array key (always stored as a `String` here) back to its PHP value
/// type: an integer-like key becomes an int, anything else stays a string.
fn php_key_to_mixed(key: &str) -> PhpMixed {
- if let Ok(n) = key.parse::<i64>() {
- if n.to_string() == key {
- return PhpMixed::Int(n);
- }
+ if let Ok(n) = key.parse::<i64>()
+ && n.to_string() == key
+ {
+ return PhpMixed::Int(n);
}
PhpMixed::String(key.to_string())
}
@@ -664,7 +664,7 @@ pub fn krsort<V>(array: &mut IndexMap<i64, V>) {
array.sort_by(|k1, _, k2, _| k2.cmp(k1));
}
-pub fn uasort<T, F>(array: &mut Vec<T>, compare: F)
+pub fn uasort<T, F>(array: &mut [T], compare: F)
where
F: FnMut(&T, &T) -> i64,
{
@@ -684,7 +684,7 @@ pub fn sort<T: Ord>(_array: &mut Vec<T>) {
_array.sort();
}
-pub fn sort_with_flags<T: Ord>(array: &mut Vec<T>, flags: i64) {
+pub fn sort_with_flags<T: Ord>(array: &mut [T], flags: i64) {
if flags != SORT_REGULAR {
// TODO(phase-d): flag-specific comparison (SORT_NUMERIC/SORT_STRING/
// SORT_NATURAL/SORT_FLAG_CASE) cannot be expressed for a generic
@@ -717,10 +717,11 @@ pub fn ksort<V>(array: &mut IndexMap<String, V>) {
// TODO(phase-d): full SORT_REGULAR semantics for mixed integer/non-numeric-string
// keys are not reproduced; every current caller uses homogeneous string keys.
fn php_sort_regular_key(a: &str, b: &str) -> std::cmp::Ordering {
- if let (Ok(na), Ok(nb)) = (a.parse::<i64>(), b.parse::<i64>()) {
- if na.to_string() == a && nb.to_string() == b {
- return na.cmp(&nb);
- }
+ if let (Ok(na), Ok(nb)) = (a.parse::<i64>(), b.parse::<i64>())
+ && na.to_string() == a
+ && nb.to_string() == b
+ {
+ return na.cmp(&nb);
}
a.cmp(b)
}
@@ -737,7 +738,7 @@ where
array.sort_by(|k1, _, k2, _| callback(k1, k2).cmp(&0));
}
-pub fn sort_natural_flag_case(values: &mut Vec<String>) {
+pub fn sort_natural_flag_case(values: &mut [String]) {
values.sort_by(|a, b| crate::strnatcasecmp(a, b).cmp(&0));
}
diff --git a/crates/shirabe-php-shim/src/env.rs b/crates/shirabe-php-shim/src/env.rs
index cf0c659..9043167 100644
--- a/crates/shirabe-php-shim/src/env.rs
+++ b/crates/shirabe-php-shim/src/env.rs
@@ -8,11 +8,21 @@ pub fn getenv<K: AsRef<std::ffi::OsStr>>(key: K) -> Option<std::ffi::OsString> {
std::env::var_os(key)
}
+/// # Safety
+///
+/// Wraps [`std::env::set_var`], which is unsafe: the caller must ensure no other
+/// thread is concurrently reading or writing the process environment for the
+/// duration of this call.
pub unsafe fn putenv<K: AsRef<std::ffi::OsStr>, V: AsRef<std::ffi::OsStr>>(key: K, value: V) {
// TODO: validate key and value format to avoid panic?
unsafe { std::env::set_var(key, value) }
}
+/// # Safety
+///
+/// Wraps [`std::env::remove_var`], which is unsafe: the caller must ensure no other
+/// thread is concurrently reading or writing the process environment for the
+/// duration of this call.
pub unsafe fn putenv_clear<K: AsRef<std::ffi::OsStr>>(key: K) {
// TODO: validate key and value format to avoid panic?
unsafe { std::env::remove_var(key) }
diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs
index a557d26..bd882c2 100644
--- a/crates/shirabe-php-shim/src/fs.rs
+++ b/crates/shirabe-php-shim/src/fs.rs
@@ -259,13 +259,15 @@ pub fn fopen(file: &str, mode: &str) -> Result<PhpResource, std::io::Error> {
// (this is what Symfony's ApplicationTester relies on -- it opens "php://memory" with "w" and
// then rewinds + reads it back). So memory streams are always both readable and writable.
if file == "php://memory" || file.starts_with("php://temp") {
- return Ok(StreamState::new(
- StreamBacking::Memory(std::io::Cursor::new(Vec::new())),
- true,
- true,
- mode.to_string(),
- file.to_string(),
- ));
+ return Ok(PhpResource::Stream(std::rc::Rc::new(
+ std::cell::RefCell::new(StreamState::new(
+ StreamBacking::Memory(std::io::Cursor::new(Vec::new())),
+ true,
+ true,
+ mode.to_string(),
+ file.to_string(),
+ )),
+ )));
}
let uri = file.to_string();
let mut options = std::fs::OpenOptions::new();
@@ -284,13 +286,15 @@ pub fn fopen(file: &str, mode: &str) -> Result<PhpResource, std::io::Error> {
_ => options.read(true),
};
let file = options.open(file)?;
- Ok(StreamState::new(
- StreamBacking::File(file),
- readable,
- writable,
- mode.to_string(),
- uri,
- ))
+ Ok(PhpResource::Stream(std::rc::Rc::new(
+ std::cell::RefCell::new(StreamState::new(
+ StreamBacking::File(file),
+ readable,
+ writable,
+ mode.to_string(),
+ uri,
+ )),
+ )))
}
/// PHP `fwrite()`. `length` caps the number of bytes written (`None` = whole string).
@@ -380,7 +384,6 @@ pub fn fclose(stream: &PhpResource) -> bool {
if state.closed {
return false;
}
- use std::io::Write;
let _ = state.backing.as_rws().flush();
state.closed = true;
true
@@ -430,10 +433,10 @@ fn fgets_read_line<R: std::io::Read + ?Sized>(
let mut line = Vec::new();
let mut byte = [0u8; 1];
loop {
- if let Some(max) = limit {
- if line.len() >= max {
- break;
- }
+ if let Some(max) = limit
+ && line.len() >= max
+ {
+ break;
}
let n = r.read(&mut byte)?;
if n == 0 {
@@ -478,7 +481,6 @@ pub fn fgetc(stream: &PhpResource) -> Option<String> {
/// PHP `ftell()`: the current position, or `None` for `false`-on-failure.
pub fn ftell(stream: &PhpResource) -> Option<i64> {
- use std::io::Seek;
match stream {
PhpResource::Stdin
| PhpResource::Stdout
@@ -501,7 +503,6 @@ pub fn ftell(stream: &PhpResource) -> Option<i64> {
/// PHP `fseek()`. Returns 0 on success, -1 on failure.
pub fn fseek(stream: &PhpResource, offset: i64, whence: i64) -> i64 {
- use std::io::Seek;
let from = match whence {
SEEK_CUR => std::io::SeekFrom::Current(offset),
SEEK_END => std::io::SeekFrom::End(offset),
diff --git a/crates/shirabe-php-shim/src/hash.rs b/crates/shirabe-php-shim/src/hash.rs
index 6e12a81..d77cc0a 100644
--- a/crates/shirabe-php-shim/src/hash.rs
+++ b/crates/shirabe-php-shim/src/hash.rs
@@ -1,6 +1,5 @@
use crate::bin2hex;
use sha1::Digest as _;
-use sha2::Digest as _;
pub fn hash(algo: &str, data: &str) -> String {
crate::bin2hex(&calculate_hash(algo, data.as_bytes()))
diff --git a/crates/shirabe-php-shim/src/json.rs b/crates/shirabe-php-shim/src/json.rs
index e2c48e4..1fa86ca 100644
--- a/crates/shirabe-php-shim/src/json.rs
+++ b/crates/shirabe-php-shim/src/json.rs
@@ -33,7 +33,6 @@ pub fn json_encode_ex<T: serde::Serialize + ?Sized>(
// them when a call site needs them.
let mut s = if flags & JSON_PRETTY_PRINT != 0 {
// PHP's JSON_PRETTY_PRINT uses a 4-space indent.
- use serde::Serialize;
let mut buf = Vec::new();
let formatter = serde_json::ser::PrettyFormatter::with_indent(b" ");
let mut ser = serde_json::Serializer::with_formatter(&mut buf, formatter);
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs
index 8c8073f..cc868ff 100644
--- a/crates/shirabe-php-shim/src/lib.rs
+++ b/crates/shirabe-php-shim/src/lib.rs
@@ -480,8 +480,8 @@ impl StreamState {
writable: bool,
mode: String,
uri: String,
- ) -> PhpResource {
- PhpResource::Stream(std::rc::Rc::new(std::cell::RefCell::new(StreamState {
+ ) -> StreamState {
+ StreamState {
backing,
readable,
writable,
@@ -489,6 +489,6 @@ impl StreamState {
closed: false,
mode,
uri,
- })))
+ }
}
}
diff --git a/crates/shirabe-php-shim/src/phar.rs b/crates/shirabe-php-shim/src/phar.rs
index 8217808..692d593 100644
--- a/crates/shirabe-php-shim/src/phar.rs
+++ b/crates/shirabe-php-shim/src/phar.rs
@@ -1,6 +1,3 @@
-use crate::PhpMixed;
-use indexmap::IndexMap;
-
#[derive(Debug)]
pub struct Phar {
path: String,
diff --git a/crates/shirabe-php-shim/src/preg.rs b/crates/shirabe-php-shim/src/preg.rs
index e5bd52e..4b43467 100644
--- a/crates/shirabe-php-shim/src/preg.rs
+++ b/crates/shirabe-php-shim/src/preg.rs
@@ -366,7 +366,7 @@ pub fn preg_split2(pattern: &str, subject: &str, limit: i64, flags: i64) -> Vec<
};
let mut result: Vec<String> = Vec::new();
- let mut push = |s: &str, result: &mut Vec<String>| {
+ let push = |s: &str, result: &mut Vec<String>| {
if !(no_empty && s.is_empty()) {
result.push(s.to_string());
}
diff --git a/crates/shirabe-php-shim/src/process.rs b/crates/shirabe-php-shim/src/process.rs
index 6999d99..ad6e1d5 100644
--- a/crates/shirabe-php-shim/src/process.rs
+++ b/crates/shirabe-php-shim/src/process.rs
@@ -253,13 +253,14 @@ pub fn proc_open(
2 => (ChildPipe::Err(child.stderr.take().unwrap()), true, false),
_ => unreachable!(),
};
- let resource = StreamState::new(
- StreamBacking::Pipe(pipe),
- readable,
- writable,
- mode,
- format!("pipe:fd{}", fd),
- );
+ let resource =
+ PhpResource::Stream(std::rc::Rc::new(std::cell::RefCell::new(StreamState::new(
+ StreamBacking::Pipe(pipe),
+ readable,
+ writable,
+ mode,
+ format!("pipe:fd{}", fd),
+ ))));
pipes.insert(fd, resource);
}
diff --git a/crates/shirabe-php-shim/src/rar.rs b/crates/shirabe-php-shim/src/rar.rs
index 8efce90..10c7e27 100644
--- a/crates/shirabe-php-shim/src/rar.rs
+++ b/crates/shirabe-php-shim/src/rar.rs
@@ -1,6 +1,3 @@
-use crate::PhpMixed;
-use indexmap::IndexMap;
-
#[derive(Debug)]
pub struct RarEntry;
diff --git a/crates/shirabe-php-shim/src/stream.rs b/crates/shirabe-php-shim/src/stream.rs
index 606b202..98f0322 100644
--- a/crates/shirabe-php-shim/src/stream.rs
+++ b/crates/shirabe-php-shim/src/stream.rs
@@ -346,12 +346,12 @@ pub fn stream_select(
// emit a warning for them. We skip them here, leaving them out of the ready set.
let mut prepare = |set: &mut FdSet, resources: &[PhpResource]| {
for resource in resources {
- if let Some(fd) = resource.raw_fd() {
- if (fd as usize) < FD_SETSIZE {
- set.set(fd);
- if fd + 1 > nfds {
- nfds = fd + 1;
- }
+ if let Some(fd) = resource.raw_fd()
+ && (fd as usize) < FD_SETSIZE
+ {
+ set.set(fd);
+ if fd + 1 > nfds {
+ nfds = fd + 1;
}
}
}
diff --git a/crates/shirabe-php-shim/src/string.rs b/crates/shirabe-php-shim/src/string.rs
index 9a82fe8..97c6695 100644
--- a/crates/shirabe-php-shim/src/string.rs
+++ b/crates/shirabe-php-shim/src/string.rs
@@ -333,10 +333,8 @@ fn natcmp_compare_right(a: &[u8], ap: &mut usize, b: &[u8], bp: &mut usize) -> i
if bias == 0 {
bias = -1;
}
- } else if ca > cb {
- if bias == 0 {
- bias = 1;
- }
+ } else if ca > cb && bias == 0 {
+ bias = 1;
}
*ap += 1;
*bp += 1;
@@ -613,14 +611,14 @@ pub fn rawurldecode(s: &str) -> String {
let mut out: Vec<u8> = Vec::with_capacity(bytes.len());
let mut i = 0;
while i < bytes.len() {
- if bytes[i] == b'%' && i + 2 < bytes.len() {
- if let (Some(h), Some(l)) =
+ if bytes[i] == b'%'
+ && i + 2 < bytes.len()
+ && let (Some(h), Some(l)) =
(hex_digit_value(bytes[i + 1]), hex_digit_value(bytes[i + 2]))
- {
- out.push((h << 4) | l);
- i += 3;
- continue;
- }
+ {
+ out.push((h << 4) | l);
+ i += 3;
+ continue;
}
out.push(bytes[i]);
i += 1;
diff --git a/crates/shirabe-php-shim/src/xml.rs b/crates/shirabe-php-shim/src/xml.rs
index 1a74edc..cc323ca 100644
--- a/crates/shirabe-php-shim/src/xml.rs
+++ b/crates/shirabe-php-shim/src/xml.rs
@@ -187,6 +187,10 @@ impl DOMNodeList {
self.0.len()
}
+ pub fn is_empty(&self) -> bool {
+ self.0.is_empty()
+ }
+
pub fn iter(&self) -> std::slice::Iter<'_, DOMNode> {
self.0.iter()
}
diff --git a/crates/shirabe-php-shim/src/zip.rs b/crates/shirabe-php-shim/src/zip.rs
index d1db9e5..8bb51d1 100644
--- a/crates/shirabe-php-shim/src/zip.rs
+++ b/crates/shirabe-php-shim/src/zip.rs
@@ -210,13 +210,15 @@ impl ZipArchive {
let mut file = archive.by_name(name).ok()?;
let mut buf = Vec::new();
std::io::Read::read_to_end(&mut file, &mut buf).ok()?;
- Some(StreamState::new(
- StreamBacking::Memory(std::io::Cursor::new(buf)),
- true,
- false,
- "r".to_string(),
- format!("zip://{}", name),
- ))
+ Some(crate::PhpResource::Stream(std::rc::Rc::new(
+ std::cell::RefCell::new(StreamState::new(
+ StreamBacking::Memory(std::io::Cursor::new(buf)),
+ true,
+ false,
+ "r".to_string(),
+ format!("zip://{}", name),
+ )),
+ )))
}
pub fn add_empty_dir(&self, local_name: &str) -> bool {
diff --git a/crates/shirabe-semver/src/semver.rs b/crates/shirabe-semver/src/semver.rs
index 9793fd8..4700ac4 100644
--- a/crates/shirabe-semver/src/semver.rs
+++ b/crates/shirabe-semver/src/semver.rs
@@ -3,7 +3,6 @@
use std::sync::OnceLock;
use crate::comparator::Comparator;
-use crate::constraint::AnyConstraint;
use crate::constraint::SimpleConstraint;
use crate::version_parser::VersionParser;
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) {
diff --git a/crates/shirabe/tests/autoload/autoload_generator_test.rs b/crates/shirabe/tests/autoload/autoload_generator_test.rs
index a3b833a..d5f16fb 100644
--- a/crates/shirabe/tests/autoload/autoload_generator_test.rs
+++ b/crates/shirabe/tests/autoload/autoload_generator_test.rs
@@ -1011,9 +1011,7 @@ fn test_psr_to_class_map_ignores_non_psr_classes() {
dump(&mut s, package.into(), true, "_1").unwrap();
assert!(std::path::Path::new(&format!("{}/autoload_classmap.php", composer_out)).exists());
- let expected = format!(
- "<?php\n\n// autoload_classmap.php @generated by Composer\n\n$vendorDir = dirname(__DIR__);\n$baseDir = dirname($vendorDir);\n\nreturn array(\n 'Composer\\\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',\n 'psr0_match' => $baseDir . '/psr0/psr0/match.php',\n 'psr4\\\\match' => $baseDir . '/psr4/match.php',\n);\n"
- );
+ let expected = "<?php\n\n// autoload_classmap.php @generated by Composer\n\n$vendorDir = dirname(__DIR__);\n$baseDir = dirname($vendorDir);\n\nreturn array(\n 'Composer\\\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',\n 'psr0_match' => $baseDir . '/psr0/psr0/match.php',\n 'psr4\\\\match' => $baseDir . '/psr4/match.php',\n);\n".to_string();
let actual =
std::fs::read_to_string(format!("{}/autoload_classmap.php", composer_out)).unwrap();
assert_eq!(expected, actual);
diff --git a/crates/shirabe/tests/command/base_dependency_command_test.rs b/crates/shirabe/tests/command/base_dependency_command_test.rs
index 697face..41ad362 100644
--- a/crates/shirabe/tests/command/base_dependency_command_test.rs
+++ b/crates/shirabe/tests/command/base_dependency_command_test.rs
@@ -263,8 +263,8 @@ fn test_warning_when_dependencies_are_not_installed() {
let some_dev_required_package = get_package("vendor2/package1", "1.0.0");
create_composer_lock(
- &[some_required_package.clone()],
- &[some_dev_required_package.clone()],
+ std::slice::from_ref(&some_required_package),
+ std::slice::from_ref(&some_dev_required_package),
);
let mut input: Vec<(PhpMixed, PhpMixed)> =
@@ -403,7 +403,7 @@ fn test_why_command_outputs() {
second_required_package.clone(),
third_required_package.clone(),
],
- &[some_dev_required_package.clone()],
+ std::slice::from_ref(&some_dev_required_package),
);
create_installed_json(
&[
@@ -411,7 +411,7 @@ fn test_why_command_outputs() {
second_required_package.clone(),
third_required_package.clone(),
],
- &[some_dev_required_package.clone()],
+ std::slice::from_ref(&some_dev_required_package),
true,
);
@@ -571,14 +571,14 @@ fn test_why_not_command_outputs() {
let second_dev_nested_required_package = get_package("vendor2/package3", "1.4.0");
create_composer_lock(
- &[some_required_package.clone()],
+ std::slice::from_ref(&some_required_package),
&[
first_dev_required_package.clone(),
second_dev_required_package.clone(),
],
);
create_installed_json(
- &[some_required_package.clone()],
+ std::slice::from_ref(&some_required_package),
&[
first_dev_required_package.clone(),
second_dev_required_package.clone(),
diff --git a/crates/shirabe/tests/command/global_command_test.rs b/crates/shirabe/tests/command/global_command_test.rs
index 6eec017..4d99613 100644
--- a/crates/shirabe/tests/command/global_command_test.rs
+++ b/crates/shirabe/tests/command/global_command_test.rs
@@ -287,7 +287,7 @@ fn test_global_update() {
let composer_home_str = tear_down.working_dir().to_string_lossy().to_string();
let pkg = get_package("vendor/pkg", "1.0.0");
- create_installed_json(&[pkg.clone()], &[], true);
+ create_installed_json(std::slice::from_ref(&pkg), &[], true);
create_composer_lock(&[pkg], &[]);
Platform::put_env("COMPOSER_HOME", &composer_home_str);
diff --git a/crates/shirabe/tests/command/init_command_test.rs b/crates/shirabe/tests/command/init_command_test.rs
index f8d3e26..efb3f49 100644
--- a/crates/shirabe/tests/command/init_command_test.rs
+++ b/crates/shirabe/tests/command/init_command_test.rs
@@ -602,7 +602,7 @@ fn test_format_authors() {
fn test_get_git_config() {
set_up();
- let mut command = InitCommand::new();
+ let command = InitCommand::new();
let git_config = command.__get_git_config();
assert!(git_config.contains_key("user.name"));
assert!(git_config.contains_key("user.email"));
diff --git a/crates/shirabe/tests/command/licenses_command_test.rs b/crates/shirabe/tests/command/licenses_command_test.rs
index 05bd7f6..5b25aad 100644
--- a/crates/shirabe/tests/command/licenses_command_test.rs
+++ b/crates/shirabe/tests/command/licenses_command_test.rs
@@ -190,7 +190,7 @@ fn test_format_summary() {
.unwrap();
assert_eq!(0, status_code);
- let expected = vec![
+ let expected = [
("-", "-"),
("License", "Number of dependencies"),
("-", "-"),
diff --git a/crates/shirabe/tests/command/remove_command_test.rs b/crates/shirabe/tests/command/remove_command_test.rs
index f645cc0..a27976a 100644
--- a/crates/shirabe/tests/command/remove_command_test.rs
+++ b/crates/shirabe/tests/command/remove_command_test.rs
@@ -282,7 +282,7 @@ fn test_remove_unused_package() {
let required_package = get_package("root/req", "1.0.0");
let extraneous_package = get_package("not/req", "1.0.0");
- create_installed_json(&[required_package.clone()], &[], true);
+ create_installed_json(std::slice::from_ref(&required_package), &[], true);
create_composer_lock(&[required_package.clone(), extraneous_package.clone()], &[]);
let mut app_tester = get_application_tester();
@@ -825,8 +825,8 @@ fn test_package_still_present_error_when_no_install_flag_used() {
);
let root_req_package = get_package("root/req", "1.0.0");
- create_installed_json(&[root_req_package.clone()], &[], true);
- create_composer_lock(&[root_req_package.clone()], &[]);
+ create_installed_json(std::slice::from_ref(&root_req_package), &[], true);
+ create_composer_lock(std::slice::from_ref(&root_req_package), &[]);
let mut app_tester = get_application_tester();
let status_code = app_tester
@@ -915,8 +915,8 @@ fn run_update_inherited_dependencies_flag_case(
let root_req_package = get_package("root/req", "1.0.0");
root_req_package.__set_type("metapackage".to_string());
- create_installed_json(&[root_req_package.clone()], &[], true);
- create_composer_lock(&[root_req_package.clone()], &[]);
+ create_installed_json(std::slice::from_ref(&root_req_package), &[], true);
+ create_composer_lock(std::slice::from_ref(&root_req_package), &[]);
let mut app_tester = get_application_tester();
let status_code = app_tester
diff --git a/crates/shirabe/tests/command/show_command_test.rs b/crates/shirabe/tests/command/show_command_test.rs
index a73992d..d5f0828 100644
--- a/crates/shirabe/tests/command/show_command_test.rs
+++ b/crates/shirabe/tests/command/show_command_test.rs
@@ -1218,7 +1218,7 @@ fn run_not_existing_package_case(package: &str, options: Vec<(&str, PhpMixed)>,
true,
);
let pkg = get_package("vendor/package", "1.0.0");
- create_installed_json(&[pkg.clone()], &[], true);
+ create_installed_json(std::slice::from_ref(&pkg), &[], true);
create_composer_lock(&[pkg], &[]);
let mut pairs = vec![
diff --git a/crates/shirabe/tests/command/suggests_command_test.rs b/crates/shirabe/tests/command/suggests_command_test.rs
index 8bbb950..e6732dc 100644
--- a/crates/shirabe/tests/command/suggests_command_test.rs
+++ b/crates/shirabe/tests/command/suggests_command_test.rs
@@ -237,14 +237,14 @@ vendor2/package2 suggests:
// 'with lockfile, show suggested (excluding dev)'
run_suggest_case(
true,
- &[no_dev.clone()],
+ std::slice::from_ref(&no_dev),
"vendor1/package1 suggests:
- vendor3/suggested: helpful for vendor1/package1
1 additional suggestions by transitive dependencies can be shown with --all",
);
// 'without lockfile, show suggested (excluding dev)'
- run_suggest_case(false, &[no_dev.clone()], basic);
+ run_suggest_case(false, std::slice::from_ref(&no_dev), basic);
let all_suggested = "vendor1/package1 suggests:
- vendor3/suggested: helpful for vendor1/package1
@@ -257,8 +257,8 @@ vendor5/dev-package suggests:
vendor6/package6 suggests:
- vendor7/transitive: helpful for vendor6/package6";
- run_suggest_case(true, &[all.clone()], all_suggested);
- run_suggest_case(false, &[all.clone()], all_suggested);
+ run_suggest_case(true, std::slice::from_ref(&all), all_suggested);
+ run_suggest_case(false, std::slice::from_ref(&all), all_suggested);
// 'with lockfile, show all suggested (excluding dev)'
run_suggest_case(
@@ -273,8 +273,8 @@ vendor6/package6 suggests:
run_suggest_case(false, &[all.clone(), no_dev.clone()], all_suggested);
// grouped by package
- run_suggest_case(true, &[by_package.clone()], basic);
- run_suggest_case(false, &[by_package.clone()], basic);
+ run_suggest_case(true, std::slice::from_ref(&by_package), basic);
+ run_suggest_case(false, std::slice::from_ref(&by_package), basic);
run_suggest_case(
true,
&[by_package.clone(), no_dev.clone()],
@@ -293,8 +293,16 @@ vendor4/dev-suggested is suggested by:
- vendor2/package2: helpful for vendor2/package2
2 additional suggestions by transitive dependencies can be shown with --all";
- run_suggest_case(true, &[by_suggestion.clone()], by_suggestion_out);
- run_suggest_case(false, &[by_suggestion.clone()], by_suggestion_out);
+ run_suggest_case(
+ true,
+ std::slice::from_ref(&by_suggestion),
+ by_suggestion_out,
+ );
+ run_suggest_case(
+ false,
+ std::slice::from_ref(&by_suggestion),
+ by_suggestion_out,
+ );
run_suggest_case(
true,
&[by_suggestion.clone(), no_dev.clone()],
@@ -367,8 +375,8 @@ vendor3/suggested is suggested by:
// list suggested
let list_out = "vendor3/suggested
vendor4/dev-suggested";
- run_suggest_case(true, &[list.clone()], list_out);
- run_suggest_case(false, &[list.clone()], list_out);
+ run_suggest_case(true, std::slice::from_ref(&list), list_out);
+ run_suggest_case(false, std::slice::from_ref(&list), list_out);
run_suggest_case(true, &[list.clone(), no_dev.clone()], "vendor3/suggested");
run_suggest_case(false, &[list.clone(), no_dev.clone()], list_out);
diff --git a/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs b/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs
index 87f02aa..0a6b0ca 100644
--- a/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs
+++ b/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs
@@ -38,13 +38,12 @@ fn load_package(
let mut id: Option<i64> = None;
// PHP: !empty($data['id'])
- if let Some(id_val) = data.get("id") {
- if let Some(i) = id_val.as_int() {
- if i != 0 {
- id = Some(i);
- data.shift_remove("id");
- }
- }
+ if let Some(id_val) = data.get("id")
+ && let Some(i) = id_val.as_int()
+ && i != 0
+ {
+ id = Some(i);
+ data.shift_remove("id");
}
let pkg = loader.load(data, None).unwrap();
@@ -267,10 +266,10 @@ fn get_package_result_set(
if let Some(source_reference) = package.get_source_reference() {
suffix = format!("#{}", source_reference);
}
- if let Some(repo) = package.get_repository() {
- if repo.is::<LockArrayRepository>() {
- suffix.push_str(" (locked)");
- }
+ if let Some(repo) = package.get_repository()
+ && repo.is::<LockArrayRepository>()
+ {
+ suffix.push_str(" (locked)");
}
if let Some(alias) = package.as_alias() {
@@ -460,18 +459,18 @@ fn run_test_pool_builder(
// PHP: foreach ($packageRepos as $packages)
for repo_entry in package_repos.as_list().unwrap() {
// PHP: isset($packages['type'])
- if let Some(repo_map) = repo_entry.as_array() {
- if repo_map.contains_key("type") {
- let repo = RepositoryFactory::create_repo(
- io.clone(),
- &config,
- repo_map.clone(),
- Some(&mut rm),
- )
- .unwrap();
- repository_set.add_repository(repo).unwrap();
- continue;
- }
+ if let Some(repo_map) = repo_entry.as_array()
+ && repo_map.contains_key("type")
+ {
+ let repo = RepositoryFactory::create_repo(
+ io.clone(),
+ &config,
+ repo_map.clone(),
+ Some(&mut rm),
+ )
+ .unwrap();
+ repository_set.add_repository(repo).unwrap();
+ continue;
}
let repo = ArrayRepository::new(vec![]).unwrap();
diff --git a/crates/shirabe/tests/dependency_resolver/pool_test.rs b/crates/shirabe/tests/dependency_resolver/pool_test.rs
index 2814aa6..b2bd0db 100644
--- a/crates/shirabe/tests/dependency_resolver/pool_test.rs
+++ b/crates/shirabe/tests/dependency_resolver/pool_test.rs
@@ -29,7 +29,7 @@ fn test_pool() {
let mut pool = create_pool(vec![package.clone()]);
assert!(same_packages(
- &[package.clone()],
+ std::slice::from_ref(&package),
&pool.what_provides("foo", None)
));
assert!(same_packages(&[package], &pool.what_provides("foo", None)));
diff --git a/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs b/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs
index 9bb939b..44013aa 100644
--- a/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs
+++ b/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs
@@ -63,7 +63,7 @@ fn test_foreach() {
rule_set_iterator.next();
}
- let expected = vec![
+ let expected = [
rules[&RuleSet::TYPE_REQUEST][0].clone(),
rules[&RuleSet::TYPE_REQUEST][1].clone(),
rules[&RuleSet::TYPE_LEARNED][0].clone(),
diff --git a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
index 978bcf7..9e048cf 100644
--- a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
+++ b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs
@@ -20,7 +20,7 @@ use shirabe::util::platform::Platform;
use shirabe::util::process_executor::{MockHandler, ProcessExecutor};
use shirabe_external_packages::symfony::console::output::output_interface;
-use shirabe_php_shim::{PHP_EOL, PhpMixed};
+use shirabe_php_shim::PHP_EOL;
use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd, get_process_executor_mock};
diff --git a/crates/shirabe/tests/installer/binary_installer_test.rs b/crates/shirabe/tests/installer/binary_installer_test.rs
index 48a6b6f..b26907d 100644
--- a/crates/shirabe/tests/installer/binary_installer_test.rs
+++ b/crates/shirabe/tests/installer/binary_installer_test.rs
@@ -104,7 +104,7 @@ fn run_install_and_exec_binary_with_full_compat(contents: &[u8]) {
let mut proc = ProcessExecutor::new(None);
let mut output = String::new();
- proc.execute(&format!("{}/binary arg", setup.bin_dir), &mut output, None)
+ proc.execute(format!("{}/binary arg", setup.bin_dir), &mut output, None)
.unwrap();
assert_eq!("", proc.get_error_output());
assert_eq!("success arg", output);
diff --git a/crates/shirabe/tests/installer/library_installer_test.rs b/crates/shirabe/tests/installer/library_installer_test.rs
index 2e4883e..0796efe 100644
--- a/crates/shirabe/tests/installer/library_installer_test.rs
+++ b/crates/shirabe/tests/installer/library_installer_test.rs
@@ -49,7 +49,7 @@ struct SetUp {
}
fn set_up() -> SetUp {
- let mut fs = Filesystem::new(None);
+ let fs = Filesystem::new(None);
let root = TempDir::new().unwrap();
let root_dir = fs::canonicalize(root.path())
diff --git a/crates/shirabe/tests/io/console_io_test.rs b/crates/shirabe/tests/io/console_io_test.rs
index f96aec1..9df851e 100644
--- a/crates/shirabe/tests/io/console_io_test.rs
+++ b/crates/shirabe/tests/io/console_io_test.rs
@@ -177,7 +177,7 @@ fn test_ask_and_validate() {
// PHP asserts the helper receives a Question with a validator. Behaviorally, an always-true
// validator passes the answer straight through.
let (console_io, _output) = make_console_io_with_answer("answer\n");
- let validator: Box<dyn Fn(PhpMixed) -> anyhow::Result<PhpMixed>> = Box::new(|value| Ok(value));
+ let validator: Box<dyn Fn(PhpMixed) -> anyhow::Result<PhpMixed>> = Box::new(Ok);
let result = console_io
.ask_and_validate(
"Why?".to_string(),
diff --git a/crates/shirabe/tests/package/loader/validating_array_loader_test.rs b/crates/shirabe/tests/package/loader/validating_array_loader_test.rs
index 2e614ee..2394af2 100644
--- a/crates/shirabe/tests/package/loader/validating_array_loader_test.rs
+++ b/crates/shirabe/tests/package/loader/validating_array_loader_test.rs
@@ -8,8 +8,7 @@ use shirabe::package::handle::PackageInterfaceHandle;
use shirabe::package::loader::{InvalidPackageException, LoaderInterface, ValidatingArrayLoader};
use shirabe_php_shim::PhpMixed;
-#[path = "../../common/test_case.rs"]
-mod test_case;
+use crate::test_case;
fn s(v: &str) -> PhpMixed {
PhpMixed::String(v.to_string())
@@ -1002,7 +1001,6 @@ fn test_load_warnings() {
fn test_load_skips_warning_data_when_ignoring_errors() {
for (mut cfg, _expected_warnings, must_check, expected_array) in warning_provider() {
if !must_check {
- assert!(true);
continue;
}
let (internal_loader, calls) = MockLoader::new();
diff --git a/crates/shirabe/tests/repository/array_repository_test.rs b/crates/shirabe/tests/repository/array_repository_test.rs
index 60bea16..1612b7c 100644
--- a/crates/shirabe/tests/repository/array_repository_test.rs
+++ b/crates/shirabe/tests/repository/array_repository_test.rs
@@ -49,7 +49,7 @@ fn reprs(results: &[SearchResult]) -> Vec<(String, Option<String>, Abandoned)> {
#[test]
fn test_add_package() {
- let mut repo = ArrayRepository::new(vec![]).unwrap();
+ let repo = ArrayRepository::new(vec![]).unwrap();
repo.add_package(get_package("foo", "1")).unwrap();
assert_eq!(1, repo.count().unwrap());
@@ -75,7 +75,7 @@ fn test_remove_package() {
#[test]
fn test_has_package() {
- let mut repo = ArrayRepository::new(vec![]).unwrap();
+ let repo = ArrayRepository::new(vec![]).unwrap();
repo.add_package(get_package("foo", "1")).unwrap();
repo.add_package(get_package("bar", "2")).unwrap();
@@ -102,7 +102,7 @@ fn test_find_packages() {
#[test]
#[ignore]
fn test_automatically_add_aliased_package_but_not_remove() {
- let mut repo = ArrayRepository::new(vec![]).unwrap();
+ let repo = ArrayRepository::new(vec![]).unwrap();
let package = get_package("foo", "1");
let alias = get_alias_package(&package, "2");
diff --git a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
index 1f9ae53..2e36833 100644
--- a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs
@@ -10,7 +10,7 @@ use shirabe::io::null_io::NullIO;
use shirabe::repository::vcs::ForgejoDriver;
use shirabe::util::filesystem::Filesystem;
use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler};
-use shirabe::util::process_executor::{MockHandler, ProcessExecutor};
+use shirabe::util::process_executor::MockHandler;
use shirabe_php_shim::PhpMixed;
use tempfile::TempDir;
diff --git a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
index e21835d..437617b 100644
--- a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
+++ b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs
@@ -12,9 +12,7 @@ use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler};
use shirabe::util::process_executor::{MockHandler, ProcessExecutor};
use shirabe_php_shim::{PhpMixed, extension_loaded};
-use crate::http_downloader_mock::{
- HttpDownloaderMockGuard, expect, expect_full, get_http_downloader_mock,
-};
+use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock};
use crate::process_executor_mock::{ProcessExecutorMockGuard, get_process_executor_mock};
// Mirrors GitLabDriverTest::setUp's `gitlab-domains` configuration.
diff --git a/crates/shirabe/tests/repository/vcs_repository_test.rs b/crates/shirabe/tests/repository/vcs_repository_test.rs
index 279db04..e3b0e84 100644
--- a/crates/shirabe/tests/repository/vcs_repository_test.rs
+++ b/crates/shirabe/tests/repository/vcs_repository_test.rs
@@ -26,10 +26,7 @@ struct SetUp {
// ref: VcsRepositoryTest::initialize. Builds a fixture git repository on disk by shelling out to
// git. Returns None when git is unavailable (mirroring markTestSkipped).
fn set_up() -> Option<SetUp> {
- if which_git().is_none() {
- // 'This test needs a git binary in the PATH to be able to run'
- return None;
- }
+ which_git()?;
let composer_home = TempDir::new().unwrap();
let git_repo = TempDir::new().unwrap();
diff --git a/crates/shirabe/tests/util/auth_helper_test.rs b/crates/shirabe/tests/util/auth_helper_test.rs
index 133fd75..b760fc8 100644
--- a/crates/shirabe/tests/util/auth_helper_test.rs
+++ b/crates/shirabe/tests/util/auth_helper_test.rs
@@ -470,7 +470,7 @@ fn expected_auth_setting(username: &str, password: &str) -> PhpMixed {
#[test]
fn test_store_auth_automatically() {
- let mut f = set_up();
+ let f = set_up();
let origin = "github.com";
expects_authentication(&f.io, origin, "my_username", "my_password");
@@ -497,7 +497,7 @@ fn test_store_auth_automatically() {
#[test]
fn test_store_auth_with_prompt_yes_answer() {
- let mut f = set_up();
+ let f = set_up();
let origin = "github.com";
expects_authentication(&f.io, origin, "my_username", "my_password");
let config_source_name = "https://api.gitlab.com/source";
@@ -536,7 +536,7 @@ fn test_store_auth_with_prompt_yes_answer() {
#[test]
fn test_store_auth_with_prompt_no_answer() {
- let mut f = set_up();
+ let f = set_up();
let origin = "github.com";
let config_source_name = "https://api.gitlab.com/source";
diff --git a/crates/shirabe/tests/util/filesystem_test.rs b/crates/shirabe/tests/util/filesystem_test.rs
index e0bb46b..2e160e8 100644
--- a/crates/shirabe/tests/util/filesystem_test.rs
+++ b/crates/shirabe/tests/util/filesystem_test.rs
@@ -5,9 +5,7 @@
// place of TestCase::getUniqueTmpDirectory, which is not ported.
use shirabe::util::filesystem::Filesystem;
use shirabe::util::platform::Platform;
-use shirabe_php_shim::{
- dirname, file_exists, file_put_contents, is_dir, is_file, mkdir, symlink, touch,
-};
+use shirabe_php_shim::{file_exists, file_put_contents, is_dir, mkdir, symlink, touch};
// PHP's setUp/tearDown build workingDir/testFile under TestCase::getUniqueTmpDirectory; the
// on-disk tests below instead create their own tempfile::TempDir inline, so no shared fixture
diff --git a/crates/shirabe/tests/util/gitlab_test.rs b/crates/shirabe/tests/util/gitlab_test.rs
index 5a91415..ebf7c08 100644
--- a/crates/shirabe/tests/util/gitlab_test.rs
+++ b/crates/shirabe/tests/util/gitlab_test.rs
@@ -7,7 +7,7 @@ use shirabe::config::{Config, ConfigSourceInterface};
use shirabe::io::IOInterface;
use shirabe::io::io_interface;
use shirabe::util::GitLab;
-use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler};
+use shirabe::util::http_downloader::HttpDownloaderMockHandler;
use shirabe_php_shim::PhpMixed;
use crate::config_stub::ConfigStubBuilder;
diff --git a/crates/shirabe/tests/util/perforce_test.rs b/crates/shirabe/tests/util/perforce_test.rs
index 4f3cb58..482094f 100644
--- a/crates/shirabe/tests/util/perforce_test.rs
+++ b/crates/shirabe/tests/util/perforce_test.rs
@@ -8,7 +8,7 @@ use serial_test::serial;
use shirabe::io::{IOInterface, NullIO};
use shirabe::util::Perforce;
use shirabe::util::filesystem::Filesystem;
-use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor};
+use shirabe::util::process_executor::{MockHandler, ProcessExecutor};
use shirabe_php_shim::PhpMixed;
use crate::io_stub::IOStub;
diff --git a/crates/shirabe/tests/util/stream_context_factory_test.rs b/crates/shirabe/tests/util/stream_context_factory_test.rs
index ad123aa..284077b 100644
--- a/crates/shirabe/tests/util/stream_context_factory_test.rs
+++ b/crates/shirabe/tests/util/stream_context_factory_test.rs
@@ -324,16 +324,16 @@ fn test_ssl_proxy() {
)]);
assert_eq!(expected_options, options);
} else {
- match StreamContextFactory::get_context(
- "http://example.org",
- IndexMap::new(),
- IndexMap::new(),
- ) {
- // The catch in PHP asserts the exception is a TransportException; the return type
- // here already guarantees that.
- Ok(_) => panic!(),
- Err(_) => {}
- }
+ // The catch in PHP asserts the exception is a TransportException; the return type
+ // here already guarantees that.
+ assert!(
+ StreamContextFactory::get_context(
+ "http://example.org",
+ IndexMap::new(),
+ IndexMap::new(),
+ )
+ .is_err()
+ );
}
}
}
@@ -351,7 +351,7 @@ fn test_ensure_thatfix_http_header_field_moves_content_type_to_end_of_options()
),
)]),
)]);
- let expected_header = vec![
+ let expected_header = [
s("User-agent: foo"),
s("X-Foo: bar"),
s("Authorization: Basic aW52YWxpZA=="),