From fce44d4587ba11b080fe0266c483d0be684ffd0d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 12:51:24 +0900 Subject: refactor(php-shim): split json_decode into assoc and obj variants The assoc flag was always a literal at every call site, so the boolean carried no information the function name could not. json_decode_assoc and json_decode_obj make the resulting PhpMixed shape visible at the call site. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/factory.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/src/factory.rs') diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs index fe5a0ec8..b821784d 100644 --- a/crates/shirabe/src/factory.rs +++ b/crates/shirabe/src/factory.rs @@ -55,8 +55,8 @@ use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, PhpMixed, RuntimeException, UnexpectedValueException, array_replace_recursive, class_exists, dirname, extension_loaded, - file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file, json_decode, - mkdir, pathinfo, realpath, rename, rtrim, strpos, strtr, substr, trim, + file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file, json_decode_assoc, + json_decode_obj, mkdir, pathinfo, realpath, rename, rtrim, strpos, strtr, substr, trim, }; use shirabe_symfony_console::formatter::OutputFormatter; use shirabe_symfony_console::formatter::OutputFormatterStyle; @@ -1529,7 +1529,7 @@ impl Factory { _ => return Ok(()), }; - let auth_data = json_decode(&composer_auth_env_str, false)?; + let auth_data = json_decode_obj(&composer_auth_env_str)?; if matches!(auth_data, PhpMixed::Null) { return Err(UnexpectedValueException::new( "COMPOSER_AUTH environment variable is malformed, should be a valid JSON object" @@ -1551,7 +1551,7 @@ impl Factory { JsonFile::AUTH_SCHEMA, Some("COMPOSER_AUTH"), )?; - let auth_data_assoc = json_decode(&composer_auth_env_str, true)?; + let auth_data_assoc = json_decode_assoc(&composer_auth_env_str)?; if !matches!(auth_data_assoc, PhpMixed::Null) { let mut wrapped: IndexMap = IndexMap::new(); wrapped.insert("config".to_string(), auth_data_assoc); -- cgit v1.3.1-4-g156e