aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/json
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-06 21:22:22 +0900
committernsfisis <nsfisis@gmail.com>2026-06-06 21:33:05 +0900
commit8bd02532cd04ee12d7595029c206f3dc5ab9dd96 (patch)
tree5f9897bfefcb9a503d92560311c4d95ee620a025 /crates/shirabe/src/json
parentc0b743c8d75813003756a72d2fdd110de8368b5f (diff)
downloadphp-shirabe-8bd02532cd04ee12d7595029c206f3dc5ab9dd96.tar.gz
php-shirabe-8bd02532cd04ee12d7595029c206f3dc5ab9dd96.tar.zst
php-shirabe-8bd02532cd04ee12d7595029c206f3dc5ab9dd96.zip
chore(shirabe): remove ports of PHP @deprecated APIs
Composer does not use its own deprecated APIs internally, so drop their Rust ports: whole deprecated classes, methods, constants, and field. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/json')
-rw-r--r--crates/shirabe/src/json/json_file.rs7
-rw-r--r--crates/shirabe/src/json/json_formatter.rs120
-rw-r--r--crates/shirabe/src/json/mod.rs2
3 files changed, 0 insertions, 129 deletions
diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs
index 0aa44fc..b8372b9 100644
--- a/crates/shirabe/src/json/json_file.rs
+++ b/crates/shirabe/src/json/json_file.rs
@@ -87,13 +87,6 @@ impl JsonFile {
pub const AUTH_SCHEMA: i64 = 3;
pub const LOCK_SCHEMA: i64 = 4;
- /// @deprecated Use \JSON_UNESCAPED_SLASHES
- pub const JSON_UNESCAPED_SLASHES: i64 = 64;
- /// @deprecated Use \JSON_PRETTY_PRINT
- pub const JSON_PRETTY_PRINT: i64 = 128;
- /// @deprecated Use \JSON_UNESCAPED_UNICODE
- pub const JSON_UNESCAPED_UNICODE: i64 = 256;
-
pub const INDENT_DEFAULT: &'static str = " ";
/// PHP: __DIR__ . '/../../../res/composer-schema.json'
diff --git a/crates/shirabe/src/json/json_formatter.rs b/crates/shirabe/src/json/json_formatter.rs
deleted file mode 100644
index 260bf1e..0000000
--- a/crates/shirabe/src/json/json_formatter.rs
+++ /dev/null
@@ -1,120 +0,0 @@
-//! ref: composer/src/Composer/Json/JsonFormatter.php
-
-use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
-use shirabe_php_shim::{PhpMixed, function_exists, mb_convert_encoding, pack};
-
-pub struct JsonFormatter;
-
-impl JsonFormatter {
- /**
- * This code is based on the function found at:
- * http://recursive-design.com/blog/2008/03/11/format-json-with-php/
- *
- * Originally licensed under MIT by Dave Perrett <mail@recursive-design.com>
- */
- pub fn format(json: String, unescape_unicode: bool, unescape_slashes: bool) -> String {
- let mut result = String::new();
- let mut pos: usize = 0;
- let indent_str = " ";
- let new_line = "\n";
- let mut out_of_quotes = true;
- let mut buffer = String::new();
- let mut noescape = true;
-
- let chars: Vec<char> = json.chars().collect();
- let str_len = chars.len();
-
- for i in 0..str_len {
- let char_ = chars[i];
-
- if char_ == '"' && noescape {
- out_of_quotes = !out_of_quotes;
- }
-
- if !out_of_quotes {
- buffer.push(char_);
- noescape = if char_ == '\\' { !noescape } else { true };
- continue;
- }
- if !buffer.is_empty() {
- if unescape_slashes {
- buffer = buffer.replace("\\/", "/");
- }
-
- if unescape_unicode && function_exists("mb_convert_encoding") {
- buffer = Preg::replace_callback(
- r"/(\\+)u([0-9a-f]{4})/i",
- |matches: &indexmap::IndexMap<CaptureKey, String>| -> String {
- let m0 = matches
- .get(&CaptureKey::ByIndex(0))
- .cloned()
- .unwrap_or_default();
- let m1 = matches
- .get(&CaptureKey::ByIndex(1))
- .cloned()
- .unwrap_or_default();
- let m2 = matches
- .get(&CaptureKey::ByIndex(2))
- .cloned()
- .unwrap_or_default();
- let l = m1.len();
-
- if l % 2 != 0 {
- let code = i64::from_str_radix(&m2, 16).unwrap_or(0);
- if code >= 0xD800 && code <= 0xDFFF {
- return m0;
- }
-
- return "\\".repeat(l - 1)
- + &mb_convert_encoding(
- pack("H*", &[PhpMixed::String(m2)]),
- "UTF-8",
- "UCS-2BE",
- );
- }
-
- m0
- },
- &buffer,
- )
- .unwrap_or(buffer);
- }
-
- result.push_str(&buffer);
- result.push(char_);
- buffer = String::new();
- continue;
- }
-
- let mut char_str = char_.to_string();
-
- if char_ == ':' {
- char_str.push(' ');
- } else if char_ == '}' || char_ == ']' {
- pos -= 1;
- let prev_char = if i > 0 { chars[i - 1] } else { '\0' };
-
- if prev_char != '{' && prev_char != '[' {
- result.push_str(new_line);
- result.push_str(&indent_str.repeat(pos));
- } else {
- result = result.trim_end().to_string();
- }
- }
-
- result.push_str(&char_str);
-
- if char_ == ',' || char_ == '{' || char_ == '[' {
- result.push_str(new_line);
-
- if char_ == '{' || char_ == '[' {
- pos += 1;
- }
-
- result.push_str(&indent_str.repeat(pos));
- }
- }
-
- result
- }
-}
diff --git a/crates/shirabe/src/json/mod.rs b/crates/shirabe/src/json/mod.rs
index 0863529..36b5b6d 100644
--- a/crates/shirabe/src/json/mod.rs
+++ b/crates/shirabe/src/json/mod.rs
@@ -1,9 +1,7 @@
pub mod json_file;
-pub mod json_formatter;
pub mod json_manipulator;
pub mod json_validation_exception;
pub use json_file::*;
-pub use json_formatter::*;
pub use json_manipulator::*;
pub use json_validation_exception::*;