aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/config_command.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-17 06:43:52 +0900
committernsfisis <nsfisis@gmail.com>2026-08-17 06:43:52 +0900
commit52a0665acbbe5bf5b8c6875118fb9cdf7952453b (patch)
tree7302b0b87f7b0d406126da734ef82c80abf64204 /crates/shirabe/src/command/config_command.rs
parentc81e9f89d9e4388f36a4427bbaa95eced659d2ce (diff)
downloadphp-shirabe-52a0665acbbe5bf5b8c6875118fb9cdf7952453b.tar.gz
php-shirabe-52a0665acbbe5bf5b8c6875118fb9cdf7952453b.tar.zst
php-shirabe-52a0665acbbe5bf5b8c6875118fb9cdf7952453b.zip
refactor(preg): wrap the preg_* $matches maps in newtypes
The five IndexMap shapes that the preg_* functions and Preg fill in are now distinct types generated by preg_match_map!, so a matches map no longer interchanges with any other map of the same key and value type. Index<usize> is kept alongside Index<&Q> because call sites such as config_command and event_dispatcher reach for a group by its position in the map rather than by its capture key.
Diffstat (limited to 'crates/shirabe/src/command/config_command.rs')
-rw-r--r--crates/shirabe/src/command/config_command.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs
index 504a0f11..550ddf3c 100644
--- a/crates/shirabe/src/command/config_command.rs
+++ b/crates/shirabe/src/command/config_command.rs
@@ -18,7 +18,7 @@ use crate::util::Filesystem;
use crate::util::Platform;
use crate::util::Silencer;
use indexmap::IndexMap;
-use shirabe_pcre::{CaptureKey, Preg};
+use shirabe_pcre::{CaptureKey, Preg, PregMatchedGroups};
use shirabe_php_shim::{
InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge,
escapeshellcmd, exec, explode, file_exists, impl_php_class, implode, in_array_loose,
@@ -701,7 +701,7 @@ impl Command for ConfigCommand {
let mut source = config.borrow_mut().get_source_of_value(&setting_key);
let mut value: PhpMixed;
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^repos?(?:itories)?(?:\\.(.+))?/"),
&setting_key,
@@ -929,7 +929,7 @@ impl Command for ConfigCommand {
return Ok(0);
}
// handle preferred-install per-package config
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^preferred-install\\.(.+)/"),
&setting_key,
@@ -967,7 +967,7 @@ impl Command for ConfigCommand {
}
// handle allow-plugins config setting elements true or false to add/remove
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("{^allow-plugins\\.([a-zA-Z0-9/*-]+)}"),
&setting_key,
@@ -1037,7 +1037,7 @@ impl Command for ConfigCommand {
}
// handle repositories
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^repos?(?:itories)?\\.(.+)/"),
&setting_key,
@@ -1110,7 +1110,7 @@ impl Command for ConfigCommand {
}
// handle extra
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^extra\\.(.+)/"),
&setting_key,
@@ -1187,7 +1187,7 @@ impl Command for ConfigCommand {
}
// handle suggest
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^suggest\\.(.+)/"),
&setting_key,
@@ -1226,7 +1226,7 @@ impl Command for ConfigCommand {
}
// handle platform
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^platform\\.(.+)/"),
&setting_key,
@@ -1348,7 +1348,7 @@ impl Command for ConfigCommand {
}
// handle auth
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!(
"/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|custom-headers|bearer|forgejo-token)\\.(.+)/"
@@ -1474,7 +1474,7 @@ impl Command for ConfigCommand {
}
// Check if the header is in correct "Name: Value" format
- let mut header_parts: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut header_parts = PregMatchedGroups::new();
if !Preg::is_match3(
php_regex!("/^[^:]+:\\s*.+$/"),
header,
@@ -1527,7 +1527,7 @@ impl Command for ConfigCommand {
}
// handle script
- let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
+ let mut matches = PregMatchedGroups::new();
if Preg::is_match3(
php_regex!("/^scripts\\.(.+)/"),
&setting_key,