| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the Symfony package. |
| 5 |
* |
| 6 |
* (c) Fabien Potencier <[email protected]> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
|
| 12 |
use Symfony\Polyfill\Intl\Grapheme as p; |
| 13 |
|
| 14 |
if (!function_exists('grapheme_str_split')) { |
| 15 |
function grapheme_str_split(string $string, int $length = 1): array|false { return p\Grapheme::grapheme_str_split($string, $length); } |
| 16 |
} |
| 17 |
if (!function_exists('grapheme_levenshtein')) { |
| 18 |
function grapheme_levenshtein(string $string1, string $string2, int $insertion_cost = 1, int $replacement_cost = 1, int $deletion_cost = 1, string $locale = ''): int|false { return p\Grapheme::grapheme_levenshtein($string1, $string2, $insertion_cost, $replacement_cost, $deletion_cost); } |
| 19 |
} |
| 20 |
if (!function_exists('grapheme_strrev')) { |
| 21 |
function grapheme_strrev(string $string): string|false { return p\Grapheme::grapheme_strrev($string); } |
| 22 |
} |
| 23 |
|
| 24 |
if (extension_loaded('intl')) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
if (!defined('GRAPHEME_EXTR_COUNT')) { |
| 29 |
define('GRAPHEME_EXTR_COUNT', 0); |
| 30 |
} |
| 31 |
if (!defined('GRAPHEME_EXTR_MAXBYTES')) { |
| 32 |
define('GRAPHEME_EXTR_MAXBYTES', 1); |
| 33 |
} |
| 34 |
if (!defined('GRAPHEME_EXTR_MAXCHARS')) { |
| 35 |
define('GRAPHEME_EXTR_MAXCHARS', 2); |
| 36 |
} |
| 37 |
|
| 38 |
if (!function_exists('grapheme_extract')) { |
| 39 |
function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null): string|false { return p\Grapheme::grapheme_extract((string) $haystack, (int) $size, (int) $type, (int) $offset, $next); } |
| 40 |
} |
| 41 |
if (\PHP_VERSION_ID >= 80500) { |
| 42 |
return require __DIR__.'/bootstrap85.php'; |
| 43 |
} |
| 44 |
|
| 45 |
if (!function_exists('grapheme_stripos')) { |
| 46 |
function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); } |
| 47 |
} |
| 48 |
if (!function_exists('grapheme_stristr')) { |
| 49 |
function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); } |
| 50 |
} |
| 51 |
if (!function_exists('grapheme_strlen')) { |
| 52 |
function grapheme_strlen(?string $string): int|false|null { return p\Grapheme::grapheme_strlen((string) $string); } |
| 53 |
} |
| 54 |
if (!function_exists('grapheme_strpos')) { |
| 55 |
function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); } |
| 56 |
} |
| 57 |
if (!function_exists('grapheme_strripos')) { |
| 58 |
function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); } |
| 59 |
} |
| 60 |
if (!function_exists('grapheme_strrpos')) { |
| 61 |
function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); } |
| 62 |
} |
| 63 |
if (!function_exists('grapheme_strstr')) { |
| 64 |
function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); } |
| 65 |
} |
| 66 |
if (!function_exists('grapheme_substr')) { |
| 67 |
function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string|false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, $length); } |
| 68 |
} |