aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package/locker.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-27 00:49:33 +0900
committernsfisis <nsfisis@gmail.com>2026-05-27 00:54:09 +0900
commitcc5d73c05a0abca2eebcc8a6afa0b1543ee49850 (patch)
tree091a0d01232d927f13f3ab22700701804980f231 /crates/shirabe/src/package/locker.rs
parentc5850d62beabef0a6bcc4cf6a179589c0ba8f405 (diff)
downloadphp-shirabe-cc5d73c05a0abca2eebcc8a6afa0b1543ee49850.tar.gz
php-shirabe-cc5d73c05a0abca2eebcc8a6afa0b1543ee49850.tar.zst
php-shirabe-cc5d73c05a0abca2eebcc8a6afa0b1543ee49850.zip
refactor(package): pass package handles by value throughout
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package/locker.rs')
-rw-r--r--crates/shirabe/src/package/locker.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs
index 8ba2cc2..e5eed78 100644
--- a/crates/shirabe/src/package/locker.rs
+++ b/crates/shirabe/src/package/locker.rs
@@ -20,7 +20,7 @@ use crate::package::CompleteAliasPackage;
use crate::package::Link;
use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
-use crate::package::RootPackageInterface;
+use crate::package::RootPackageInterfaceHandle;
use crate::package::dumper::ArrayDumper;
use crate::package::loader::ArrayLoader;
use crate::package::loader::LoaderInterface;
@@ -766,9 +766,7 @@ impl Locker {
.into());
}
- let mut spec = self
- .dumper
- .dump(package.as_rc().borrow().as_package_interface());
+ let mut spec = self.dumper.dump(package.clone());
spec.shift_remove("version_normalized");
// always move time to the end of the package definition
@@ -778,8 +776,7 @@ impl Locker {
&& package.get_installation_source() == Some("source".to_string())
{
// use the exact commit time of the current reference if it's a dev package
- let pkg_time =
- self.get_package_time(package.as_rc().borrow().as_package_interface())?;
+ let pkg_time = self.get_package_time(package.clone())?;
pkg_time.map(PhpMixed::String).or(time)
} else {
time
@@ -823,7 +820,7 @@ impl Locker {
}
/// Returns the packages's datetime for its source reference.
- fn get_package_time(&mut self, package: &dyn PackageInterface) -> Result<Option<String>> {
+ fn get_package_time(&mut self, package: PackageInterfaceHandle) -> Result<Option<String>> {
if !function_exists("proc_open") {
return Ok(None);
}
@@ -831,7 +828,7 @@ impl Locker {
let path = self
.installation_manager
.borrow_mut()
- .get_install_path(package);
+ .get_install_path(package.clone());
if path.is_none() {
return Ok(None);
}
@@ -841,7 +838,7 @@ impl Locker {
if path.is_some()
&& in_array(
- PhpMixed::String(source_type.unwrap_or("").to_string()),
+ PhpMixed::String(source_type.clone().unwrap_or_default()),
&PhpMixed::List(vec![
Box::new(PhpMixed::String("git".to_string())),
Box::new(PhpMixed::String("hg".to_string())),
@@ -852,9 +849,8 @@ impl Locker {
let source_ref = package
.get_source_reference()
.or_else(|| package.get_dist_reference())
- .unwrap_or("")
- .to_string();
- match source_type.unwrap_or("") {
+ .unwrap_or_default();
+ match source_type.as_deref().unwrap_or("") {
"git" => {
GitUtil::clean_env(&self.process);
@@ -934,7 +930,7 @@ impl Locker {
/// @return array<string>
pub fn get_missing_requirement_info(
&mut self,
- package: &dyn RootPackageInterface,
+ package: RootPackageInterfaceHandle,
include_dev: bool,
) -> Result<Vec<String>> {
let mut missing_requirement_info: Vec<String> = vec![];