aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-symfony-console/src/input
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-16 19:06:49 +0900
committernsfisis <nsfisis@gmail.com>2026-08-16 19:07:15 +0900
commitb6604e1395f003748fe40a44e1190470632a40ce (patch)
tree27ce3c137c860a7bd8914852ba5f851e213d448c /crates/shirabe-symfony-console/src/input
parentc5605cc072c1880af7d70647278c6aa0de43f402 (diff)
downloadphp-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-console/src/input')
-rw-r--r--crates/shirabe-symfony-console/src/input/argv_input.rs5
-rw-r--r--crates/shirabe-symfony-console/src/input/input.rs4
-rw-r--r--crates/shirabe-symfony-console/src/input/input_option.rs4
-rw-r--r--crates/shirabe-symfony-console/src/input/string_input.rs16
4 files changed, 11 insertions, 18 deletions
diff --git a/crates/shirabe-symfony-console/src/input/argv_input.rs b/crates/shirabe-symfony-console/src/input/argv_input.rs
index 200c7384..b2b663a6 100644
--- a/crates/shirabe-symfony-console/src/input/argv_input.rs
+++ b/crates/shirabe-symfony-console/src/input/argv_input.rs
@@ -6,7 +6,7 @@ use crate::input::InputDefinition;
use crate::input::InputInterface;
use crate::input::StreamableInputInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, php_regex};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_match};
/// ArgvInput represents an input coming from the CLI arguments.
///
@@ -524,8 +524,7 @@ impl std::fmt::Display for ArgvInput {
.iter()
.map(|token| {
let mut r#match: Vec<Option<String>> = Vec::new();
- if shirabe_php_shim::preg_match(php_regex!("{^(-[^=]+=)(.+)}"), token, &mut r#match)
- {
+ if preg_match(php_regex!("{^(-[^=]+=)(.+)}"), token, &mut r#match) {
return format!(
"{}{}",
r#match[1].as_deref().unwrap_or(""),
diff --git a/crates/shirabe-symfony-console/src/input/input.rs b/crates/shirabe-symfony-console/src/input/input.rs
index 7744a4f1..89eedb03 100644
--- a/crates/shirabe-symfony-console/src/input/input.rs
+++ b/crates/shirabe-symfony-console/src/input/input.rs
@@ -4,7 +4,7 @@ use crate::exception::InvalidArgumentException;
use crate::exception::RuntimeException;
use crate::input::InputDefinition;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, PhpResource, php_regex};
+use shirabe_php_shim::{PhpMixed, PhpResource, php_regex, preg_match};
/// Input is the base class for all concrete Input classes.
///
@@ -208,7 +208,7 @@ impl Input {
/// Escapes a token through escapeshellarg if it contains unsafe chars.
pub fn escape_token(&self, token: &str) -> String {
let mut matches: Vec<Option<String>> = vec![];
- if shirabe_php_shim::preg_match(php_regex!("{^[\\w-]+$}"), token, &mut matches) {
+ if preg_match(php_regex!("{^[\\w-]+$}"), token, &mut matches) {
token.to_string()
} else {
shirabe_php_shim::escapeshellarg(token)
diff --git a/crates/shirabe-symfony-console/src/input/input_option.rs b/crates/shirabe-symfony-console/src/input/input_option.rs
index 6734f374..3b24d914 100644
--- a/crates/shirabe-symfony-console/src/input/input_option.rs
+++ b/crates/shirabe-symfony-console/src/input/input_option.rs
@@ -2,7 +2,7 @@
use crate::exception::InvalidArgumentException;
use crate::exception::LogicException;
-use shirabe_php_shim::{PhpMixed, php_regex};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_split};
#[derive(Debug, Clone)]
pub struct InputOption {
@@ -99,7 +99,7 @@ impl InputOption {
fn normalize_shortcut(s: String) -> anyhow::Result<Option<String>> {
let stripped = shirabe_php_shim::ltrim(&s, Some("-"));
- let parts = shirabe_php_shim::preg_split(php_regex!(r"{(\|)-?}"), &stripped);
+ let parts = preg_split(php_regex!(r"{(\|)-?}"), &stripped);
let filtered: Vec<String> =
shirabe_php_shim::array_filter(&parts, |s: &String| !s.is_empty());
let result = shirabe_php_shim::implode("|", &filtered);
diff --git a/crates/shirabe-symfony-console/src/input/string_input.rs b/crates/shirabe-symfony-console/src/input/string_input.rs
index 453bca45..1ec6e853 100644
--- a/crates/shirabe-symfony-console/src/input/string_input.rs
+++ b/crates/shirabe-symfony-console/src/input/string_input.rs
@@ -6,7 +6,7 @@ use crate::input::InputDefinition;
use crate::input::InputInterface;
use crate::input::StreamableInputInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::{CaptureKey, PhpMixed, php_regex};
+use shirabe_php_shim::{CaptureKey, PhpMixed, php_regex, preg_match2};
/// StringInput represents an input provided as a string.
///
@@ -58,19 +58,13 @@ impl StringInput {
}
let mut m: IndexMap<CaptureKey, Option<String>> = IndexMap::new();
- if shirabe_php_shim::preg_match2(
- php_regex!(r"/\s+/A"),
- input,
- &mut m,
- 0,
- cursor as usize,
- ) {
+ if preg_match2(php_regex!(r"/\s+/A"), input, &mut m, 0, cursor as usize) {
if token.is_some() {
tokens.push(token.take().unwrap());
}
cursor +=
shirabe_php_shim::strlen(m[&CaptureKey::ByIndex(0)].as_deref().unwrap_or(""));
- } else if shirabe_php_shim::preg_match2(
+ } else if preg_match2(
format!(r#"/([^="'\s]+?)(=?)({}+)/A"#, Self::REGEX_QUOTED_STRING),
input,
&mut m,
@@ -93,7 +87,7 @@ impl StringInput {
));
cursor +=
shirabe_php_shim::strlen(m[&CaptureKey::ByIndex(0)].as_deref().unwrap_or(""));
- } else if shirabe_php_shim::preg_match2(
+ } else if preg_match2(
format!(r"/{}/A", Self::REGEX_QUOTED_STRING),
input,
&mut m,
@@ -111,7 +105,7 @@ impl StringInput {
));
cursor +=
shirabe_php_shim::strlen(m[&CaptureKey::ByIndex(0)].as_deref().unwrap_or(""));
- } else if shirabe_php_shim::preg_match2(
+ } else if preg_match2(
format!(r"/{}/A", Self::REGEX_UNQUOTED_STRING),
input,
&mut m,