From cfd2a4488797ddaabd0087aa0021b26892663ffb Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 14 Jun 2026 13:02:59 +0900 Subject: refactor(pcre): treat regex compile failure as fatal in shim The preg_* shim helpers wrapped their results in Option/Result solely to signal a regex that failed to compile. Composer never feeds a pattern that fails at runtime, so such a failure is a programming error: panic instead and drop the Option/Result wrappers, updating all callers. preg_replace_callback keeps its Result return type since the callback itself is fallible. preg_match_groups is removed in favor of preg_match at its sole call site. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/symfony/console/input/string_input.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'crates/shirabe-external-packages/src/symfony/console/input/string_input.rs') diff --git a/crates/shirabe-external-packages/src/symfony/console/input/string_input.rs b/crates/shirabe-external-packages/src/symfony/console/input/string_input.rs index 952a18e..f57fcf6 100644 --- a/crates/shirabe-external-packages/src/symfony/console/input/string_input.rs +++ b/crates/shirabe-external-packages/src/symfony/console/input/string_input.rs @@ -56,7 +56,6 @@ impl StringInput { let mut m: IndexMap> = IndexMap::new(); if shirabe_php_shim::preg_match2(r"/\s+/A", input, Some(&mut m), 0, cursor as usize) - .expect("invalid regex") == 1 { if token.is_some() { @@ -70,9 +69,7 @@ impl StringInput { Some(&mut m), 0, cursor as usize, - ) - .expect("invalid regex") - == 1 + ) == 1 { let inner = shirabe_php_shim::substr( m[&CaptureKey::ByIndex(3)].as_deref().unwrap_or(""), @@ -96,9 +93,7 @@ impl StringInput { Some(&mut m), 0, cursor as usize, - ) - .expect("invalid regex") - == 1 + ) == 1 { token = Some(format!( "{}{}", @@ -117,9 +112,7 @@ impl StringInput { Some(&mut m), 0, cursor as usize, - ) - .expect("invalid regex") - == 1 + ) == 1 { token = Some(format!( "{}{}", -- cgit v1.3.1