aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/dump_autoload_command.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-06 20:18:43 +0900
committernsfisis <nsfisis@gmail.com>2026-06-06 20:18:43 +0900
commit66bcf2d099a14c718931be9c9426629bc5b94e6e (patch)
tree866986f33bb5f3614c8334aa2ecc0e95f4ad1759 /crates/shirabe/src/command/dump_autoload_command.rs
parent87f7f1b0f875e9cf26b84bd45dd48226a33749cb (diff)
downloadphp-shirabe-66bcf2d099a14c718931be9c9426629bc5b94e6e.tar.gz
php-shirabe-66bcf2d099a14c718931be9c9426629bc5b94e6e.tar.zst
php-shirabe-66bcf2d099a14c718931be9c9426629bc5b94e6e.zip
feat(dump-autoload-command): wire up install path check and dump call
Resolve the two phase-b borrow-conflict TODOs by cloning each Composer subsystem handle out before borrowing, so the missing-dependency loop and AutoloadGenerator::dump can hold their independent RefCell borrows. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/dump_autoload_command.rs')
-rw-r--r--crates/shirabe/src/command/dump_autoload_command.rs53
1 files changed, 43 insertions, 10 deletions
diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs
index 0f229d0..011fc56 100644
--- a/crates/shirabe/src/command/dump_autoload_command.rs
+++ b/crates/shirabe/src/command/dump_autoload_command.rs
@@ -67,13 +67,15 @@ impl DumpAutoloadCommand {
let mut missing_dependencies = false;
{
- let repository_manager = composer.get_repository_manager().clone();
- let repository_manager = repository_manager.borrow();
- let local_repo = repository_manager.get_local_repository();
- for local_pkg in local_repo.get_canonical_packages() {
- // TODO(phase-b): get_install_path takes &mut self on installation_manager which conflicts with the &local_repo borrow held by this loop; needs shared-ownership refactor
- let install_path: Option<String> =
- todo!("InstallationManager::get_install_path requires &mut self");
+ let local_repo = composer
+ .get_repository_manager()
+ .borrow()
+ .get_local_repository();
+ for local_pkg in local_repo.get_canonical_packages()? {
+ let install_path = composer
+ .get_installation_manager()
+ .borrow_mut()
+ .get_install_path(local_pkg);
if install_path.as_deref().is_some_and(|p| !file_exists(p)) {
missing_dependencies = true;
self.get_io().write("<warning>Not all dependencies are installed. Make sure to run a \"composer install\" to install missing dependencies</warning>");
@@ -214,9 +216,40 @@ impl DumpAutoloadCommand {
.get_autoload_generator()
.borrow_mut()
.set_platform_requirement_filter(platform_requirement_filter);
- // TODO(phase-b): dump requires multiple borrows of composer simultaneously (autoload generator mut, repository, package, installation manager, locker); needs shared-ownership refactor
- let class_map: shirabe_class_map_generator::class_map::ClassMap =
- todo!("AutoloadGenerator::dump requires concurrent borrows of Composer subsystems");
+ let strict_ambiguous = input
+ .borrow()
+ .get_option("strict-ambiguous")
+ .as_bool()
+ .unwrap_or(false);
+
+ let local_repo_handle = composer
+ .get_repository_manager()
+ .borrow()
+ .get_local_repository();
+ let package = composer.get_package().clone();
+ let installation_manager = composer.get_installation_manager();
+ let locker = composer.get_locker();
+ let autoload_generator = composer.get_autoload_generator();
+
+ let config_ref = config.borrow();
+ let mut local_repo_ref = local_repo_handle.borrow_mut();
+ let local_repo = local_repo_ref
+ .as_installed_repository_interface_mut()
+ .expect("local repository must be an InstalledRepositoryInterface");
+ let mut installation_manager_ref = installation_manager.borrow_mut();
+ let mut locker_ref = locker.borrow_mut();
+
+ let class_map = autoload_generator.borrow_mut().dump(
+ &config_ref,
+ local_repo,
+ package,
+ &mut *installation_manager_ref,
+ "composer",
+ optimize,
+ None,
+ Some(&mut *locker_ref),
+ strict_ambiguous,
+ )?;
let number_of_classes = class_map.map.len();
if authoritative {