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