ilario-pierbattista/reverse-regex
ReverseRegex generates random text strings that match a given regular expression, making it easy to create test data for web forms, databases, and regex testing. A fork of icomefromthenet/reverse-regex with lexer, parser, and scope-based generation.
Architecture fit: ReverseRegex remains a small, framework-agnostic PHP library with a lexer/parser/generator pipeline and no Laravel coupling. Release 0.8.0 does not change that shape: it is still best composed inside PHPUnit/Pest tests, factories, seeders, or a thin internal helper. The 0.8.0 changes actually make composition slightly more attractive than inheritance — native return types and typed properties were added to Scope, Node::contains(), Parser, and the Parser\Quantifier/Parser\Unicode strategies, so any internal wrapper should use composition (a façade/helper) rather than subclassing parser internals. It remains a pattern-driven test-data generator, not a general fake-data library.
Integration feasibility: Still Composer-only with PHP 8.1+ and a simple API. 0.8.0 widens runtime ranges to doctrine/lexer ^3 and doctrine/collections ^2/^3, which is materially better for modern Laravel projects where doctrine/lexer v3 is already resolved; older Laravel stacks pinned to doctrine/collections ^1 may still conflict, so resolution must be tested against each target Laravel version. The package no longer ships its test classes (tests moved from src/ReverseRegex/Test/ to tests/) and PSR-0 was replaced by PSR-4 with identical namespaces, so the published archive is leaner and autoloading is standard. Supported pattern subset is unchanged: literals, character classes, quantifiers, alternation, groups, \d, \w, \s, ., hex ranges, \X{####}; still unsupported: \p{...}, lookarounds, backreferences, conditionals.
Technical risk: Adoption remains very low (3 GitHub stars, 0 dependents), so external validation is still minimal and long-term maintenance is the dominant risk. Engineering hygiene improved meaningfully in 0.8.0 (PHPStan level 6 with no baseline, 90% coverage floor via Codecov, Dependabot, release-from-tag automation, PHP 8.1/8.5 matrix, examples run in CI), which reduces — but does not eliminate — the "abandoned fork" risk. The main upgrade risk is the subclassing break: typed signatures on parser internals will fatal for any code extending them, though the team has no such code today. Secondary risks: subtle divergence from full PCRE semantics, and unbounded quantifiers (*, +) producing oversized output. Note that Scope::generate() now normalises null to an empty string, so consumers should expect '' rather than null on empty results.
Key questions: Which production-adjacent regex patterns must be supported, and are they all in scope? Will this remain test-only, or is there pressure to use it in seeding/load-testing? Who owns the dependency internally if upstream stalls (the maintainer is active as of 0.8.0, but bus factor is one)? Does the Composer resolution work on each supported Laravel version now that doctrine/* ranges changed? Do we need deterministic, seed-reproducible data across environments? What is the fallback if a required regex feature is unsupported?
Stack fit: Best suited to Laravel projects on PHP 8.1+ using PHPUnit/Pest that need structured test data for validation rules, database constraints, API payloads, or load-test fixtures. Wrap it in a project-specific helper or factory method that hides the lexer/parser API, enforces bounded patterns, and calls the library by composition only — do not extend Parser, Scope, Node, or the quantifier/unicode strategies, since 0.8.0 explicitly treats those signatures as possibly breaking for subclasses. A custom Faker provider is still viable but inherits the supported-regex limits.
Migration path: Adopt or upgrade as a require-dev dependency and pilot against one validation-heavy test suite. Upgrading from 0.6.x to 0.8.0 should be effectively drop-in for consumers that only call the public API; verify by running the existing test suite and static analysis first. The PSR-0 → PSR-4 change is transparent unless anything referenced src/ReverseRegex/Test/ classes (they are no longer shipped — treat that as intentional, not a regression). If migrating from icomefromthenet/reverse-regex, validate namespace and behavioural compatibility before switching packages. Do not migrate production runtime code; this stays a test/tooling capability.
Compatibility: Confirm PHP 8.1–8.5 support against the application's Laravel version and locked dependencies. The widened doctrine/lexer ^3 and doctrine/collections ^2|^3 ranges are the key resolution lever — validate on the oldest and newest Laravel versions in the support matrix before rolling out. strict_types=1 is now declared in all source files; this is internal, but it makes previously tolerated loose comparisons fail loudly, so run the full suite rather than a single pilot. Pin a known-good version and avoid floating constraints in CI-sensitive projects.
Sequencing: 1) Inventory regex patterns used in validation and test fixtures. 2) Upgrade to 0.8.0 in a branch and run the full suite plus static analysis (Psalm/PHPStan) to confirm no subclassing or null-vs-empty-string assumptions break. 3) Pilot in one test suite with bounded quantifiers only. 4) Confirm the helper uses composition, enforces input validation, and caps generation size. 5) Expand to factories/seeders if results are stable. 6) Add CI checks that generated values match the intended pattern and stay within size limits. 7) Review package health quarterly and keep a fork/patch contingency.
Maintenance: Expect low community activity and no enterprise support. The 0.8.0 release shows a maintainer investing in quality (coverage gate, PHPStan level 6, Dependabot, automated releases), which is a positive signal, but it is still a single-maintainer dependency. The codebase is small enough to fork or patch internally if needed; that remains an ownership cost. Treat it as a narrowly scoped test dependency, pin versions, and watch the changelog — this release demonstrates the project will make subclass-level breaking changes in minor versions.
Support: Community-driven only. The TPM should name an internal owner for dependency review, vulnerability monitoring, and fallback planning. Zero dependents still means little external evidence that edge cases have been exercised by other teams; the package's own 90% coverage is reassuring for its own behaviour but says nothing about fit to our patterns.
Scaling: Generation is CPU-bound and intended for test/tooling volumes. Large-scale load testing should use bounded quantifiers and hard generation caps; unbounded * and + can produce very large strings and exhaust memory or time. Benchmark the 0.8.0 upgrade against the current pinned version if CI already generates thousands of records — the internal changes are unlikely to affect throughput, but confirm rather than assume.
Failure modes: Unsupported regex constructs may fail or silently produce unintended output. Unbounded quantifiers can cause oversized strings. null now normalises to an empty string, so code branching on null will silently take the wrong path. Subclassing parser internals is now a breaking-change surface. Composer conflicts are possible on older stacks still requiring doctrine/collections ^1. Package abandonment or a future major bump can block upgrades. Generated data may satisfy the regex but not domain semantics, so pattern-level validation is not a substitute for business-rule validation.
Ramp-up: Basic usage is quick for developers comfortable with regex and Composer. The real learning curve is the supported regex subset, quantifier behaviour, and building a safe wrapper — plus the new rule that internal helpers must compose rather than extend library classes. Provide examples, enforce bounded patterns in code review, document the empty-string-on-empty-result behaviour, and make clear this is a pattern-generation tool, not a replacement for Faker, factories, or domain-specific fixture builders.
How can I help you explore Laravel packages today?