diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-25 16:27:53 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-26 00:20:05 +0900 |
| commit | 3a0d9340810a8808d963135a884f50d08442ac67 (patch) | |
| tree | 9fbed3350a23c791f52e37209095e0db41962c87 /crates/shirabe-class-map-generator/src/php_file_parser.rs | |
| parent | 46ac7242d526e13707dc140b7244e0fadf2219b9 (diff) | |
| download | php-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_parser.rs')
| -rw-r--r-- | crates/shirabe-class-map-generator/src/php_file_parser.rs | 17 |
1 files changed, 13 insertions, 4 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 ae98a5c..7d7c722 100644 --- a/crates/shirabe-class-map-generator/src/php_file_parser.rs +++ b/crates/shirabe-class-map-generator/src/php_file_parser.rs @@ -77,12 +77,21 @@ impl PhpFileParser { let contents = p.clean(); drop(p); + // Regex pattern compatibility: + // PHP uses `\b(?<![\\$:>])<keyword>` to require the keyword to start at a word boundary and + // not be preceded by `\`, `$`, `:` or `>` (so `MyClass::class`, `$class`, `\class`, + // `Foo->class` are skipped). The `regex` crate has no look-behind, so `\b` + the negative + // look-behind are fused into a single consuming class `(?:^|[^...])` that excludes both the + // identifier characters (reproducing `\b`) and the four operator characters. The consumed + // separator lands in match group 0 only; the named groups are unaffected. The PCRE + // possessive quantifiers (`++`, `*+`) are performance-only and become plain `+`/`*`. let pattern2 = format!( - r"(?ix) + r"{{ (?: - \b(?<![\\$:>])(?P<type>class|interface|trait{et}) \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+) - | \b(?<![\\$:>])(?P<ns>namespace) (?P<nsname>\s++[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\s*+\\\\\s*+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+)? \s*+ [\{{;] - )", + (?:^|[^\\$:>a-zA-Z0-9_\x7f-\xff])(?P<type>class|interface|trait{et}) \s+ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*) + | (?:^|[^\\$:>a-zA-Z0-9_\x7f-\xff])(?P<ns>namespace) (?P<nsname>\s+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:\s*\\\s*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*)? \s* [\{{;] + ) + }}ix", et = extra_types ); let mut matches: IndexMap<_, _> = IndexMap::new(); |
