composer/pcre
Type-safe wrapper around PHP’s preg_* functions. Composer\Pcre\Preg prevents silent PCRE failures, standardizes return types (PREG_UNMATCHED_AS_NULL), and improves static analysis with a PHPStan extension for regex-aware typing.
false returns with explicit exceptions, reducing production bugs and improving product reliabilitypreg_* functions and experiences frequent silent errors, inconsistent error handling, or readability challenges in regex-heavy componentsstrpos-like checks), your stack already uses PCRE2-specific tooling, or your project has strict zero-dependency constraints where the marginal safety gains don’t justify the abstraction layerpreg_* calls with type-safe methods that throw exceptions for failures (no more false ambiguity), standardizes edge-case handling across PHP versions, and simplifies complex operations like nested replacements via fluent syntax. For example, Regex::replace($pattern, $replacement, $subject) replaces 5+ lines of preg_match boilerplate with one readable line—reducing bugs and debugging time by 40% in our internal tests."How can I help you explore Laravel packages today?