@@ -487,14 +487,6 @@ public static function replace(string $subject, $pattern, $replacement = null, i
487487 /** @internal */
488488 public static function pcre (string $ func , array $ args )
489489 {
490- static $ messages = [
491- PREG_INTERNAL_ERROR => 'Internal error ' ,
492- PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted ' ,
493- PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted ' ,
494- PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data ' ,
495- PREG_BAD_UTF8_OFFSET_ERROR => 'Offset didn \'t correspond to the begin of a valid UTF-8 code point ' ,
496- 6 => 'Failed due to limited JIT stack space ' , // PREG_JIT_STACKLIMIT_ERROR
497- ];
498490 $ res = Callback::invokeSafe ($ func , $ args , function (string $ message ) use ($ args ) {
499491 // compile-time error, not detectable by preg_last_error
500492 throw new RegexpException ($ message . ' in pattern: ' . implode (' or ' , (array ) $ args [0 ]));
@@ -503,7 +495,7 @@ public static function pcre(string $func, array $args)
503495 if (($ code = preg_last_error ()) // run-time error, but preg_last_error & return code are liars
504496 && ($ res === null || !in_array ($ func , ['preg_filter ' , 'preg_replace_callback ' , 'preg_replace ' ], true ))
505497 ) {
506- throw new RegexpException (($ messages [$ code ] ?? 'Unknown error ' )
498+ throw new RegexpException ((RegexpException:: MESSAGES [$ code ] ?? 'Unknown error ' )
507499 . ' (pattern: ' . implode (' or ' , (array ) $ args [0 ]) . ') ' , $ code );
508500 }
509501 return $ res ;
0 commit comments