bootstrap.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. use Symfony\Polyfill\Php84 as p;
  11. if (\PHP_VERSION_ID >= 80400) {
  12. return;
  13. }
  14. if (defined('CURL_VERSION_HTTP3') || PHP_VERSION_ID < 80200 && function_exists('curl_version') && curl_version()['version'] >= 0x074200) { // libcurl >= 7.66.0
  15. if (!defined('CURL_HTTP_VERSION_3')) {
  16. define('CURL_HTTP_VERSION_3', 30);
  17. }
  18. if (!defined('CURL_HTTP_VERSION_3ONLY') && defined('CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256')) { // libcurl >= 7.80.0 (7.88 would be better but is slow to check)
  19. define('CURL_HTTP_VERSION_3ONLY', 31);
  20. }
  21. }
  22. if (!function_exists('array_find')) {
  23. function array_find(array $array, callable $callback) { return p\Php84::array_find($array, $callback); }
  24. }
  25. if (!function_exists('array_find_key')) {
  26. function array_find_key(array $array, callable $callback) { return p\Php84::array_find_key($array, $callback); }
  27. }
  28. if (!function_exists('array_any')) {
  29. function array_any(array $array, callable $callback): bool { return p\Php84::array_any($array, $callback); }
  30. }
  31. if (!function_exists('array_all')) {
  32. function array_all(array $array, callable $callback): bool { return p\Php84::array_all($array, $callback); }
  33. }
  34. if (!function_exists('fpow')) {
  35. function fpow(float $num, float $exponent): float { return p\Php84::fpow($num, $exponent); }
  36. }
  37. if (extension_loaded('mbstring')) {
  38. if (!function_exists('mb_ucfirst')) {
  39. function mb_ucfirst(string $string, ?string $encoding = null): string { return p\Php84::mb_ucfirst($string, $encoding); }
  40. }
  41. if (!function_exists('mb_lcfirst')) {
  42. function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Php84::mb_lcfirst($string, $encoding); }
  43. }
  44. if (!function_exists('mb_trim')) {
  45. function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Php84::mb_trim($string, $characters, $encoding); }
  46. }
  47. if (!function_exists('mb_ltrim')) {
  48. function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Php84::mb_ltrim($string, $characters, $encoding); }
  49. }
  50. if (!function_exists('mb_rtrim')) {
  51. function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Php84::mb_rtrim($string, $characters, $encoding); }
  52. }
  53. }
  54. if (extension_loaded('bcmath')) {
  55. if (!function_exists('bcdivmod')) {
  56. function bcdivmod(string $num1, string $num2, ?int $scale = null): ?array { return p\Php84::bcdivmod($num1, $num2, $scale); }
  57. }
  58. }
  59. if (\PHP_VERSION_ID >= 80200) {
  60. return require __DIR__.'/bootstrap82.php';
  61. }
  62. if (extension_loaded('intl') && !function_exists('grapheme_str_split')) {
  63. function grapheme_str_split(string $string, int $length = 1) { return p\Php84::grapheme_str_split($string, $length); }
  64. }