From a3171eefd8f8e520329bdd8f613e83ba6f0a7c13 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 21 Jun 2026 18:49:24 +0900 Subject: refactor(php-shim): remove ArrayObject, inline IndexMap into PhpMixed::Object ArrayObject was only a thin wrapper around IndexMap used as an empty-{} vs empty-[] marker and as the assoc=false JSON object representation; no reference semantics were involved. Inline its payload directly into PhpMixed::Object and drop the type along with the now-dead StdClass. Side effects of the unification: - ArrayObject::new was todo!(); the config --global / object-typed get paths that built PhpMixed::Object(ArrayObject::new(None)) no longer panic. - base_config_command wrote 'config' as PhpMixed::Array(empty), emitting [] instead of {}; now matches PHP's new \ArrayObject ({}). - The dead is::()/is::() instanceof checks in JsonManipulator are replaced with the faithful as_object() mapping. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/command/base_config_command.rs | 2 +- crates/shirabe/src/command/config_command.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/src/command') diff --git a/crates/shirabe/src/command/base_config_command.rs b/crates/shirabe/src/command/base_config_command.rs index 01952f6..4099ea5 100644 --- a/crates/shirabe/src/command/base_config_command.rs +++ b/crates/shirabe/src/command/base_config_command.rs @@ -89,7 +89,7 @@ pub trait BaseConfigCommand: BaseCommand { .borrow() .write(PhpMixed::Array({ let mut m = IndexMap::new(); - m.insert("config".to_string(), PhpMixed::Array(IndexMap::new())); + m.insert("config".to_string(), PhpMixed::Object(IndexMap::new())); m }))?; let _ = Silencer::call(|| { diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 1517e57..2ee6fd2 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -10,7 +10,7 @@ use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ - ArrayObject, InvalidArgumentException, JsonObject, PhpMixed, RuntimeException, array_filter, + InvalidArgumentException, JsonObject, PhpMixed, RuntimeException, array_filter, array_filter_use_key, array_is_list, array_map, array_merge, array_unique, count, escapeshellcmd, exec, explode, file_exists, file_get_contents, implode, in_array, is_array, is_bool, is_dir, is_numeric, is_object, is_string, json_encode, key, sort, sprintf, @@ -188,7 +188,7 @@ impl Command for ConfigCommand { "bearer", "forgejo-token", ] { - empty_objs.insert(k.to_string(), PhpMixed::Object(ArrayObject::new(None))); + empty_objs.insert(k.to_string(), PhpMixed::Object(IndexMap::new())); } self.auth_config_file .as_ref() @@ -487,7 +487,7 @@ impl Command for ConfigCommand { }) .unwrap_or_default(); if type_strings.iter().any(|s| s == "object") { - value = PhpMixed::Object(ArrayObject::new(None)); + value = PhpMixed::Object(IndexMap::new()); } } } -- cgit v1.3.1