aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-17 04:18:59 +0900
committernsfisis <nsfisis@gmail.com>2026-08-17 04:18:59 +0900
commit704ba2d87733657dea852fa697fc6d23a961a71b (patch)
treefd96f0fb4c2fb334a6480088a4c542bd60603f65 /crates/shirabe/src
parentdc0cc70f6916810f326d6019a4bec90ca2915904 (diff)
downloadphp-shirabe-704ba2d87733657dea852fa697fc6d23a961a71b.tar.gz
php-shirabe-704ba2d87733657dea852fa697fc6d23a961a71b.tar.zst
php-shirabe-704ba2d87733657dea852fa697fc6d23a961a71b.zip
refactor(preg): replace Preg::split*() with shim preg_split*()
preg_split2()'s limit was always -1 and its flags were always either 0 or PREG_SPLIT_DELIM_CAPTURE alone, so both arguments are gone: the shim now exposes preg_split() and preg_split_delim_capture() over a shared preg_split_impl(). That leaves Preg::split()/split4() as bare pass-throughs, so callers use the shim functions directly and the wrappers are dropped along with the now-unreferenced PREG_SPLIT_* constants. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/command/global_command.rs6
-rw-r--r--crates/shirabe/src/downloader/fossil_downloader.rs4
-rw-r--r--crates/shirabe/src/downloader/git_downloader.rs6
-rw-r--r--crates/shirabe/src/downloader/svn_downloader.rs5
-rw-r--r--crates/shirabe/src/package/archiver/git_exclude_filter.rs5
-rw-r--r--crates/shirabe/src/package/loader/root_package_loader.rs4
-rw-r--r--crates/shirabe/src/repository/array_repository.rs6
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs7
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs6
-rw-r--r--crates/shirabe/src/util/no_proxy_pattern.rs6
-rw-r--r--crates/shirabe/src/util/process_executor.rs4
11 files changed, 31 insertions, 28 deletions
diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs
index af25eb29..21375141 100644
--- a/crates/shirabe/src/command/global_command.rs
+++ b/crates/shirabe/src/command/global_command.rs
@@ -9,7 +9,9 @@ use crate::factory::Factory;
use crate::util::Filesystem;
use crate::util::Platform;
use shirabe_pcre::Preg;
-use shirabe_php_shim::{LogicException, RuntimeException, chdir, impl_php_class, php_regex};
+use shirabe_php_shim::{
+ LogicException, RuntimeException, chdir, impl_php_class, php_regex, preg_split,
+};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::completion::CompletionInput;
use shirabe_symfony_console::completion::{CompletionSuggestions, StringOrSuggestion};
@@ -223,7 +225,7 @@ impl Command for GlobalCommand {
input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
- let tokens = Preg::split(
+ let tokens = preg_split(
php_regex!(r"{\s+}"),
&Self::input_to_string(&*input.borrow())?,
);
diff --git a/crates/shirabe/src/downloader/fossil_downloader.rs b/crates/shirabe/src/downloader/fossil_downloader.rs
index b5e3cb7c..cdc5f268 100644
--- a/crates/shirabe/src/downloader/fossil_downloader.rs
+++ b/crates/shirabe/src/downloader/fossil_downloader.rs
@@ -13,7 +13,7 @@ use crate::util::Filesystem;
use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_pcre::Preg;
-use shirabe_php_shim::{PhpMixed, RuntimeException, impl_php_class, php_regex};
+use shirabe_php_shim::{PhpMixed, RuntimeException, impl_php_class, php_regex, preg_split};
#[derive(Debug)]
pub struct FossilDownloader {
@@ -223,7 +223,7 @@ impl VcsDownloader for FossilDownloader {
let lines: Vec<String> = if trimmed.is_empty() {
vec![]
} else {
- Preg::split(php_regex!(r"{\r?\n}"), &trimmed)
+ preg_split(php_regex!(r"{\r?\n}"), &trimmed)
};
for line in lines {
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs
index 7aeea252..90a962a2 100644
--- a/crates/shirabe/src/downloader/git_downloader.rs
+++ b/crates/shirabe/src/downloader/git_downloader.rs
@@ -20,8 +20,8 @@ use indexmap::IndexMap;
use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
CmpOp, PhpMixed, RuntimeException, array_map, basename, dirname, impl_php_class, implode,
- in_array_strict, is_dir, php_regex, preg_quote, realpath, rtrim, strlen, strpos, substr, trim,
- version_compare,
+ in_array_strict, is_dir, php_regex, preg_quote, preg_split, realpath, rtrim, strlen, strpos,
+ substr, trim, version_compare,
};
#[derive(Debug)]
@@ -1200,7 +1200,7 @@ impl VcsDownloader for GitDownloader {
let changes: Vec<String> = array_map(
|elem: &String| format!(" {}", elem),
- &Preg::split(php_regex!(r"{\s*\r?\n\s*}"), &changes),
+ &preg_split(php_regex!(r"{\s*\r?\n\s*}"), &changes),
);
self.inner.io.write_error3(
&format!(
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs
index 1487a710..d5087d10 100644
--- a/crates/shirabe/src/downloader/svn_downloader.rs
+++ b/crates/shirabe/src/downloader/svn_downloader.rs
@@ -17,7 +17,8 @@ use crate::util::Svn as SvnUtil;
use indexmap::IndexMap;
use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- CmpOp, PhpMixed, RuntimeException, impl_php_class, is_dir, php_regex, version_compare,
+ CmpOp, PhpMixed, RuntimeException, impl_php_class, is_dir, php_regex, preg_split,
+ version_compare,
};
#[derive(Debug)]
@@ -271,7 +272,7 @@ impl VcsDownloader for SvnDownloader {
}
let changes_str = changes.unwrap();
- let changes: Vec<String> = Preg::split(php_regex!(r"{\s*\r?\n\s*}"), &changes_str)
+ let changes: Vec<String> = preg_split(php_regex!(r"{\s*\r?\n\s*}"), &changes_str)
.into_iter()
.map(|elem| format!(" {}", elem))
.collect();
diff --git a/crates/shirabe/src/package/archiver/git_exclude_filter.rs b/crates/shirabe/src/package/archiver/git_exclude_filter.rs
index 3dd104ca..e3b35349 100644
--- a/crates/shirabe/src/package/archiver/git_exclude_filter.rs
+++ b/crates/shirabe/src/package/archiver/git_exclude_filter.rs
@@ -2,8 +2,7 @@
use crate::package::archiver::BaseExcludeFilter;
use crate::package::archiver::BaseExcludeFilterBase;
-use shirabe_pcre::Preg;
-use shirabe_php_shim::php_regex;
+use shirabe_php_shim::{php_regex, preg_split};
use std::path::Path;
pub struct GitExcludeFilter {
@@ -36,7 +35,7 @@ impl GitExcludeFilter {
}
fn parse_git_attributes_line_static(line: &str) -> Option<(String, bool, bool)> {
- let parts = Preg::split(php_regex!(r"#\s+#"), line);
+ let parts = preg_split(php_regex!(r"#\s+#"), line);
if parts.len() == 2 && parts[1] == "export-ignore" {
return Some(BaseExcludeFilterBase::generate_pattern(&parts[0]));
diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs
index 0ee355f0..58a06ebd 100644
--- a/crates/shirabe/src/package/loader/root_package_loader.rs
+++ b/crates/shirabe/src/package/loader/root_package_loader.rs
@@ -17,7 +17,7 @@ use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- PhpMixed, RuntimeException, UnexpectedValueException, php_regex, strtolower,
+ PhpMixed, RuntimeException, UnexpectedValueException, php_regex, preg_split, strtolower,
};
#[derive(Debug)]
@@ -305,7 +305,7 @@ impl RootPackageLoader {
for (req_name, req_version) in requires {
let mut constraints: Vec<String> = vec![];
- let or_split = Preg::split(php_regex!(r"{\s*\|\|?\s*}"), req_version.trim());
+ let or_split = preg_split(php_regex!(r"{\s*\|\|?\s*}"), req_version.trim());
for or_constraint in &or_split {
let and_split = shirabe_semver::split_and_constraints(or_constraint);
for and_constraint in and_split {
diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs
index b28cccdc..0f3dc237 100644
--- a/crates/shirabe/src/repository/array_repository.rs
+++ b/crates/shirabe/src/repository/array_repository.rs
@@ -13,7 +13,7 @@ use crate::repository::{
};
use indexmap::IndexMap;
use shirabe_pcre::Preg;
-use shirabe_php_shim::{implode, php_regex, preg_quote, strtolower};
+use shirabe_php_shim::{implode, php_regex, preg_quote, preg_split, strtolower};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use std::rc::Weak;
@@ -329,11 +329,11 @@ impl RepositoryInterface for ArrayRepository {
r#type: Option<String>,
) -> anyhow::Result<Vec<SearchResult>> {
let regex = if mode == crate::repository::SEARCH_FULLTEXT {
- let parts = Preg::split(php_regex!("{\\s+}"), &preg_quote(&query, None));
+ let parts = preg_split(php_regex!("{\\s+}"), &preg_quote(&query, None));
format!("{{(?:{})}}i", implode("|", &parts))
} else {
// vendor/name searches expect the caller to have preg_quoted the query
- let parts = Preg::split(php_regex!("{\\s+}"), &query);
+ let parts = preg_split(php_regex!("{\\s+}"), &query);
format!("{{(?:{})}}i", implode("|", &parts))
};
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index ab8572ad..5f9314b4 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -42,7 +42,8 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
AnyThrowable, CmpOp, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed,
RuntimeException, UnexpectedValueException, extension_loaded, hash, http_build_query_mixed,
- json_decode_assoc, parse_url, php_regex, realpath, strtolower, strtr, urlencode, var_export,
+ json_decode_assoc, parse_url, php_regex, preg_split, realpath, strtolower, strtr, urlencode,
+ var_export,
};
use shirabe_semver::CompilingMatcher;
use shirabe_semver::constraint::AnyConstraint;
@@ -764,7 +765,7 @@ impl ComposerRepository {
if mode == SEARCH_VENDOR {
let mut results: Vec<IndexMap<String, PhpMixed>> = Vec::new();
- let parts = Preg::split(php_regex!(r"{\s+}"), &query);
+ let parts = preg_split(php_regex!(r"{\s+}"), &query);
let regex = format!("{{(?:{})}}i", parts.join("|"));
let vendor_names = self.get_vendor_names()?;
@@ -828,7 +829,7 @@ impl ComposerRepository {
}
let mut results: Vec<IndexMap<String, PhpMixed>> = Vec::new();
- let parts = Preg::split(php_regex!(r"{\s+}"), &query);
+ let parts = preg_split(php_regex!(r"{\s+}"), &query);
let regex = format!("{{(?:{})}}i", parts.join("|"));
let package_names = self.get_package_names(None)?;
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 341d9f18..4c0df86a 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -19,7 +19,7 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_map,
array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array_loose,
- parse_url, php_regex, strpos, strtolower, substr, trim, urlencode,
+ parse_url, php_regex, preg_split, strpos, strtolower, substr, trim, urlencode,
};
#[derive(Debug)]
@@ -493,7 +493,7 @@ impl GitHubDriver {
let mut result: Vec<IndexMap<String, PhpMixed>> = vec![];
let mut key: Option<String> = None;
- for line in Preg::split(php_regex!(r"{\r?\n}"), &funding) {
+ for line in preg_split(php_regex!(r"{\r?\n}"), &funding) {
let line = trim(&line, None);
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
if Preg::is_match3(php_regex!(r"{^(\w+)\s*:\s*(.+)$}"), &line, Some(&mut m)) {
@@ -508,7 +508,7 @@ impl GitHubDriver {
let inner = m2.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default();
for item in array_map(
|s: &String| trim(s, None),
- &Preg::split(php_regex!(r#"{[\'\"]?\s*,\s*[\'\"]?}"#), &inner),
+ &preg_split(php_regex!(r#"{[\'\"]?\s*,\s*[\'\"]?}"#), &inner),
) {
let mut entry = IndexMap::new();
entry.insert("type".to_string(), PhpMixed::String(g1.clone()));
diff --git a/crates/shirabe/src/util/no_proxy_pattern.rs b/crates/shirabe/src/util/no_proxy_pattern.rs
index 85e1f472..cd54fa1a 100644
--- a/crates/shirabe/src/util/no_proxy_pattern.rs
+++ b/crates/shirabe/src/util/no_proxy_pattern.rs
@@ -1,10 +1,10 @@
//! ref: composer/src/Composer/Util/NoProxyPattern.php
use indexmap::IndexMap;
-use shirabe_pcre::Preg;
use shirabe_php_shim::{
RuntimeException, array_key_exists, explode, filter_var_int_with_range, filter_var_ip,
- inet_pton, ltrim, parse_url, php_regex, stripos, strlen, strpbrk, strpos, substr, substr_count,
+ inet_pton, ltrim, parse_url, php_regex, preg_split, stripos, strlen, strpbrk, strpos, substr,
+ substr_count,
};
/// Tests URLs against NO_PROXY patterns
@@ -37,7 +37,7 @@ impl NoProxyPattern {
/// @param string $pattern NO_PROXY pattern
pub fn new(pattern: &str) -> Self {
// PHP: Preg::split('{[\s,]+}', $pattern, -1, PREG_SPLIT_NO_EMPTY)
- let host_names = Preg::split(php_regex!(r"{[\s,]+}"), pattern);
+ let host_names = preg_split(php_regex!(r"{[\s,]+}"), pattern);
let noproxy = host_names.is_empty() || host_names[0] == "*";
Self {
host_names,
diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs
index 875c8810..fc67604e 100644
--- a/crates/shirabe/src/util/process_executor.rs
+++ b/crates/shirabe/src/util/process_executor.rs
@@ -12,7 +12,7 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
LogicException, PHP_EOL, PhpMixed, RuntimeException, array_intersect, array_map,
escapeshellarg, explode, implode, in_array_strict, is_array, is_dir, is_numeric, is_string,
- php_regex, rtrim, str_replace, strcspn, strlen, strpbrk, strtolower, strtr_array,
+ php_regex, preg_split, rtrim, str_replace, strcspn, strlen, strpbrk, strtolower, strtr_array,
substr_replace, trim,
};
use shirabe_symfony_process::ExecutableFinder;
@@ -779,7 +779,7 @@ impl ProcessExecutor {
if output.is_empty() {
vec![]
} else {
- Preg::split(php_regex!(r"{\r?\n}"), &output)
+ preg_split(php_regex!(r"{\r?\n}"), &output)
}
}