From d0336078c5b63b174e7313d54d973a1832228928 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 25 Jun 2026 14:39:00 +0900 Subject: feat(external-packages,shim): implement impl todos across components Port seld/jsonlint JsonParser (+hand-written Lexer), unblocking 10 json_file parse-error tests verified byte-for-byte against PHP. Implement Symfony Finder SplFileInfo, executable finders, String classes (byte/code-point/unicode), ZipArchive shim (via the zip crate), SPDX license validation, and shim date/stream functions. Genuinely-blocked sites (reflection, PHP runtime constants, non-UTF-8 transcoding, recursive PCRE) stay todo!() with reasons. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/symfony/string/byte_string.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/string/byte_string.rs') diff --git a/crates/shirabe-external-packages/src/symfony/string/byte_string.rs b/crates/shirabe-external-packages/src/symfony/string/byte_string.rs index ab17c1e..cd8eae8 100644 --- a/crates/shirabe-external-packages/src/symfony/string/byte_string.rs +++ b/crates/shirabe-external-packages/src/symfony/string/byte_string.rs @@ -8,11 +8,25 @@ pub struct ByteString { } impl ByteString { - pub fn new(_string: &str) -> Self { - todo!() + pub fn new(string: &str) -> Self { + Self { + string: string.to_string(), + } } - pub fn to_code_point_string(&self, _encoding: &str) -> CodePointString { + pub fn to_code_point_string(&self, from_encoding: &str) -> CodePointString { + // The source `string` is always valid UTF-8 (Rust `String`/`&str` guarantee). PHP takes the + // early-return branch whenever `preg_match('//u', ...)` holds for a UTF-8/null encoding, so + // the result mirrors the input bytes verbatim. The `mb_detect_encoding`/`iconv` conversion + // path only applies to genuinely non-UTF-8 byte strings, which cannot occur here. + if matches!(from_encoding, "" | "utf8" | "utf-8" | "UTF8" | "UTF-8") { + return CodePointString { + string: self.string.clone(), + }; + } + + // TODO(phase-d): non-UTF-8 source encodings would require mb_convert_encoding/iconv-style + // decoding, which is unreachable for the UTF-8-only inputs Shirabe currently produces. todo!() } } -- cgit v1.3.1