Skip to content

ext/strmatch: Add prepared string matching and replacement - #25122

Draft
ArtUkrainskiy wants to merge 1 commit into
php:masterfrom
ArtUkrainskiy:str-matcher-prototype
Draft

ArtUkrainskiy wants to merge 1 commit into
php:masterfrom
ArtUkrainskiy:str-matcher-prototype

Conversation

@ArtUkrainskiy

Copy link
Copy Markdown
Contributor

Introduce independent final Str\Matcher and Str\Replacer classes for reusing fixed keyword dictionaries across subjects.

Use Aho-Corasick for byte-based matching and reversed matching for leftmost-longest replacement. Keep result keywords as shared strings, check count overflow, and reject repeated initialization.

Include Unix and Windows build configuration and 20 PHPT tests.

Introduce independent final Str\Matcher and Str\Replacer classes for
reusing fixed keyword dictionaries across subjects.

Build hybrid Aho-Corasick automata with dense and packed sparse
transitions. Use byte-based matching and reversed matching for
leftmost-longest replacement, while retaining shared keyword strings.

Check state, count and result limits, reject repeated initialization,
and keep prepared objects uncloneable, non-serializable and incomparable.

Include Unix and Windows build configuration, CI coverage and 16 PHPT
tests for API semantics, binary input, overlapping matches and lifecycle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants