Skip to content

Commit 518ff4c

Browse files
committed
minor #46767 Use preg_last_error_msg() when possible (nicolas-grekas)
This PR was merged into the 6.2 branch. Discussion ---------- Use preg_last_error_msg() when possible | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- 0cbcf42408 Use preg_last_error_msg() when possible
2 parents 5e96a3d + f8439b7 commit 518ff4c

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

Parser.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,23 +1036,12 @@ private function isStringUnIndentedCollectionItem(): bool
10361036
*
10371037
* @throws ParseException on a PCRE internal error
10381038
*
1039-
* @see preg_last_error()
1040-
*
10411039
* @internal
10421040
*/
10431041
public static function preg_match(string $pattern, string $subject, array &$matches = null, int $flags = 0, int $offset = 0): int
10441042
{
10451043
if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) {
1046-
$error = match (preg_last_error()) {
1047-
\PREG_INTERNAL_ERROR => 'Internal PCRE error.',
1048-
\PREG_BACKTRACK_LIMIT_ERROR => 'pcre.backtrack_limit reached.',
1049-
\PREG_RECURSION_LIMIT_ERROR => 'pcre.recursion_limit reached.',
1050-
\PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data.',
1051-
\PREG_BAD_UTF8_OFFSET_ERROR => 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.',
1052-
default => 'Error.',
1053-
};
1054-
1055-
throw new ParseException($error);
1044+
throw new ParseException(preg_last_error_msg());
10561045
}
10571046

10581047
return $ret;

0 commit comments

Comments
 (0)