From 901878ee3f2bee6605b02d321cc4c92bc32fd5b0 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 27 Jun 2026 08:44:57 +0900 Subject: refactor(composer): hold managers behind *Interface traits Composer/PartialComposer exposed its RepositoryManager, InstallationManager, EventDispatcher, Locker, DownloadManager, AutoloadGenerator and ArchiveManager as concrete types, but Composer's public setters (setDownloadManager() etc.) let plugins swap in subclasses. Introduce a *Interface trait per manager and store each as Rc> so a replacement is honored. Only Composer's slots and the sinks fed from its accessors become trait objects; managers injected concretely at construction keep their concrete references, matching PHP semantics. Fluent setters on the affected classes now return () and Locker::update_hash is de-generified to a boxed FnOnce so the traits stay object-safe. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/command/diagnose_command.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/shirabe/src/command/diagnose_command.rs') diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index 37009fb..68aec20 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -34,7 +34,7 @@ use crate::io::IOInterfaceImmutable; use crate::io::NullIO; use crate::json::JsonFile; use crate::json::JsonValidationException; -use crate::package::Locker; +use crate::package::LockerInterface; use crate::package::RootPackage; use crate::package::version::VersionParser; use crate::plugin::CommandEvent; @@ -284,7 +284,7 @@ impl Command for DiagnoseCommand { io.write_no_newline("Checking composer.lock: "); let locker = c.get_locker().clone(); let locker = locker.borrow(); - let r = self.check_composer_lock_schema(&locker)?; + let r = self.check_composer_lock_schema(&*locker)?; self.output_result(r); } } @@ -487,7 +487,7 @@ impl DiagnoseCommand { Ok(PhpMixed::Bool(true)) } - fn check_composer_lock_schema(&self, locker: &Locker) -> anyhow::Result { + fn check_composer_lock_schema(&self, locker: &dyn LockerInterface) -> anyhow::Result { let json = locker.get_json_file(); match json.validate_schema(JsonFile::LOCK_SCHEMA, None) { -- cgit v1.3.1