Skip to content

Commit f8439b7

Browse files
Use preg_last_error_msg() when possible
1 parent b01c4e7 commit f8439b7

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)