aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
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/src
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/src')
-rw-r--r--crates/shirabe/src/command/show_command.rs4
-rw-r--r--crates/shirabe/src/console/application.rs22
2 files changed, 12 insertions, 14 deletions
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index ead034da..d02295d5 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -40,7 +40,7 @@ use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
CmpOp, DATE_ATOM, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException,
array_search, date_format_to_strftime, date_local, extension_loaded, impl_php_class,
- in_array_loose, in_array_strict, php_regex, realpath, strtolower, version_compare,
+ in_array_loose, in_array_strict, php_regex, preg_quote, realpath, strtolower, version_compare,
};
use shirabe_semver::Semver;
use shirabe_semver::constraint::AnyConstraint;
@@ -2279,7 +2279,7 @@ impl Command for ShowCommand {
let mut packages: IndexMap<String, IndexMap<String, PackageOrName>> = IndexMap::new();
let mut package_filter_regex: Option<String> = None;
if let Some(ref pf) = package_filter {
- let escaped = shirabe_php_shim::preg_quote(pf, None);
+ let escaped = preg_quote(pf, None);
package_filter_regex = Some(format!("{{^{}$}}i", escaped.replace("\\*", ".*?")));
}
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs
index 04819b81..9033700b 100644
--- a/crates/shirabe/src/console/application.rs
+++ b/crates/shirabe/src/console/application.rs
@@ -61,8 +61,8 @@ use shirabe_php_shim::{
dirname, disk_free_space, extension_loaded, file_exists, file_get_contents, file_put_contents,
function_exists, getcwd, getmypid, glob, ini_set, is_array, is_dir, is_file, is_string,
json_decode_assoc, memory_get_peak_usage, memory_get_usage, microtime, php_regex, php_uname,
- posix_getuid, random_bytes, realpath, restore_error_handler, round, str_replace, strpos,
- strtoupper, sys_get_temp_dir, time, unlink,
+ posix_getuid, preg_grep, preg_match2, preg_quote, preg_split, random_bytes, realpath,
+ restore_error_handler, round, str_replace, strpos, strtoupper, sys_get_temp_dir, time, unlink,
};
use shirabe_seld_json_lint::ParsingException;
use shirabe_symfony_console::application::Application as BaseApplication;
@@ -950,10 +950,10 @@ impl Application {
// implode('[^:]*:', array_map('preg_quote', explode(':', $namespace))).'[^:]*'
let parts: Vec<String> = shirabe_php_shim::explode(":", namespace)
.into_iter()
- .map(|p| shirabe_php_shim::preg_quote(&p, None))
+ .map(|p| preg_quote(&p, None))
.collect();
let expr = format!("{}{}", shirabe_php_shim::implode("[^:]*:", &parts), "[^:]*");
- let namespaces = shirabe_php_shim::preg_grep(format!("{{^{}}}", expr), &all_namespaces);
+ let namespaces = preg_grep(format!("{{^{}}}", expr), &all_namespaces);
if namespaces.is_empty() {
let mut message = format!(
@@ -1046,19 +1046,17 @@ impl Application {
let parts: Vec<String> = shirabe_php_shim::explode(":", name)
.into_iter()
- .map(|p| shirabe_php_shim::preg_quote(&p, None))
+ .map(|p| preg_quote(&p, None))
.collect();
let expr = format!("{}{}", shirabe_php_shim::implode("[^:]*:", &parts), "[^:]*");
- let mut commands = shirabe_php_shim::preg_grep(format!("{{^{}}}", expr), &all_commands);
+ let mut commands = preg_grep(format!("{{^{}}}", expr), &all_commands);
if commands.is_empty() {
- commands = shirabe_php_shim::preg_grep(format!("{{^{}}}i", expr), &all_commands);
+ commands = preg_grep(format!("{{^{}}}i", expr), &all_commands);
}
// if no commands matched or we just matched namespaces
- if commands.is_empty()
- || shirabe_php_shim::preg_grep(format!("{{^{}$}}i", expr), &commands).is_empty()
- {
+ if commands.is_empty() || preg_grep(format!("{{^{}$}}i", expr), &commands).is_empty() {
if let Some(pos) = shirabe_php_shim::strrpos(name, ":") {
// check if a namespace exists and contains commands
self.find_namespace(&name[..pos])?;
@@ -1344,7 +1342,7 @@ impl Application {
};
let mut lines: Vec<(String, i64)> = Vec::new();
let split = if !message.is_empty() {
- shirabe_php_shim::preg_split(php_regex!(r"/\r?\n/"), &message)
+ preg_split(php_regex!(r"/\r?\n/"), &message)
} else {
Vec::new()
};
@@ -1788,7 +1786,7 @@ impl Application {
let mut offset = 0i64;
let mut m: indexmap::IndexMap<shirabe_php_shim::CaptureKey, Option<String>> =
indexmap::IndexMap::new();
- while shirabe_php_shim::preg_match2(
+ while preg_match2(
php_regex!(r"/.{1,10000}/u"),
&utf8_string,
&mut m,