Resources
2 years ago
LICENSE
2 years ago
Mbstring.php
1 year ago
README.md
3 years ago
bootstrap.php
1 year ago
bootstrap80.php
1 year ago
bootstrap.php
295 lines
| 1 | <?php |
| 2 | |
| 3 | namespace { |
| 4 | /* |
| 5 | * This file is part of the Symfony package. |
| 6 | * |
| 7 | * (c) Fabien Potencier <fabien@symfony.com> |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | use Symfony\Polyfill\Mbstring as p; |
| 13 | if (\PHP_VERSION_ID >= 80000) { |
| 14 | return require __DIR__ . '/bootstrap80.php'; |
| 15 | } |
| 16 | if (!\function_exists('mb_convert_encoding')) { |
| 17 | function mb_convert_encoding($string, $to_encoding, $from_encoding = null) |
| 18 | { |
| 19 | return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); |
| 20 | } |
| 21 | } |
| 22 | if (!\function_exists('mb_decode_mimeheader')) { |
| 23 | function mb_decode_mimeheader($string) |
| 24 | { |
| 25 | return p\Mbstring::mb_decode_mimeheader($string); |
| 26 | } |
| 27 | } |
| 28 | if (!\function_exists('mb_encode_mimeheader')) { |
| 29 | function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = "\r\n", $indent = 0) |
| 30 | { |
| 31 | return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); |
| 32 | } |
| 33 | } |
| 34 | if (!\function_exists('mb_decode_numericentity')) { |
| 35 | function mb_decode_numericentity($string, $map, $encoding = null) |
| 36 | { |
| 37 | return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); |
| 38 | } |
| 39 | } |
| 40 | if (!\function_exists('mb_encode_numericentity')) { |
| 41 | function mb_encode_numericentity($string, $map, $encoding = null, $hex = \false) |
| 42 | { |
| 43 | return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); |
| 44 | } |
| 45 | } |
| 46 | if (!\function_exists('mb_convert_case')) { |
| 47 | function mb_convert_case($string, $mode, $encoding = null) |
| 48 | { |
| 49 | return p\Mbstring::mb_convert_case($string, $mode, $encoding); |
| 50 | } |
| 51 | } |
| 52 | if (!\function_exists('mb_internal_encoding')) { |
| 53 | function mb_internal_encoding($encoding = null) |
| 54 | { |
| 55 | return p\Mbstring::mb_internal_encoding($encoding); |
| 56 | } |
| 57 | } |
| 58 | if (!\function_exists('mb_language')) { |
| 59 | function mb_language($language = null) |
| 60 | { |
| 61 | return p\Mbstring::mb_language($language); |
| 62 | } |
| 63 | } |
| 64 | if (!\function_exists('mb_list_encodings')) { |
| 65 | function mb_list_encodings() |
| 66 | { |
| 67 | return p\Mbstring::mb_list_encodings(); |
| 68 | } |
| 69 | } |
| 70 | if (!\function_exists('mb_encoding_aliases')) { |
| 71 | function mb_encoding_aliases($encoding) |
| 72 | { |
| 73 | return p\Mbstring::mb_encoding_aliases($encoding); |
| 74 | } |
| 75 | } |
| 76 | if (!\function_exists('mb_check_encoding')) { |
| 77 | function mb_check_encoding($value = null, $encoding = null) |
| 78 | { |
| 79 | return p\Mbstring::mb_check_encoding($value, $encoding); |
| 80 | } |
| 81 | } |
| 82 | if (!\function_exists('mb_detect_encoding')) { |
| 83 | function mb_detect_encoding($string, $encodings = null, $strict = \false) |
| 84 | { |
| 85 | return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); |
| 86 | } |
| 87 | } |
| 88 | if (!\function_exists('mb_detect_order')) { |
| 89 | function mb_detect_order($encoding = null) |
| 90 | { |
| 91 | return p\Mbstring::mb_detect_order($encoding); |
| 92 | } |
| 93 | } |
| 94 | if (!\function_exists('mb_parse_str')) { |
| 95 | function mb_parse_str($string, &$result = []) |
| 96 | { |
| 97 | \parse_str($string, $result); |
| 98 | return (bool) $result; |
| 99 | } |
| 100 | } |
| 101 | if (!\function_exists('mb_strlen')) { |
| 102 | function mb_strlen($string, $encoding = null) |
| 103 | { |
| 104 | return p\Mbstring::mb_strlen($string, $encoding); |
| 105 | } |
| 106 | } |
| 107 | if (!\function_exists('mb_strpos')) { |
| 108 | function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) |
| 109 | { |
| 110 | return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); |
| 111 | } |
| 112 | } |
| 113 | if (!\function_exists('mb_strtolower')) { |
| 114 | function mb_strtolower($string, $encoding = null) |
| 115 | { |
| 116 | return p\Mbstring::mb_strtolower($string, $encoding); |
| 117 | } |
| 118 | } |
| 119 | if (!\function_exists('mb_strtoupper')) { |
| 120 | function mb_strtoupper($string, $encoding = null) |
| 121 | { |
| 122 | return p\Mbstring::mb_strtoupper($string, $encoding); |
| 123 | } |
| 124 | } |
| 125 | if (!\function_exists('mb_substitute_character')) { |
| 126 | function mb_substitute_character($substitute_character = null) |
| 127 | { |
| 128 | return p\Mbstring::mb_substitute_character($substitute_character); |
| 129 | } |
| 130 | } |
| 131 | if (!\function_exists('mb_substr')) { |
| 132 | function mb_substr($string, $start, $length = 2147483647, $encoding = null) |
| 133 | { |
| 134 | return p\Mbstring::mb_substr($string, $start, $length, $encoding); |
| 135 | } |
| 136 | } |
| 137 | if (!\function_exists('mb_stripos')) { |
| 138 | function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) |
| 139 | { |
| 140 | return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); |
| 141 | } |
| 142 | } |
| 143 | if (!\function_exists('mb_stristr')) { |
| 144 | function mb_stristr($haystack, $needle, $before_needle = \false, $encoding = null) |
| 145 | { |
| 146 | return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); |
| 147 | } |
| 148 | } |
| 149 | if (!\function_exists('mb_strrchr')) { |
| 150 | function mb_strrchr($haystack, $needle, $before_needle = \false, $encoding = null) |
| 151 | { |
| 152 | return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); |
| 153 | } |
| 154 | } |
| 155 | if (!\function_exists('mb_strrichr')) { |
| 156 | function mb_strrichr($haystack, $needle, $before_needle = \false, $encoding = null) |
| 157 | { |
| 158 | return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); |
| 159 | } |
| 160 | } |
| 161 | if (!\function_exists('mb_strripos')) { |
| 162 | function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) |
| 163 | { |
| 164 | return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); |
| 165 | } |
| 166 | } |
| 167 | if (!\function_exists('mb_strrpos')) { |
| 168 | function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) |
| 169 | { |
| 170 | return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); |
| 171 | } |
| 172 | } |
| 173 | if (!\function_exists('mb_strstr')) { |
| 174 | function mb_strstr($haystack, $needle, $before_needle = \false, $encoding = null) |
| 175 | { |
| 176 | return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); |
| 177 | } |
| 178 | } |
| 179 | if (!\function_exists('mb_get_info')) { |
| 180 | function mb_get_info($type = 'all') |
| 181 | { |
| 182 | return p\Mbstring::mb_get_info($type); |
| 183 | } |
| 184 | } |
| 185 | if (!\function_exists('mb_http_output')) { |
| 186 | function mb_http_output($encoding = null) |
| 187 | { |
| 188 | return p\Mbstring::mb_http_output($encoding); |
| 189 | } |
| 190 | } |
| 191 | if (!\function_exists('mb_strwidth')) { |
| 192 | function mb_strwidth($string, $encoding = null) |
| 193 | { |
| 194 | return p\Mbstring::mb_strwidth($string, $encoding); |
| 195 | } |
| 196 | } |
| 197 | if (!\function_exists('mb_substr_count')) { |
| 198 | function mb_substr_count($haystack, $needle, $encoding = null) |
| 199 | { |
| 200 | return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); |
| 201 | } |
| 202 | } |
| 203 | if (!\function_exists('mb_output_handler')) { |
| 204 | function mb_output_handler($string, $status) |
| 205 | { |
| 206 | return p\Mbstring::mb_output_handler($string, $status); |
| 207 | } |
| 208 | } |
| 209 | if (!\function_exists('mb_http_input')) { |
| 210 | function mb_http_input($type = null) |
| 211 | { |
| 212 | return p\Mbstring::mb_http_input($type); |
| 213 | } |
| 214 | } |
| 215 | if (!\function_exists('mb_convert_variables')) { |
| 216 | function mb_convert_variables($to_encoding, $from_encoding, &...$vars) |
| 217 | { |
| 218 | return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); |
| 219 | } |
| 220 | } |
| 221 | if (!\function_exists('mb_ord')) { |
| 222 | function mb_ord($string, $encoding = null) |
| 223 | { |
| 224 | return p\Mbstring::mb_ord($string, $encoding); |
| 225 | } |
| 226 | } |
| 227 | if (!\function_exists('mb_chr')) { |
| 228 | function mb_chr($codepoint, $encoding = null) |
| 229 | { |
| 230 | return p\Mbstring::mb_chr($codepoint, $encoding); |
| 231 | } |
| 232 | } |
| 233 | if (!\function_exists('mb_scrub')) { |
| 234 | function mb_scrub($string, $encoding = null) |
| 235 | { |
| 236 | $encoding = null === $encoding ? \mb_internal_encoding() : $encoding; |
| 237 | return \mb_convert_encoding($string, $encoding, $encoding); |
| 238 | } |
| 239 | } |
| 240 | if (!\function_exists('mb_str_split')) { |
| 241 | function mb_str_split($string, $length = 1, $encoding = null) |
| 242 | { |
| 243 | return p\Mbstring::mb_str_split($string, $length, $encoding); |
| 244 | } |
| 245 | } |
| 246 | if (!\function_exists('mb_str_pad')) { |
| 247 | function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null) : string |
| 248 | { |
| 249 | return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); |
| 250 | } |
| 251 | } |
| 252 | if (!\function_exists('mb_ucfirst')) { |
| 253 | function mb_ucfirst(string $string, ?string $encoding = null) : string |
| 254 | { |
| 255 | return p\Mbstring::mb_ucfirst($string, $encoding); |
| 256 | } |
| 257 | } |
| 258 | if (!\function_exists('mb_lcfirst')) { |
| 259 | function mb_lcfirst(string $string, ?string $encoding = null) : string |
| 260 | { |
| 261 | return p\Mbstring::mb_lcfirst($string, $encoding); |
| 262 | } |
| 263 | } |
| 264 | if (!\function_exists('mb_trim')) { |
| 265 | function mb_trim(string $string, ?string $characters = null, ?string $encoding = null) : string |
| 266 | { |
| 267 | return p\Mbstring::mb_trim($string, $characters, $encoding); |
| 268 | } |
| 269 | } |
| 270 | if (!\function_exists('mb_ltrim')) { |
| 271 | function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null) : string |
| 272 | { |
| 273 | return p\Mbstring::mb_ltrim($string, $characters, $encoding); |
| 274 | } |
| 275 | } |
| 276 | if (!\function_exists('mb_rtrim')) { |
| 277 | function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null) : string |
| 278 | { |
| 279 | return p\Mbstring::mb_rtrim($string, $characters, $encoding); |
| 280 | } |
| 281 | } |
| 282 | if (\extension_loaded('mbstring')) { |
| 283 | return; |
| 284 | } |
| 285 | if (!\defined('MB_CASE_UPPER')) { |
| 286 | \define('MB_CASE_UPPER', 0); |
| 287 | } |
| 288 | if (!\defined('MB_CASE_LOWER')) { |
| 289 | \define('MB_CASE_LOWER', 1); |
| 290 | } |
| 291 | if (!\defined('MB_CASE_TITLE')) { |
| 292 | \define('MB_CASE_TITLE', 2); |
| 293 | } |
| 294 | } |
| 295 |