diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-25 00:58:20 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-25 00:58:36 +0900 |
| commit | 1921f173ea219cb4b25847294d2d3fa465550fbb (patch) | |
| tree | 0d30486a2cb9a0c106e5d5827be3f655c60cd871 /crates/shirabe/src/package/loader/root_package_loader.rs | |
| parent | dbdecaf5a1c54a876b7ee0153d58dd39b1080f97 (diff) | |
| download | php-shirabe-1921f173ea219cb4b25847294d2d3fa465550fbb.tar.gz php-shirabe-1921f173ea219cb4b25847294d2d3fa465550fbb.tar.zst php-shirabe-1921f173ea219cb4b25847294d2d3fa465550fbb.zip | |
refactor(package): introduce Rc<RefCell<_>> handles for packages
PHP packages have reference semantics, so introduce shared-ownership
handles over an AnyPackage enum (PackageInterfaceHandle and friends)
and replace Box<dyn PackageInterface> throughout.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package/loader/root_package_loader.rs')
| -rw-r--r-- | crates/shirabe/src/package/loader/root_package_loader.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs index 3cdaaa7..e235e31 100644 --- a/crates/shirabe/src/package/loader/root_package_loader.rs +++ b/crates/shirabe/src/package/loader/root_package_loader.rs @@ -66,7 +66,7 @@ impl RootPackageLoader { config: IndexMap<String, Box<shirabe_php_shim::PhpMixed>>, class: &str, cwd: Option<&str>, - ) -> anyhow::Result<Box<dyn PackageInterface>> { + ) -> anyhow::Result<crate::package::PackageInterfaceHandle> { if class != "Composer\\Package\\RootPackage" { shirabe_php_shim::trigger_error( "The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.", @@ -193,11 +193,14 @@ impl RootPackageLoader { Some("Composer\\Package\\RootPackage".to_string()), )?; - // TODO(phase-b): as_any_mut is not available on BasePackage; downcast via Any is not - // possible without it. Skipping real downcast and using todo!() placeholder. + // TODO(phase-c): mutating the loaded RootPackage through a PackageInterfaceHandle + // requires going through as_root_package() + a RefCell borrow; the inherent + // RootPackage mutators used below are not yet reachable that way. let real_package: &mut RootPackage = { let _ = &mut package; - todo!("downcast Box<dyn BasePackage> to &mut RootPackage requires as_any_mut on trait") + todo!( + "mutate RootPackage through PackageInterfaceHandle (as_root_package + borrow_mut)" + ) }; if auto_versioned { |
