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.
strict_types=1 across all source files, PHPStan level 6 with no baseline, a 90% coverage floor with Codecov reporting, a PHP 8.1/8.5 lowest/highest CI matrix, and Dependabot. However, with 3 stars and 0 dependents, it should still be treated as a tactical utility, not critical infrastructure.doctrine/lexer now accepts ^3, doctrine/collections accepts ^2 and ^3) while keeping previously supported versions working. This lowers the chance of a Composer conflict when piloting inside an existing Laravel application—a common blocker for "small utility" adoption decisions.ArrayCollection::getAt() out-of-range handling, Parser scope/short-parse correctness) reduce the risk of silently wrong generated data in evidence-producing test runs.Scope, Node::contains(), Parser and the Parser\Quantifier/Parser\Unicode strategies, and Parser/Quantifier properties are now typed. Public interfaces are unchanged, and normal consumer usage (generating strings) is unaffected. If the recommended internal helper is kept as a thin, non-subclassing wrapper, this upgrade is a low-effort dependency bump.Adopt when:
\d, \w, \s, and selected Unicode/hex ranges.Look elsewhere when:
\p{...} Unicode properties, or advanced full-regex semantics.Executive summary: ReverseRegex is a low-cost, MIT-licensed utility for generating test strings that match regex patterns. It can reduce manual QA effort for validation-heavy features such as phone numbers, postcodes, IDs, and compliance-format inputs. The latest release (0.8.0) is a maintenance and hardening release rather than a feature release: strict typing across the codebase, PHPStan level 6 with no baseline, a 90% minimum coverage gate, a broader PHP version matrix, and fixes for edge-case generation bugs. It widens supported Doctrine dependency ranges, which reduces integration friction, and contains only a narrow breaking change affecting code that subclasses its internals. Adoption remains very low—3 stars and 0 dependents—so it should be piloted as a test-only utility, not adopted as critical platform infrastructure. Recommendation: proceed with the small pilot behind an internal helper; if successful, vendor or fork the package to control risk.
For engineering: The package is framework-agnostic PHP and can be used in Laravel factories, seeders, PHPUnit/Pest setup, and CI scripts. It supports common regex constructs and seeded randomness, which helps reproducible tests. Upgrading to 0.8.0 is low risk for normal consumers: PSR-0 was replaced with PSR-4 (same namespaces and class names), tests no longer ship in the archive, and all source files are now strict_types=1. The breaking surface is limited to subclasses—native return types on Scope, Node::contains(), Parser and its Quantifier/Unicode strategies, plus typed Parser/Quantifier properties. Scope::generate() now normalises null to '', and the ContextInterface::generate() docblocks declare $result as string|null in and string out, which should quiet Psalm/static-analysis noise. Fixed: ArrayCollection::getAt() now returns null outside 1..count() as documented, Parser no longer attaches a null scope when constructed without an explicit head, Parser\Short::parse() returns the documented head scope, and Node::detach() no longer trips the PHP 8.5 SplObjectStorage::detach() deprecation. It does not support advanced regex features such as lookarounds, backreferences, or Unicode properties. Integrate it through an internal RegexTestData helper (composition, not subclassing) so the dependency can be swapped or forked without rewriting tests.
For product/QA leadership: Use it where test data is pattern-constrained and currently handcrafted. Do not use it for realistic user-profile data or production data generation. The 0.8.0 fixes are relevant to QA credibility—generated values are now correct in documented edge cases rather than silently wrong—which matters if test output is used as evidence of validation coverage. Measure pilot success by reduced fixture maintenance, fewer flaky validation tests, and faster creation of edge-case inputs. Treat broad rollout as contingent on the pilot proving value and the team accepting low-community-dependency risk.
How can I help you explore Laravel packages today?