aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-class-map-generator/src
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
commita01330572b985007acae339817d171a6505bb16b (patch)
treecf8e9395a8aa679e3e6c1e8e87bcfee309bc7f6d /crates/shirabe-class-map-generator/src
parentcb77f7c7076aa4bac3e6aaa1c164cf9c1d449ddc (diff)
downloadphp-shirabe-a01330572b985007acae339817d171a6505bb16b.tar.gz
php-shirabe-a01330572b985007acae339817d171a6505bb16b.tar.zst
php-shirabe-a01330572b985007acae339817d171a6505bb16b.zip
refactor(preg): drop the Vec-returning preg_match_all
The two preg_match_all variants took the same arguments and differed only in what they returned: a Vec of columns, or the named-and-numbered PregMatchesAll. The latter is the one all but two call sites already used, so preg_match_all2 takes over the plain PHP name and the Vec variant goes away. Its remaining readers only ever wanted group 0's column, which they now take through CaptureKey::ByIndex(0); in the formatter this replaces the array_shift that popped that column off the PREG_PATTERN_ORDER array. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-class-map-generator/src')
-rw-r--r--crates/shirabe-class-map-generator/src/php_file_parser.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/shirabe-class-map-generator/src/php_file_parser.rs b/crates/shirabe-class-map-generator/src/php_file_parser.rs
index 0ed78c7f..7cc96228 100644
--- a/crates/shirabe-class-map-generator/src/php_file_parser.rs
+++ b/crates/shirabe-class-map-generator/src/php_file_parser.rs
@@ -3,7 +3,7 @@
use crate::php_file_cleaner::PhpFileCleaner;
use shirabe_php_shim::{
CaptureKey, PHP_EOL, RuntimeException, file_exists, file_get_contents, function_exists,
- is_file, is_readable, ltrim, php_strip_whitespace, preg_match_all2, str_replace_array, strrpos,
+ is_file, is_readable, ltrim, php_strip_whitespace, preg_match_all, str_replace_array, strrpos,
substr, trim,
};
use std::sync::OnceLock;
@@ -58,7 +58,7 @@ impl PhpFileParser {
// return early if there is no chance of matching anything in this file
let pattern = format!("{{\\b(?:class|interface|trait{})\\s}}i", extra_types);
- let max_matches = preg_match_all2(&pattern, &contents).occurrence_count();
+ let max_matches = preg_match_all(&pattern, &contents).occurrence_count();
if max_matches == 0 {
return Ok(vec![]);
}
@@ -84,7 +84,7 @@ impl PhpFileParser {
}}ix",
et = extra_types
);
- let matches = preg_match_all2(&pattern2, &contents);
+ let matches = preg_match_all(&pattern2, &contents);
let mut classes = vec![];
let mut namespace = String::new();