diff options
Diffstat (limited to 'crates/shirabe-external-packages/src/seld/json_lint')
3 files changed, 33 insertions, 0 deletions
diff --git a/crates/shirabe-external-packages/src/seld/json_lint/duplicate_key_exception.rs b/crates/shirabe-external-packages/src/seld/json_lint/duplicate_key_exception.rs index 9e35396..df61a91 100644 --- a/crates/shirabe-external-packages/src/seld/json_lint/duplicate_key_exception.rs +++ b/crates/shirabe-external-packages/src/seld/json_lint/duplicate_key_exception.rs @@ -1,7 +1,17 @@ +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; + #[derive(Debug)] pub struct DuplicateKeyException { pub message: String, pub code: i64, + pub details: IndexMap<String, PhpMixed>, +} + +impl DuplicateKeyException { + pub fn get_details(&self) -> &IndexMap<String, PhpMixed> { + &self.details + } } impl std::fmt::Display for DuplicateKeyException { diff --git a/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs b/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs index 31f64df..dbff9a0 100644 --- a/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs +++ b/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs @@ -19,4 +19,12 @@ impl JsonParser { pub fn parse(&self, _json: &str, _flags: u32) -> anyhow::Result<PhpMixed> { todo!() } + + /// PHP: JsonParser::lint() — returns null on success, ParsingException on failure. + pub fn lint( + &mut self, + _json: &str, + ) -> Option<crate::seld::json_lint::parsing_exception::ParsingException> { + todo!() + } } diff --git a/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs b/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs index 3ec6b6b..b756c1b 100644 --- a/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs +++ b/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs @@ -4,6 +4,21 @@ pub struct ParsingException { pub code: i64, } +impl ParsingException { + pub fn new(message: String, _details: Option<shirabe_php_shim::PhpMixed>) -> Self { + Self { message, code: 0 } + } + + pub fn get_message(&self) -> &str { + &self.message + } + + pub fn get_details(&self) -> indexmap::IndexMap<String, shirabe_php_shim::PhpMixed> { + // TODO(phase-b): PHP ParsingException exposes ['text', 'line', 'token'] details + indexmap::IndexMap::new() + } +} + impl std::fmt::Display for ParsingException { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.message) |
