diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
| commit | 050c56ef263d90d862ef565bc1762909110e02eb (patch) | |
| tree | cb0887f9dc9a75910c72244d884463cc13778ca1 /treefmt.nix | |
| parent | 7061051e19dc0ccbbdb694f030aedb05802287e4 (diff) | |
| download | php-shirabe-050c56ef263d90d862ef565bc1762909110e02eb.tar.gz php-shirabe-050c56ef263d90d862ef565bc1762909110e02eb.tar.zst php-shirabe-050c56ef263d90d862ef565bc1762909110e02eb.zip | |
fix(class-map-generator): anchor the type keyword search
PhpFileCleaner::clean scans for the single class/interface/trait keyword
of a one-declaration file with a pattern PHP runs anchored (`A`) one char
before the keyword. The port dropped the anchor and relied on the
leftmost match of an offset search instead, on the grounds that the
keyword sits exactly one char past the offset.
That holds for the keyword but not for the guards around it: where the
preceding char makes PCRE fail (`Foo::class`, `$class`, `->class`), the
unanchored search does not fail, it matches the next declaration further
down the file and returns the cleaned prefix cut short there. Given
<?php
namespace A {
$x = Foo::class;
}
namespace B {
class Bar {}
}
PhpFileParser::findClasses reported A\Bar where PHP reports B\Bar,
because the `namespace B {` the cleaner skipped past never reached the
parser.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'treefmt.nix')
0 files changed, 0 insertions, 0 deletions
