diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-16 19:06:49 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-16 19:07:15 +0900 |
| commit | b6604e1395f003748fe40a44e1190470632a40ce (patch) | |
| tree | 27ce3c137c860a7bd8914852ba5f851e213d448c /crates/shirabe-symfony-process | |
| parent | c5605cc072c1880af7d70647278c6aa0de43f402 (diff) | |
| download | php-shirabe-b6604e1395f003748fe40a44e1190470632a40ce.tar.gz php-shirabe-b6604e1395f003748fe40a44e1190470632a40ce.tar.zst php-shirabe-b6604e1395f003748fe40a44e1190470632a40ce.zip | |
refactor(preg): import preg_*() instead of qualifying them
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-symfony-process')
| -rw-r--r-- | crates/shirabe-symfony-process/src/process.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/shirabe-symfony-process/src/process.rs b/crates/shirabe-symfony-process/src/process.rs index 556238cf..5307e1ae 100644 --- a/crates/shirabe-symfony-process/src/process.rs +++ b/crates/shirabe-symfony-process/src/process.rs @@ -11,7 +11,10 @@ use crate::pipes::unix_pipes::UnixPipes; use crate::pipes::windows_pipes::WindowsPipes; use crate::process_utils::ProcessUtils; use indexmap::IndexMap; -use shirabe_php_shim::{CaptureKey, Descriptor, PhpMixed, PhpResource, php_regex}; +use shirabe_php_shim::{ + CaptureKey, Descriptor, PhpMixed, PhpResource, php_regex, preg_match, preg_replace, + preg_replace_callback, +}; use std::sync::OnceLock; /// A user-supplied callback invoked with the output type ("out"/"err") and a chunk of output. @@ -925,7 +928,7 @@ impl Process { let uid = shirabe_php_shim::uniqid("", true); let mut var_count = 0; let mut var_cache: IndexMap<String, String> = IndexMap::new(); - let cmd = shirabe_php_shim::preg_replace_callback( + let cmd = preg_replace_callback( php_regex!( r#"/"(?:( [^"%!^]*+ @@ -963,7 +966,7 @@ impl Process { } value = format!( "\"{}\"", - shirabe_php_shim::preg_replace(php_regex!(r#"/(\\*)"/"#), "$1$1\\\"", &value) + preg_replace(php_regex!(r#"/(\\*)"/"#), "$1$1\\\"", &value) ); var_count += 1; let var = format!("{}{}", uid, var_count); @@ -985,11 +988,7 @@ impl Process { .map(|spec| { format!( "\"{}\"", - shirabe_php_shim::preg_replace( - php_regex!(r#"{(\\*+)"}"#), - "$1$1\\\"", - &spec, - ) + preg_replace(php_regex!(r#"{(\\*+)"}"#), "$1$1\\\"", &spec,) ) }) }) @@ -1044,14 +1043,14 @@ impl Process { if argument.contains('\0') { argument = argument.replace('\0', "?"); } - if !shirabe_php_shim::preg_match( + if !preg_match( php_regex!(r#"/[()%!^"<>&|\s\[\]=;*?'$]/"#), &argument, &mut Vec::new(), ) { return argument; } - argument = shirabe_php_shim::preg_replace(php_regex!(r"/(\\+)$/"), "$1$1", &argument); + argument = preg_replace(php_regex!(r"/(\\+)$/"), "$1$1", &argument); let mut result = argument; for (from, to) in [ @@ -1071,7 +1070,7 @@ impl Process { commandline: &str, env: &IndexMap<String, PhpMixed>, ) -> anyhow::Result<String> { - shirabe_php_shim::preg_replace_callback( + preg_replace_callback( php_regex!(r#"/"\$\{:([_a-zA-Z]+[_a-zA-Z0-9]*)\}"/"#), |matches: &IndexMap<CaptureKey, Option<String>>| -> anyhow::Result<String> { let key = matches |
