@@ -17,14 +17,6 @@ class Regexp
17
17
public const ALL = 1 ;
18
18
public const OFFSET_CAPTURE = 2 ;
19
19
20
- private static array $ messages = [
21
- PREG_INTERNAL_ERROR => 'Internal error ' ,
22
- PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted ' ,
23
- PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted ' ,
24
- PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data ' ,
25
- 5 => 'Offset didn \'t correspond to the begin of a valid UTF-8 code point ' , // PREG_BAD_UTF8_OFFSET_ERROR
26
- ];
27
-
28
20
29
21
/**
30
22
* Splits string by a regular expression.
@@ -35,7 +27,7 @@ public static function split(string $subject, string $pattern, int $flags = 0):
35
27
$ reFlags = (($ flags & self ::OFFSET_CAPTURE ) ? PREG_SPLIT_OFFSET_CAPTURE : 0 ) | PREG_SPLIT_DELIM_CAPTURE ;
36
28
$ res = preg_split ($ pattern , $ subject , -1 , $ reFlags );
37
29
if (preg_last_error ()) { // run-time error
38
- trigger_error (@ self :: $ messages [ preg_last_error ()] , E_USER_WARNING );
30
+ trigger_error (preg_last_error_msg () , E_USER_WARNING );
39
31
}
40
32
41
33
return $ res ;
@@ -58,7 +50,7 @@ public static function match(string $subject, string $pattern, int $flags = 0, i
58
50
? preg_match_all ($ pattern , $ subject , $ m , $ reFlags | PREG_SET_ORDER , $ offset )
59
51
: preg_match ($ pattern , $ subject , $ m , $ reFlags , $ offset );
60
52
if (preg_last_error ()) { // run-time error
61
- trigger_error (@ self :: $ messages [ preg_last_error ()] , E_USER_WARNING );
53
+ trigger_error (preg_last_error_msg () , E_USER_WARNING );
62
54
} elseif ($ res ) {
63
55
return $ m ;
64
56
}
@@ -79,7 +71,7 @@ public static function replace(
79
71
if (is_object ($ replacement ) || is_array ($ replacement )) {
80
72
$ res = preg_replace_callback ($ pattern , $ replacement , $ subject );
81
73
if ($ res === null && preg_last_error ()) { // run-time error
82
- trigger_error (@ self :: $ messages [ preg_last_error ()] , E_USER_WARNING );
74
+ trigger_error (preg_last_error_msg () , E_USER_WARNING );
83
75
}
84
76
85
77
return $ res ;
@@ -91,7 +83,7 @@ public static function replace(
91
83
92
84
$ res = preg_replace ($ pattern , $ replacement , $ subject );
93
85
if (preg_last_error ()) { // run-time error
94
- trigger_error (@ self :: $ messages [ preg_last_error ()] , E_USER_WARNING );
86
+ trigger_error (preg_last_error_msg () , E_USER_WARNING );
95
87
}
96
88
97
89
return $ res ;
0 commit comments