aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/package_discovery_trait.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-18 01:57:02 +0900
committernsfisis <nsfisis@gmail.com>2026-08-18 01:57:02 +0900
commite093b2be1c333e67c96aebb0a5291bea9ae3d6db (patch)
tree0743fad689f419959c3a898605e21485087884fa /crates/shirabe/src/command/package_discovery_trait.rs
parent050c56ef263d90d862ef565bc1762909110e02eb (diff)
downloadphp-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.gz
php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.zst
php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.zip
refactor(preg): drop the offset argument from preg_match
Every call site but one passed offset 0. The remaining one, the UTF-8 chunking loop in Application, slices the subject instead: its pattern has no anchor or lookaround, so matching a suffix is equivalent to starting the search at that offset. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/package_discovery_trait.rs')
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index a5b606a8..8e25c1b9 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -23,7 +23,7 @@ use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
Exception, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, array_keys,
array_slice, asort, explode, file_get_contents, implode, in_array_strict, is_array, is_file,
- is_numeric, json_decode_assoc, levenshtein, php_regex, preg_match2, strlen, strpos, trim,
+ is_numeric, json_decode_assoc, levenshtein, php_regex, preg_match, strlen, strpos, trim,
};
use shirabe_symfony_console::input::InputInterface;
use shirabe_symfony_console::output::OutputInterface;
@@ -143,10 +143,9 @@ pub trait PackageDiscoveryTrait: BaseCommand {
for mut requirement in requires_norm {
if requirement.contains_key("version")
- && preg_match2(
+ && preg_match(
php_regex!(r"{^\d+(\.\d+)?$}"),
requirement.get("version").map(|s| s.as_str()).unwrap_or(""),
- 0,
)
.is_some()
{
@@ -331,10 +330,9 @@ pub trait PackageDiscoveryTrait: BaseCommand {
}
}
- if let Some(m) = preg_match2(
+ if let Some(m) = preg_match(
php_regex!(r"{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}"),
&selection,
- 0,
) {
if let Some(v) = m.name("version").map(str::to_string) {
// parsing `acme/example ~2.3`