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/tests/json/composer_schema_test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/tests/json/composer_schema_test.rs') diff --git a/crates/shirabe/tests/json/composer_schema_test.rs b/crates/shirabe/tests/json/composer_schema_test.rs index f2a5da44..8c6e8b8a 100644 --- a/crates/shirabe/tests/json/composer_schema_test.rs +++ b/crates/shirabe/tests/json/composer_schema_test.rs @@ -10,7 +10,7 @@ use shirabe::json::{JsonFile, JsonValidationException}; use shirabe_php_shim::Catch as _; -use shirabe_php_shim::json_decode; +use shirabe_php_shim::json_decode_obj; const NAME_PATTERN: &str = r#"^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$"#; const VERSION_PATTERN: &str = r#"^[vV]?\d+(?:[.-]\d+){0,3}[._-]?(?:(?:[sS][tT][aA][bB][lL][eE]|[bB][eE][tT][aA]|[bB]|[rR][cC]|[aA][lL][pP][hH][aA]|[aA]|[pP][aA][tT][cC][hH]|[pP][lL]|[pP])(?:(?:[.-]?\d+)*)?)?(?:[.-]?[dD][eE][vV]|\.x-dev)?(?:\+.*)?$|^dev-.*$"#; @@ -19,7 +19,7 @@ const VERSION_PATTERN: &str = r#"^[vV]?\d+(?:[.-]\d+){0,3}[._-]?(?:(?:[sS][tT][a /// (the `{"$ref": "file://…"}` wrapper used by `LAX_SCHEMA`), returning the validation error /// strings, or an empty vec when the document is valid. fn check(json: &str) -> Vec { - let data = json_decode(json, false).unwrap(); + let data = json_decode_obj(json).unwrap(); match JsonFile::validate_json_schema("test", &data, JsonFile::LAX_SCHEMA, None) { Ok(_) => Vec::new(), Err(e) => e -- cgit v1.3.1-4-g156e