aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/config
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-20 08:33:49 +0900
committernsfisis <nsfisis@gmail.com>2026-05-20 08:33:57 +0900
commitf31b101ce1e921a026ba234b1f0a83b0392bc118 (patch)
treeb7ac2aa84d71ebd162cc21aeab0240e7e0544988 /crates/shirabe/src/config
parent5e31fa33c3b5cf726a57a063b8e7a070869250fe (diff)
downloadphp-shirabe-f31b101ce1e921a026ba234b1f0a83b0392bc118.tar.gz
php-shirabe-f31b101ce1e921a026ba234b1f0a83b0392bc118.tar.zst
php-shirabe-f31b101ce1e921a026ba234b1f0a83b0392bc118.zip
fix(compile): fix all remaining compile errors
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/config')
-rw-r--r--crates/shirabe/src/config/config_source_interface.rs10
-rw-r--r--crates/shirabe/src/config/json_config_source.rs32
2 files changed, 9 insertions, 33 deletions
diff --git a/crates/shirabe/src/config/config_source_interface.rs b/crates/shirabe/src/config/config_source_interface.rs
index 5a23282..f8676cc 100644
--- a/crates/shirabe/src/config/config_source_interface.rs
+++ b/crates/shirabe/src/config/config_source_interface.rs
@@ -1,20 +1,14 @@
//! ref: composer/src/Composer/Config/ConfigSourceInterface.php
-use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
pub trait ConfigSourceInterface: std::fmt::Debug {
- fn add_repository(
- &mut self,
- name: &str,
- config: Option<IndexMap<String, PhpMixed>>,
- append: bool,
- ) -> anyhow::Result<()>;
+ fn add_repository(&mut self, name: &str, config: PhpMixed, append: bool) -> anyhow::Result<()>;
fn insert_repository(
&mut self,
name: &str,
- config: Option<IndexMap<String, PhpMixed>>,
+ config: PhpMixed,
reference_name: &str,
offset: i64,
) -> anyhow::Result<()>;
diff --git a/crates/shirabe/src/config/json_config_source.rs b/crates/shirabe/src/config/json_config_source.rs
index 13eb9b3..b6c3722 100644
--- a/crates/shirabe/src/config/json_config_source.rs
+++ b/crates/shirabe/src/config/json_config_source.rs
@@ -69,7 +69,7 @@ impl JsonConfigSource {
contents = "{\n \"config\": {\n }\n}\n".to_string();
}
- let mut manipulator = JsonManipulator::new(&contents);
+ let mut manipulator = JsonManipulator::new(contents.clone())?;
let new_file = !self.file.exists();
@@ -248,7 +248,8 @@ impl JsonConfigSource {
// TODO(phase-b): retain reference semantics so later mutations of $value propagate
array[0] = value.clone();
- return_val.map(|_| 0).unwrap_or(0) + array.len() as i64
+ let _ = return_val;
+ array.len() as i64
}
}
@@ -257,14 +258,8 @@ impl ConfigSourceInterface for JsonConfigSource {
self.file.get_path().to_string()
}
- fn add_repository(
- &mut self,
- name: &str,
- config: Option<IndexMap<String, PhpMixed>>,
- append: bool,
- ) -> Result<()> {
+ fn add_repository(&mut self, name: &str, config: PhpMixed, append: bool) -> Result<()> {
let name_owned = name.to_string();
- let config_owned = config.clone();
self.manipulate_json(
"addRepository",
Box::new(move |cfg: &mut PhpMixed, args: &mut Vec<PhpMixed>| {
@@ -272,27 +267,18 @@ impl ConfigSourceInterface for JsonConfigSource {
let _ = (cfg, args);
todo!("addRepository fallback closure body");
}),
- vec![
- PhpMixed::String(name_owned),
- config_owned
- .map(|m| {
- PhpMixed::Array(m.into_iter().map(|(k, v)| (k, Box::new(v))).collect())
- })
- .unwrap_or(PhpMixed::Bool(false)),
- PhpMixed::Bool(append),
- ],
+ vec![PhpMixed::String(name_owned), config, PhpMixed::Bool(append)],
)
}
fn insert_repository(
&mut self,
name: &str,
- config: Option<IndexMap<String, PhpMixed>>,
+ config: PhpMixed,
reference_name: &str,
offset: i64,
) -> Result<()> {
let name_owned = name.to_string();
- let config_owned = config.clone();
let reference_name_owned = reference_name.to_string();
self.manipulate_json(
"insertRepository",
@@ -303,11 +289,7 @@ impl ConfigSourceInterface for JsonConfigSource {
}),
vec![
PhpMixed::String(name_owned),
- config_owned
- .map(|m| {
- PhpMixed::Array(m.into_iter().map(|(k, v)| (k, Box::new(v))).collect())
- })
- .unwrap_or(PhpMixed::Bool(false)),
+ config,
PhpMixed::String(reference_name_owned),
PhpMixed::Int(offset),
],