diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-09 11:10:53 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-09 11:10:53 +0900 |
| commit | 66c3eba15ba6302d43de057a9063f7feee8c6fb3 (patch) | |
| tree | d44bf5cec4d9ddfffa1a732dba85418c2873de82 /crates/shirabe/src/util | |
| parent | 0b737de495e9a8530a6a32ce2799dc49f3e5786f (diff) | |
| download | php-shirabe-66c3eba15ba6302d43de057a9063f7feee8c6fb3.tar.gz php-shirabe-66c3eba15ba6302d43de057a9063f7feee8c6fb3.tar.zst php-shirabe-66c3eba15ba6302d43de057a9063f7feee8c6fb3.zip | |
refactor(pcre): extract composer/pcre into the shirabe-pcre crate
Move `Composer\Pcre` out of shirabe-external-packages and into its own
crate, so the path is `shirabe_pcre::preg::Preg` instead of
`shirabe_external_packages::composer::pcre::preg::Preg`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/util')
| -rw-r--r-- | crates/shirabe/src/util/auth_helper.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/composer_mirror.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/config_validator.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/filesystem.rs | 18 | ||||
| -rw-r--r-- | crates/shirabe/src/util/forgejo_url.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/src/util/git.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/github.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/gitlab.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/hg.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/http/curl_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/http/response.rs | 11 | ||||
| -rw-r--r-- | crates/shirabe/src/util/http_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/no_proxy_pattern.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/perforce.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/platform.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/util/process_executor.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/remote_filesystem.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/svn.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/tls_helper.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/url.rs | 2 |
20 files changed, 32 insertions, 43 deletions
diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs index 69a84857..ab8769e8 100644 --- a/crates/shirabe/src/util/auth_helper.rs +++ b/crates/shirabe/src/util/auth_helper.rs @@ -9,7 +9,7 @@ use crate::util::Bitbucket; use crate::util::GitHub; use crate::util::GitLab; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::{ PHP_URL_HOST, PHP_URL_PATH, PHP_URL_SCHEME, PhpMixed, RuntimeException, base64_encode, explode, in_array_loose, in_array_strict, is_array, is_string, json_decode, parse_url, php_regex, diff --git a/crates/shirabe/src/util/composer_mirror.rs b/crates/shirabe/src/util/composer_mirror.rs index a6f60621..1e57662a 100644 --- a/crates/shirabe/src/util/composer_mirror.rs +++ b/crates/shirabe/src/util/composer_mirror.rs @@ -1,6 +1,6 @@ //! ref: composer/src/Composer/Util/ComposerMirror.php -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::{hash, php_regex}; pub struct ComposerMirror; diff --git a/crates/shirabe/src/util/config_validator.rs b/crates/shirabe/src/util/config_validator.rs index 978a5cd2..adf2aea2 100644 --- a/crates/shirabe/src/util/config_validator.rs +++ b/crates/shirabe/src/util/config_validator.rs @@ -9,7 +9,7 @@ use crate::package::loader::LoaderInterface; use crate::package::loader::ValidatingArrayLoader; use indexmap::IndexMap; use serde::de::Error as _; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{PhpMixed, php_regex}; use shirabe_spdx_licenses::SpdxLicenses; diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs index 9c4f4dbf..9adefce7 100644 --- a/crates/shirabe/src/util/filesystem.rs +++ b/crates/shirabe/src/util/filesystem.rs @@ -3,9 +3,9 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Silencer; -use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::filesystem::exception::IOException; use shirabe_external_packages::symfony::finder::Finder; +use shirabe_pcre::Preg; use shirabe_php_shim::{ ErrorException, LogicException, PhpMixed, RuntimeException, array_pop, basename, chdir, clearstatcache, clearstatcache2, copy, dirname, explode, fclose, feof, file_exists, @@ -736,17 +736,15 @@ impl Filesystem { } // extract a prefix being a protocol://, protocol:, protocol://drive: or simply drive: - let mut prefix_match: indexmap::IndexMap< - shirabe_external_packages::composer::pcre::CaptureKey, - String, - > = indexmap::IndexMap::new(); + let mut prefix_match: indexmap::IndexMap<shirabe_pcre::CaptureKey, String> = + indexmap::IndexMap::new(); if Preg::is_match3( php_regex!("{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix"), &path, Some(&mut prefix_match), ) { prefix = prefix_match - .get(&shirabe_external_packages::composer::pcre::CaptureKey::ByIndex(1)) + .get(&shirabe_pcre::CaptureKey::ByIndex(1)) .cloned() .unwrap_or_default(); path = substr(&path, strlen(&prefix), None); @@ -771,13 +769,9 @@ impl Filesystem { // ensure c: is normalized to C: prefix = Preg::replace_callback( php_regex!("{(^|://)[a-z]:$}i"), - |m: &indexmap::IndexMap< - shirabe_external_packages::composer::pcre::CaptureKey, - String, - >| - -> String { + |m: &indexmap::IndexMap<shirabe_pcre::CaptureKey, String>| -> String { let s = m - .get(&shirabe_external_packages::composer::pcre::CaptureKey::ByIndex(0)) + .get(&shirabe_pcre::CaptureKey::ByIndex(0)) .cloned() .unwrap_or_default(); strtoupper(&s) diff --git a/crates/shirabe/src/util/forgejo_url.rs b/crates/shirabe/src/util/forgejo_url.rs index 639426e1..d2628409 100644 --- a/crates/shirabe/src/util/forgejo_url.rs +++ b/crates/shirabe/src/util/forgejo_url.rs @@ -1,6 +1,6 @@ //! ref: composer/src/Composer/Util/ForgejoUrl.php -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::InvalidArgumentException; #[derive(Debug)] @@ -37,14 +37,12 @@ impl ForgejoUrl { pub fn try_from(repo_url: Option<&str>) -> Option<Self> { let repo_url = repo_url?; - let mut matches: indexmap::IndexMap< - shirabe_external_packages::composer::pcre::CaptureKey, - String, - > = indexmap::IndexMap::new(); + let mut matches: indexmap::IndexMap<shirabe_pcre::CaptureKey, String> = + indexmap::IndexMap::new(); if !Preg::match3(Self::URL_REGEX, repo_url, Some(&mut matches)) { return None; } - use shirabe_external_packages::composer::pcre::CaptureKey; + use shirabe_pcre::CaptureKey; let m: Vec<String> = (0..5) .map(|i| { matches diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs index d7bd3685..c92847a2 100644 --- a/crates/shirabe/src/util/git.rs +++ b/crates/shirabe/src/util/git.rs @@ -14,7 +14,7 @@ use crate::util::ProcessExecutor; use crate::util::Url; use crate::util::{AuthHelper, StoreAuth}; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ AnyThrowable, CmpOp, InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map, clearstatcache, explode, implode, in_array_loose, in_array_strict, is_dir, php_regex, diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs index 066f0ff5..10a30159 100644 --- a/crates/shirabe/src/util/github.rs +++ b/crates/shirabe/src/util/github.rs @@ -8,7 +8,7 @@ use crate::io::io_interface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{PhpMixed, date, in_array_loose, php_regex, stripos, strtolower}; diff --git a/crates/shirabe/src/util/gitlab.rs b/crates/shirabe/src/util/gitlab.rs index cdeb0f21..73806762 100644 --- a/crates/shirabe/src/util/gitlab.rs +++ b/crates/shirabe/src/util/gitlab.rs @@ -9,7 +9,7 @@ use crate::io::io_interface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ PhpMixed, RuntimeException, http_build_query, in_array_strict, json_decode, php_regex, time, diff --git a/crates/shirabe/src/util/hg.rs b/crates/shirabe/src/util/hg.rs index 9f5ea3b5..f0cc56cc 100644 --- a/crates/shirabe/src/util/hg.rs +++ b/crates/shirabe/src/util/hg.rs @@ -5,7 +5,7 @@ use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; use crate::util::ProcessExecutor; use crate::util::Url; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::{php_regex, rawurlencode}; use std::sync::OnceLock; diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs index 6409c9d5..bd77f75e 100644 --- a/crates/shirabe/src/util/http/curl_downloader.rs +++ b/crates/shirabe/src/util/http/curl_downloader.rs @@ -31,7 +31,7 @@ use crate::util::http::ProxyManager; use crate::util::http::Response; use crate::util::{AuthHelper, PromptAuthResult, StoreAuth}; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::{ PhpMixed, in_array_loose, in_array_strict, parse_url, php_regex, preg_quote, rename, strpos, substr, unlink_silent, diff --git a/crates/shirabe/src/util/http/response.rs b/crates/shirabe/src/util/http/response.rs index 3ee538d5..47a1593f 100644 --- a/crates/shirabe/src/util/http/response.rs +++ b/crates/shirabe/src/util/http/response.rs @@ -1,7 +1,7 @@ //! ref: composer/src/Composer/Util/Http/Response.php use crate::json::JsonFile; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::{PhpMixed, php_regex, preg_quote}; #[derive(Debug)] @@ -65,13 +65,10 @@ impl Response { let mut value = None; let pattern = format!("{{^{}:\\s*(.+?)\\s*$}}i", preg_quote(name, None)); for header in headers { - let mut matches: indexmap::IndexMap< - shirabe_external_packages::composer::pcre::CaptureKey, - String, - > = indexmap::IndexMap::new(); + let mut matches: indexmap::IndexMap<shirabe_pcre::CaptureKey, String> = + indexmap::IndexMap::new(); if Preg::match3(&pattern, header, Some(&mut matches)) - && let Some(s) = - matches.get(&shirabe_external_packages::composer::pcre::CaptureKey::ByIndex(1)) + && let Some(s) = matches.get(&shirabe_pcre::CaptureKey::ByIndex(1)) { value = Some(s.clone()); } diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs index e53ad82f..0aa589ca 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -16,7 +16,7 @@ use crate::util::http::CurlDownloader; use crate::util::http::Response; use crate::util::sync_executor; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, extension_loaded, diff --git a/crates/shirabe/src/util/no_proxy_pattern.rs b/crates/shirabe/src/util/no_proxy_pattern.rs index 83adb09f..7d4d7b84 100644 --- a/crates/shirabe/src/util/no_proxy_pattern.rs +++ b/crates/shirabe/src/util/no_proxy_pattern.rs @@ -1,7 +1,7 @@ //! ref: composer/src/Composer/Util/NoProxyPattern.php use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::{ PHP_URL_HOST, PHP_URL_PORT, PHP_URL_SCHEME, PhpMixed, RuntimeException, array_key_exists, empty, explode, filter_var_int_with_range, filter_var_ip, inet_pton, ltrim, parse_url, diff --git a/crates/shirabe/src/util/perforce.rs b/crates/shirabe/src/util/perforce.rs index d98f1edf..f03e4835 100644 --- a/crates/shirabe/src/util/perforce.rs +++ b/crates/shirabe/src/util/perforce.rs @@ -6,9 +6,9 @@ use crate::util::Filesystem; use crate::util::Platform; use crate::util::ProcessExecutor; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::process::ExecutableFinder; use shirabe_external_packages::symfony::process::Process; +use shirabe_pcre::Preg; use shirabe_php_shim::{ Exception, PHP_EOL, PhpMixed, PhpResource, chdir, date, explode, fclose, feof, fgets, file_get_contents, fopen, fwrite, gethostname, json_decode, php_regex, str_replace_array, diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs index 2bb5cf99..596a634b 100644 --- a/crates/shirabe/src/util/platform.rs +++ b/crates/shirabe/src/util/platform.rs @@ -2,7 +2,7 @@ use crate::util::ProcessExecutor; use crate::util::Silencer; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::{ PHP_ENV, PHP_SERVER, PhpMixed, PhpResource, RuntimeException, defined, file_exists, file_get_contents, fstat, function_exists, getcwd, getenv, ini_get, is_array, is_readable, @@ -83,7 +83,7 @@ impl Platform { /// Parses tildes and environment variables in paths. pub fn expand_path(path: &str) -> String { - use shirabe_external_packages::composer::pcre::CaptureKey; + use shirabe_pcre::CaptureKey; if Preg::is_match(php_regex!(r"#^~[\\/]#"), path) { return format!( "{}{}", diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs index b9373b6f..2b4c0d89 100644 --- a/crates/shirabe/src/util/process_executor.rs +++ b/crates/shirabe/src/util/process_executor.rs @@ -6,13 +6,13 @@ use crate::io::io_interface; use crate::util::GitHub; use crate::util::Platform; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::seld::signal::SignalHandler; use shirabe_external_packages::symfony::process::ExecutableFinder; use shirabe_external_packages::symfony::process::Process; use shirabe_external_packages::symfony::process::ProcessMock; use shirabe_external_packages::symfony::process::exception::ProcessSignaledException; use shirabe_external_packages::symfony::process::exception::RuntimeException as SymfonyProcessRuntimeException; +use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ LogicException, PHP_EOL, PhpMixed, RuntimeException, array_intersect, array_map, diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index e2901b2c..28edb65c 100644 --- a/crates/shirabe/src/util/remote_filesystem.rs +++ b/crates/shirabe/src/util/remote_filesystem.rs @@ -13,7 +13,7 @@ use crate::util::Url; use crate::util::http::ProxyManager; use crate::util::http::Response; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ PHP_URL_HOST, PHP_URL_PATH, PHP_URL_SCHEME, PHP_VERSION_ID, PhpMixed, RuntimeException, diff --git a/crates/shirabe/src/util/svn.rs b/crates/shirabe/src/util/svn.rs index aaa0c6d1..395f176f 100644 --- a/crates/shirabe/src/util/svn.rs +++ b/crates/shirabe/src/util/svn.rs @@ -7,7 +7,7 @@ use crate::io::io_interface; use crate::util::Platform; use crate::util::ProcessExecutor; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ LogicException, PHP_URL_HOST, PhpMixed, RuntimeException, empty, implode, parse_url, parse_url_all, php_regex, stripos, strpos, trim, diff --git a/crates/shirabe/src/util/tls_helper.rs b/crates/shirabe/src/util/tls_helper.rs index 30d5f754..0df30b1a 100644 --- a/crates/shirabe/src/util/tls_helper.rs +++ b/crates/shirabe/src/util/tls_helper.rs @@ -1,7 +1,7 @@ //! ref: composer/src/Composer/Util/TlsHelper.php use shirabe_external_packages::composer::ca_bundle::ca_bundle::CaBundle; -use shirabe_external_packages::composer::pcre::Preg; +use shirabe_pcre::Preg; use shirabe_php_shim::{ PhpMixed, ltrim, php_regex, preg_quote, str_replace, strtolower, substr, substr_count, }; diff --git a/crates/shirabe/src/util/url.rs b/crates/shirabe/src/util/url.rs index b1974b0b..c7cbd228 100644 --- a/crates/shirabe/src/util/url.rs +++ b/crates/shirabe/src/util/url.rs @@ -3,7 +3,7 @@ use crate::config::Config; use crate::util::GitHub; use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ PHP_URL_HOST, PHP_URL_PORT, PhpMixed, in_array_strict, parse_url, php_regex, }; |
