aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package/loader/root_package_loader.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/package/loader/root_package_loader.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/package/loader/root_package_loader.rs')
-rw-r--r--crates/shirabe/src/package/loader/root_package_loader.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs
index bc49ffc0..491961a6 100644
--- a/crates/shirabe/src/package/loader/root_package_loader.rs
+++ b/crates/shirabe/src/package/loader/root_package_loader.rs
@@ -16,7 +16,7 @@ use crate::util::Platform;
use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::{
- PhpMixed, RuntimeException, UnexpectedValueException, php_regex, preg_match2, preg_replace,
+ PhpMixed, RuntimeException, UnexpectedValueException, php_regex, preg_match, preg_replace,
preg_split, strtolower,
};
@@ -252,10 +252,9 @@ impl RootPackageLoader {
mut aliases: Vec<IndexMap<String, String>>,
) -> Vec<IndexMap<String, String>> {
for (req_name, req_version) in requires {
- if let Some(m) = preg_match2(
+ if let Some(m) = preg_match(
php_regex!(r"{(?:^|\| *|, *)([^,\s#|]+)(?:#[^ ]+)? +as +([^,\s|]+)(?:$| *\|| *,)}"),
req_version,
- 0,
) {
let m1 = m.get(1).unwrap_or_default().to_string();
let m2 = m.get(2).unwrap_or_default().to_string();
@@ -317,7 +316,7 @@ impl RootPackageLoader {
let mut matched = false;
for constraint in &constraints {
- if let Some(m) = preg_match2(&pattern, constraint, 0) {
+ if let Some(m) = preg_match(&pattern, constraint) {
let name = strtolower(req_name);
let m1 = m.get(1).unwrap_or_default().to_string();
let normalized_m1 = VersionParser::normalize_stability(&m1).unwrap_or_default();
@@ -338,7 +337,7 @@ impl RootPackageLoader {
for constraint in &constraints {
let req_version_stripped =
preg_replace(php_regex!(r"{^([^,\s@]+) as .+$}"), "$1", constraint);
- if preg_match2(php_regex!(r"{^[^,\s@]+$}"), &req_version_stripped, 0).is_some() {
+ if preg_match(php_regex!(r"{^[^,\s@]+$}"), &req_version_stripped).is_some() {
let stability_name = VersionParser::parse_stability(&req_version_stripped);
if stability_name != "stable" {
let name = strtolower(req_name);
@@ -363,7 +362,7 @@ impl RootPackageLoader {
) -> IndexMap<String, String> {
for (req_name, req_version) in requires {
let req_version = preg_replace(php_regex!(r"{^([^,\s@]+) as .+$}"), "$1", req_version);
- if let Some(m) = preg_match2(php_regex!(r"{^[^,\s@]+?#([a-f0-9]+)$}"), &req_version, 0)
+ if let Some(m) = preg_match(php_regex!(r"{^[^,\s@]+?#([a-f0-9]+)$}"), &req_version)
&& VersionParser::parse_stability(&req_version) == "dev"
{
let name = strtolower(req_name);