From e63ccb5cbb479df0f0e5010065ff57bbf4ca238f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 27 Jun 2026 19:44:01 +0900 Subject: 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) --- crates/shirabe/src/package/locker.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/shirabe/src/package/locker.rs') diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs index df5e1de..1f123f1 100644 --- a/crates/shirabe/src/package/locker.rs +++ b/crates/shirabe/src/package/locker.rs @@ -705,7 +705,8 @@ impl Locker { }) .unwrap_or(false); if should_replace { - lock_data.insert(key.to_string(), PhpMixed::Array(IndexMap::new())); + // PHP: new \stdClass() — empty JSON object + lock_data.insert(key.to_string(), PhpMixed::Object(IndexMap::new())); } } -- cgit v1.3.1