aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util/auth_helper.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-16 12:51:24 +0900
committernsfisis <nsfisis@gmail.com>2026-08-16 12:51:24 +0900
commitfce44d4587ba11b080fe0266c483d0be684ffd0d (patch)
tree753e87ac7ed2e57d635a60c10a4ce01b7e0f0f8e /crates/shirabe/src/util/auth_helper.rs
parentb12c2b15f0487d54d359a581e99ced68713914d0 (diff)
downloadphp-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/util/auth_helper.rs')
-rw-r--r--crates/shirabe/src/util/auth_helper.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs
index 3b8aa2e7..7d47f088 100644
--- a/crates/shirabe/src/util/auth_helper.rs
+++ b/crates/shirabe/src/util/auth_helper.rs
@@ -12,7 +12,8 @@ use indexmap::IndexMap;
use shirabe_pcre::Preg;
use shirabe_php_shim::{
PhpMixed, RuntimeException, base64_encode, explode, in_array_loose, in_array_strict, is_array,
- is_string, json_decode, parse_url, php_regex, str_replace, strpos, strtolower, substr, trim,
+ is_string, json_decode_assoc, parse_url, php_regex, str_replace, strpos, strtolower, substr,
+ trim,
};
#[derive(Debug)]
@@ -189,7 +190,7 @@ impl AuthHelper {
// Try to extract a more specific error message from GitHub's API response
let mut git_hub_api_message: Option<String> = None;
if let Some(body) = response_body {
- let decoded = json_decode(body, true)?;
+ let decoded = json_decode_assoc(body)?;
if is_array(&decoded)
&& let Some(arr) = decoded.as_array()
&& let Some(msg) = arr.get("message")
@@ -520,7 +521,7 @@ impl AuthHelper {
let mut custom_headers: PhpMixed = PhpMixed::Null;
// PHP: if (is_string($auth['username']))
// username field is always String in our IndexMap representation
- custom_headers = json_decode(&username, true)?;
+ custom_headers = json_decode_assoc(&username)?;
if is_array(&custom_headers) {
if let Some(arr) = custom_headers.as_array() {
for header in arr.values() {
@@ -580,12 +581,12 @@ impl AuthHelper {
Some("Using Bitbucket OAuth token authentication".to_string());
}
} else if username == "client-certificate" {
- // PHP: $options['ssl'] = array_merge($options['ssl'] ?? [], json_decode((string) $auth['password'], true));
+ // PHP: $options['ssl'] = array_merge($options['ssl'] ?? [], json_decode_assoc((string) $auth['password']));
let existing_ssl = options
.get("ssl")
.cloned()
.unwrap_or(PhpMixed::Array(IndexMap::new()));
- let decoded = json_decode(&password, true)?;
+ let decoded = json_decode_assoc(&password)?;
options.insert(
"ssl".to_string(),
shirabe_php_shim::array_merge(existing_ssl, decoded),