aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/config
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-27 19:44:01 +0900
committernsfisis <nsfisis@gmail.com>2026-06-27 20:18:56 +0900
commite63ccb5cbb479df0f0e5010065ff57bbf4ca238f (patch)
treef91c7db9b3475e845b023f51cef2d6379e80ae5e /crates/shirabe/src/config
parent3cb13f1d7025351615c254b9225a4c5d1bcbd170 (diff)
downloadphp-shirabe-e63ccb5cbb479df0f0e5010065ff57bbf4ca238f.tar.gz
php-shirabe-e63ccb5cbb479df0f0e5010065ff57bbf4ca238f.tar.zst
php-shirabe-e63ccb5cbb479df0f0e5010065ff57bbf4ca238f.zip
fix(json): encode empty stdClass fields as {} not []
Empty PhpMixed::Array now serializes as [], so the several places that build a PHP `new \stdClass` via an empty Array were emitting [] where Composer writes {}. Use PhpMixed::Object for those empty-object cases: - InitCommand: require / require-dev - Locker::fixupJsonDataType: stability-flags / platform / platform-dev - JsonConfigSource fallback: require/config keys that must stay objects Align the affected test expectations with Composer: JsonFile::read() decodes with assoc=true, collapsing the on-disk {} back to [], so reads expect []. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/config')
-rw-r--r--crates/shirabe/src/config/json_config_source.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/shirabe/src/config/json_config_source.rs b/crates/shirabe/src/config/json_config_source.rs
index 2509239..1ce51ad 100644
--- a/crates/shirabe/src/config/json_config_source.rs
+++ b/crates/shirabe/src/config/json_config_source.rs
@@ -98,7 +98,7 @@ impl JsonConfigSource {
&& inner.is_empty()
{
// PHP: $config[$prop] = new \stdClass;
- map.insert(prop.to_string(), PhpMixed::Array(IndexMap::new()));
+ map.insert(prop.to_string(), PhpMixed::Object(IndexMap::new()));
}
}
for prop in ["psr-0", "psr-4"] {
@@ -108,14 +108,15 @@ impl JsonConfigSource {
&& let Some(PhpMixed::Array(inner_map)) = autoload_map.get(prop)
&& inner_map.is_empty()
{
- autoload_map.insert(prop.to_string(), PhpMixed::Array(IndexMap::new()));
+ autoload_map.insert(prop.to_string(), PhpMixed::Object(IndexMap::new()));
}
if let Some(autoload_dev) = map.get_mut("autoload-dev")
&& let PhpMixed::Array(autoload_dev_map) = autoload_dev
&& let Some(PhpMixed::Array(inner_map)) = autoload_dev_map.get(prop)
&& inner_map.is_empty()
{
- autoload_dev_map.insert(prop.to_string(), PhpMixed::Array(IndexMap::new()));
+ autoload_dev_map
+ .insert(prop.to_string(), PhpMixed::Object(IndexMap::new()));
}
}
}
@@ -136,7 +137,7 @@ impl JsonConfigSource {
&& let Some(PhpMixed::Array(inner_map)) = cfg_map.get(prop)
&& inner_map.is_empty()
{
- cfg_map.insert(prop.to_string(), PhpMixed::Array(IndexMap::new()));
+ cfg_map.insert(prop.to_string(), PhpMixed::Object(IndexMap::new()));
}
}
self.file.borrow().write(config)?;