aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-class-map-generator/src/php_file_cleaner.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-25 16:27:53 +0900
committernsfisis <nsfisis@gmail.com>2026-06-26 00:20:05 +0900
commit3a0d9340810a8808d963135a884f50d08442ac67 (patch)
tree9fbed3350a23c791f52e37209095e0db41962c87 /crates/shirabe-class-map-generator/src/php_file_cleaner.rs
parent46ac7242d526e13707dc140b7244e0fadf2219b9 (diff)
downloadphp-shirabe-3a0d9340810a8808d963135a884f50d08442ac67.tar.gz
php-shirabe-3a0d9340810a8808d963135a884f50d08442ac67.tar.zst
php-shirabe-3a0d9340810a8808d963135a884f50d08442ac67.zip
test: port 59 autoload/vcs/installer/util/command tests; fix output capture
Port autoload_generator (24), bitbucket (14), suggested_packages (11), git_driver (6), archive_manager (3), and a bump command test. Fix the ApplicationTester output-capture root cause (php://memory streams must be readable regardless of fopen mode). Implement posix_getuid/geteuid, the PCRE 'A' anchored modifier, php_strip_whitespace, stream_get_wrappers, is_callable scalars; fix preg_quote angle-bracket escaping and class-map parser regexes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-class-map-generator/src/php_file_cleaner.rs')
-rw-r--r--crates/shirabe-class-map-generator/src/php_file_cleaner.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/shirabe-class-map-generator/src/php_file_cleaner.rs b/crates/shirabe-class-map-generator/src/php_file_cleaner.rs
index 2b97d34..22e37a9 100644
--- a/crates/shirabe-class-map-generator/src/php_file_cleaner.rs
+++ b/crates/shirabe-class-map-generator/src/php_file_cleaner.rs
@@ -34,8 +34,18 @@ impl PhpFileCleaner {
TypeConfigEntry {
name: r#type.clone(),
length: r#type.len(),
+ // Regex pattern compatibility:
+ // PHP uses `.\b(?<![$:>])<type>` anchored (`A`): it consumes the single char
+ // before the keyword (`.`), requires a word boundary there (`\b`) and forbids
+ // that char being `$`, `:` or `>`. The `regex` crate has no look-behind, so the
+ // consumed char plus both guards collapse into one negated class
+ // `[^a-zA-Z0-9_$:>]` (the `\w` set reproducing `\b`, plus the three operators).
+ // The possessive quantifiers (`++`, `*+`) are performance-only and become plain
+ // `+`/`*`. The leftmost-match semantics of `captures_at(.., offset)` stand in for
+ // the dropped `A` (anchored) modifier, since the keyword is known to sit exactly
+ // one char past the search offset.
pattern: format!(
- "{{.\\b(?<![$:>]){}\\s++[a-zA-Z_\\x7f-\\xff:][a-zA-Z0-9_\\x7f-\\xff:\\-]*+}}Ais",
+ "{{[^a-zA-Z0-9_$:>]{}\\s+[a-zA-Z_\\x7f-\\xff:][a-zA-Z0-9_\\x7f-\\xff:\\-]*}}is",
r#type
),
},