diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-16 12:51:24 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-16 12:51:24 +0900 |
| commit | fce44d4587ba11b080fe0266c483d0be684ffd0d (patch) | |
| tree | 753e87ac7ed2e57d635a60c10a4ce01b7e0f0f8e /crates/shirabe/src/factory.rs | |
| parent | b12c2b15f0487d54d359a581e99ced68713914d0 (diff) | |
| download | php-shirabe-fce44d4587ba11b080fe0266c483d0be684ffd0d.tar.gz php-shirabe-fce44d4587ba11b080fe0266c483d0be684ffd0d.tar.zst php-shirabe-fce44d4587ba11b080fe0266c483d0be684ffd0d.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/factory.rs')
| -rw-r--r-- | crates/shirabe/src/factory.rs | 8 |
1 files changed, 4 insertions, 4 deletions
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<String, PhpMixed> = IndexMap::new(); wrapped.insert("config".to_string(), auth_data_assoc); |
