From 2d474e91e49c7343d28198eff2b5bbbed9afbcee Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 10 Jun 2026 02:41:34 +0900 Subject: feat(phase-c): resolve cross-module phase-b TODOs --- crates/shirabe/src/command/audit_command.rs | 2 +- crates/shirabe/src/command/base_command.rs | 5 +-- .../shirabe/src/command/base_dependency_command.rs | 11 +++--- .../shirabe/src/command/create_project_command.rs | 18 ++------- .../shirabe/src/command/package_discovery_trait.rs | 8 ++-- crates/shirabe/src/command/remove_command.rs | 8 ++-- crates/shirabe/src/command/require_command.rs | 11 ++++-- crates/shirabe/src/command/script_alias_command.rs | 4 +- crates/shirabe/src/command/show_command.rs | 12 +++--- crates/shirabe/src/command/update_command.rs | 44 +++++++++++----------- 10 files changed, 59 insertions(+), 64 deletions(-) (limited to 'crates/shirabe/src/command') diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs index 20532f1..0e050cc 100644 --- a/crates/shirabe/src/command/audit_command.rs +++ b/crates/shirabe/src/command/audit_command.rs @@ -181,7 +181,7 @@ impl AuditCommand { } let _root_pkg = composer.get_package(); - // TODO(phase-b): InstalledRepository::new expects Vec>, but + // TODO(phase-c): InstalledRepository::new expects Vec>, but // get_local_repository returns &dyn InstalledRepositoryInterface. Conversion requires // either cloning into a Box or restructuring InstalledRepository constructor. let _ = RepositoryUtils::filter_required_packages; diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs index c98bc2b..b1a1837 100644 --- a/crates/shirabe/src/command/base_command.rs +++ b/crates/shirabe/src/command/base_command.rs @@ -511,9 +511,8 @@ impl BaseCommand for C { } else { crate::factory::DisablePlugins::None }; - // TODO(phase-b): Option> -> Option conversion - let _ = config; - Factory::create(io, None, disable_plugins_kind, disable_scripts).map(|c| c.upcast()) + let config = config.map(crate::factory::LocalConfigInput::Data); + Factory::create(io, config, disable_plugins_kind, disable_scripts).map(|c| c.upcast()) } fn get_preferred_install_options( diff --git a/crates/shirabe/src/command/base_dependency_command.rs b/crates/shirabe/src/command/base_dependency_command.rs index 9317b31..decfd5b 100644 --- a/crates/shirabe/src/command/base_dependency_command.rs +++ b/crates/shirabe/src/command/base_dependency_command.rs @@ -106,17 +106,18 @@ pub trait BaseDependencyCommand: BaseCommand { repos.push(local_repo); - let platform_overrides = composer + let platform_overrides: IndexMap = composer .get_config() .borrow() .get("platform") .as_array() .cloned() - .unwrap_or_default(); - // TODO(phase-b): platform_overrides type adjustment; using empty for now - let _ = platform_overrides; + .unwrap_or_default() + .into_iter() + .map(|(k, v)| (k, *v)) + .collect(); repos.push(crate::repository::RepositoryInterfaceHandle::new( - PlatformRepository::new(vec![], IndexMap::new())?, + PlatformRepository::new(vec![], platform_overrides)?, )); } diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index c49d2fc..bf00371 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -293,7 +293,7 @@ impl CreateProjectCommand { io.clone(), &config, package_name, - &*platform_requirement_filter, + platform_requirement_filter.clone(), directory.clone(), package_version, stability, @@ -334,17 +334,10 @@ impl CreateProjectCommand { .get_config() .borrow() .get_repositories(); - // TODO(phase-b): generate_repository_name expects existing repos as - // IndexMap>; pass empty placeholder. - let _ = &composer_json_repositories_config; - let placeholder_existing: IndexMap< - String, - crate::repository::RepositoryInterfaceHandle, - > = IndexMap::new(); let name = RepositoryFactory::generate_repository_name( &PhpMixed::Int(index as i64), &repo_config, - &placeholder_existing, + &composer_json_repositories_config, ); let mut config_source = JsonConfigSource::new( std::rc::Rc::new(std::cell::RefCell::new(JsonFile::new( @@ -595,7 +588,7 @@ impl CreateProjectCommand { io: std::rc::Rc>, config: &std::rc::Rc>, package_name: &str, - platform_requirement_filter: &dyn PlatformRequirementFilterInterface, + platform_requirement_filter: std::rc::Rc, directory: Option, mut package_version: Option, mut stability: Option, @@ -850,14 +843,11 @@ impl CreateProjectCommand { std::rc::Rc::new(std::cell::RefCell::new(repository_set)), Some(&mut platform_repo), )?; - // TODO(phase-b): platform_requirement_filter is &dyn here but VersionSelector expects - // Option>; pass None as placeholder. - let _ = platform_requirement_filter; let package = version_selector.find_best_candidate( &name, package_version.as_deref(), &stability, - None, + Some(platform_requirement_filter.clone()), 0, Some(io.clone()), PhpMixed::Bool(true), diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs index 32e5e21..b5e6cd5 100644 --- a/crates/shirabe/src/command/package_discovery_trait.rs +++ b/crates/shirabe/src/command/package_discovery_trait.rs @@ -852,7 +852,6 @@ pub trait PackageDiscoveryTrait { let installed_repo = repository_manager.get_local_repository(); for result in &results { - // TODO(phase-b): installed_repo.find_package signature mismatch with FindPackageConstraint if installed_repo .find_package( &result.name, @@ -929,11 +928,14 @@ pub trait PackageDiscoveryTrait { let has_config_platform = platform_extra.contains_key("config.platform"); let is_complete = platform_pkg.as_complete().is_some(); if has_config_platform && is_complete { - // TODO(phase-b): platform_pkg.get_description() via CompletePackageInterface platform_pkg_version = format!( "{} ({})", platform_pkg_version, - todo!("platform_pkg.get_description()") + platform_pkg + .as_complete() + .unwrap() + .get_description() + .unwrap_or_default() ); } details.push(format!( diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs index 1857b17..6cd2424 100644 --- a/crates/shirabe/src/command/remove_command.rs +++ b/crates/shirabe/src/command/remove_command.rs @@ -14,6 +14,7 @@ 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::installer::Installer; use crate::io::IOInterface; @@ -597,7 +598,7 @@ impl RemoveCommand { .unwrap_or(false); let mut update_allow_transitive_dependencies = - Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE; + UpdateAllowTransitiveDeps::UpdateListedWithTransitiveDepsNoRootRequire; let mut flags = String::new(); if input .borrow() @@ -610,7 +611,8 @@ impl RemoveCommand { .as_bool() .unwrap_or(false) { - update_allow_transitive_dependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS; + update_allow_transitive_dependencies = + UpdateAllowTransitiveDeps::UpdateListedWithTransitiveDeps; flags += " --with-all-dependencies"; } else if input .borrow() @@ -618,7 +620,7 @@ impl RemoveCommand { .as_bool() .unwrap_or(false) { - update_allow_transitive_dependencies = Request::UPDATE_ONLY_LISTED; + update_allow_transitive_dependencies = UpdateAllowTransitiveDeps::UpdateOnlyListed; flags += " --with-dependencies"; } diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 7fa4793..44ab921 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -20,6 +20,7 @@ use crate::composer::PartialComposerHandle; 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::installer::Installer; use crate::installer::InstallerEvents; @@ -848,7 +849,7 @@ impl RequireCommand { .as_bool() .unwrap_or(false); - let mut update_allow_transitive_dependencies = Request::UPDATE_ONLY_LISTED; + let mut update_allow_transitive_dependencies = UpdateAllowTransitiveDeps::UpdateOnlyListed; let mut flags = String::new(); if input .borrow() @@ -861,7 +862,8 @@ impl RequireCommand { .as_bool() .unwrap_or(false) { - update_allow_transitive_dependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS; + update_allow_transitive_dependencies = + UpdateAllowTransitiveDeps::UpdateListedWithTransitiveDeps; flags += " --with-all-dependencies"; } else if input .borrow() @@ -875,7 +877,7 @@ impl RequireCommand { .unwrap_or(false) { update_allow_transitive_dependencies = - Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE; + UpdateAllowTransitiveDeps::UpdateListedWithTransitiveDepsNoRootRequire; flags += " --with-dependencies"; } @@ -1135,7 +1137,8 @@ impl RequireCommand { IndexMap::new(), ); let stability_flags_clone = stability_flags.clone(); - // TODO(phase-b): get_locker_mut needs update_hash with stability flags rewriter. + // TODO(phase-c): Locker::update_hash needs the stability-flags rewriter callback; + // depends on modeling the closure passed to updateHash. let _ = &stability_flags_clone; todo!("update locker hash with stability flags rewriter"); } diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs index 50e7e80..ef95c7e 100644 --- a/crates/shirabe/src/command/script_alias_command.rs +++ b/crates/shirabe/src/command/script_alias_command.rs @@ -103,7 +103,7 @@ impl ScriptAliasCommand { let args = input.borrow().get_arguments(); - // TODO(phase-b): InputInterface has_to_string/get_class_name not modeled in Rust + // TODO(phase-c): InputInterface has_to_string/get_class_name not modeled in Rust // TODO remove for Symfony 6+ as it is then in the interface if false { return Err(LogicException { @@ -122,7 +122,7 @@ impl ScriptAliasCommand { Platform::put_env("COMPOSER_DEV_MODE", if dev_mode { "1" } else { "0" }); - // TODO(phase-b): InputInterface lacks to_string; use a placeholder + // TODO(phase-c): InputInterface lacks to_string; use a placeholder until it is modeled. let input_as_string = String::new(); let _ = input; let script_alias_input = Preg::replace4(r"{^\S+ ?}", "", &input_as_string, 1)?; diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index 1ce91cb..3761b09 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -610,7 +610,7 @@ impl ShowCommand { .get_option("patch-only") .as_bool() .unwrap_or(false), - &*platform_req_filter, + platform_req_filter.clone(), )?; } if input.borrow().get_option("outdated").as_bool() == Some(true) @@ -885,7 +885,7 @@ impl ShowCommand { show_major_only, show_minor_only, show_patch_only, - &*platform_req_filter, + platform_req_filter.clone(), )?; if latest.is_none() { continue; @@ -2639,7 +2639,7 @@ impl ShowCommand { major_only: bool, minor_only: bool, patch_only: bool, - platform_req_filter: &dyn PlatformRequirementFilterInterface, + platform_req_filter: std::rc::Rc, ) -> anyhow::Result> { // find the latest version allowed in this repo set let name = package.get_name(); @@ -2738,14 +2738,14 @@ impl ShowCommand { version_compare(&candidate.get_version(), &package_version, "<=") }); } - // TODO(phase-b): platform_req_filter needs to be Option>; current code holds &dyn. - let _ = platform_req_filter; + // 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; let mut candidate = version_selector.find_best_candidate( &name, target_version.as_deref(), &best_stability, - None, + Some(platform_req_filter), 0, Some(self.get_io().clone()), PhpMixed::Bool(true), diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index 751203c..eb618ca 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -49,7 +49,8 @@ impl UpdateCommand { .set_name("update") .set_aliases(&["u".to_string(), "upgrade".to_string()]) .set_description("Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file") - // TODO(phase-b): set_definition with InputArgument/InputOption (see PHP UpdateCommand) + // TODO(phase-c): populate with InputArgument/InputOption entries (see PHP UpdateCommand); + // blocked on the symfony InputDefinition entry modeling. .set_definition(&[]) .set_help( "The update command reads the composer.json file from the\n\ @@ -227,15 +228,10 @@ impl UpdateCommand { "~{}", matches.get(1).cloned().unwrap_or_default() ))?; - if temporary_constraints.contains_key(&package.get_name()) { - let existing = temporary_constraints - .get(&package.get_name()) - .map(|c| c.clone()) - .unwrap(); + if let Some(existing) = temporary_constraints.get(&package.get_name()) { temporary_constraints.insert( package.get_name(), - // TODO(phase-b): MultiConstraint::create signature - todo!("MultiConstraint::create([existing, constraint], true)"), + MultiConstraint::create(vec![existing.clone(), constraint], true, None)?, ); } else { temporary_constraints.insert(package.get_name(), constraint); @@ -376,14 +372,15 @@ impl UpdateCommand { .as_bool() .unwrap_or(false); - let mut update_allow_transitive_dependencies: i64 = Request::UPDATE_ONLY_LISTED; + let mut update_allow_transitive_dependencies = UpdateAllowTransitiveDeps::UpdateOnlyListed; if input .borrow() .get_option("with-all-dependencies") .as_bool() .unwrap_or(false) { - update_allow_transitive_dependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS; + update_allow_transitive_dependencies = + UpdateAllowTransitiveDeps::UpdateListedWithTransitiveDeps; } else if input .borrow() .get_option("with-dependencies") @@ -391,10 +388,8 @@ impl UpdateCommand { .unwrap_or(false) { update_allow_transitive_dependencies = - Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE; + UpdateAllowTransitiveDeps::UpdateListedWithTransitiveDepsNoRootRequire; } - // Keep `UpdateAllowTransitiveDeps` import alive while still using i64 for the setter. - let _ = UpdateAllowTransitiveDeps::UpdateOnlyListed; install .set_dry_run( @@ -456,13 +451,7 @@ impl UpdateCommand { .as_bool() .unwrap_or(false), ) - // TODO(phase-b): VersionParser::parse_constraints returns Arc but - // Installer::set_temporary_constraints expects IndexMap>; - // bridge the constraint storage types later. - .set_temporary_constraints({ - let _ = &temporary_constraints; - IndexMap::new() - }) + .set_temporary_constraints(temporary_constraints) .set_audit_config( self.create_audit_config(&mut *composer.get_config().borrow_mut(), input.clone())?, ) @@ -548,7 +537,6 @@ impl UpdateCommand { ); let filter: Option = if packages.len() > 0 { - // TODO(phase-b): base_package::package_names_to_regexp signature Some(base_package::package_names_to_regexp(&packages, "%s")) } else { None @@ -682,11 +670,21 @@ impl UpdateCommand { fn create_version_selector(&self, composer: &PartialComposerHandle) -> Result { let composer = crate::command::composer_full(composer); + let root_aliases: Vec = composer + .get_package() + .get_aliases() + .into_iter() + .map(|alias| crate::repository::RootAliasInput { + package: alias.get("package").cloned().unwrap_or_default(), + version: alias.get("version").cloned().unwrap_or_default(), + alias: alias.get("alias").cloned().unwrap_or_default(), + alias_normalized: alias.get("alias_normalized").cloned().unwrap_or_default(), + }) + .collect(); let mut repository_set = RepositorySet::new( &composer.get_package().get_minimum_stability(), composer.get_package().get_stability_flags().clone(), - // TODO(phase-b): collect root aliases from composer.get_package().get_aliases() - Vec::new(), + root_aliases, composer.get_package().get_references().clone(), IndexMap::new(), IndexMap::new(), -- cgit v1.3.1