Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed

- Requires PHP `8.5`
- Exception messages raised in `RegExp` now uses `preg_last_error_msg()` for better debuggability

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions src/RegExp.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private function __construct(string $pattern)
/** @psalm-suppress ArgumentTypeCoercion */
if (@\preg_match($pattern, '') === false) {
/** @psalm-suppress ImpureFunctionCall */
throw new LogicException($pattern, \preg_last_error());
throw new LogicException(\preg_last_error_msg(), \preg_last_error());
}

$this->pattern = $pattern;
Expand All @@ -46,7 +46,7 @@ public function matches(Str $string): bool

if ($value === false) {
/** @psalm-suppress ImpureFunctionCall */
throw new InvalidRegex('', \preg_last_error());
throw new InvalidRegex(\preg_last_error_msg(), \preg_last_error());
}

return (bool) $value;
Expand All @@ -66,7 +66,7 @@ public function capture(Str $string): Map

if ($value === false) {
/** @psalm-suppress ImpureFunctionCall */
throw new InvalidRegex('', \preg_last_error());
throw new InvalidRegex(\preg_last_error_msg(), \preg_last_error());
}

/** @var Map<int|string, Str> */
Expand Down
Loading