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/installer/project_installer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/shirabe/src/installer/project_installer.rs') diff --git a/crates/shirabe/src/installer/project_installer.rs b/crates/shirabe/src/installer/project_installer.rs index 351fd35..83ffbb2 100644 --- a/crates/shirabe/src/installer/project_installer.rs +++ b/crates/shirabe/src/installer/project_installer.rs @@ -1,6 +1,6 @@ //! ref: composer/src/Composer/Installer/ProjectInstaller.php -use crate::downloader::DownloadManager; +use crate::downloader::DownloadManagerInterface; use crate::installer::InstallerInterface; use crate::package::PackageInterfaceHandle; use crate::repository::InstalledRepositoryInterface; @@ -10,14 +10,14 @@ use shirabe_php_shim::{InvalidArgumentException, PhpMixed}; #[derive(Debug)] pub struct ProjectInstaller { install_path: String, - download_manager: std::rc::Rc>, + download_manager: std::rc::Rc>, filesystem: std::rc::Rc>, } impl ProjectInstaller { pub fn new( install_path: &str, - dm: std::rc::Rc>, + dm: std::rc::Rc>, fs: std::rc::Rc>, ) -> Self { let install_path = format!("{}/", install_path.replace('\\', "/").trim_end_matches('/')); -- cgit v1.3.1