bootstrap.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 (\extension_loaded('curl')) {
  15. // CURL_VERSION_HTTP3 is defined by PHP 8.2+ when libcurl >= 7.66.0
  16. if (defined('CURL_VERSION_HTTP3') || \PHP_VERSION_ID < 80200 && curl_version()['version_number'] >= 0x074200) {
  17. if (!defined('CURL_HTTP_VERSION_3')) {
  18. define('CURL_HTTP_VERSION_3', 30);
  19. }
  20. // CURL_HTTP_VERSION_3ONLY requires libcurl >= 7.88.0 and is not gated by any PHP-defined constant before 8.4
  21. if (!defined('CURL_HTTP_VERSION_3ONLY') && curl_version()['version_number'] >= 0x075800) {
  22. define('CURL_HTTP_VERSION_3ONLY', 31);
  23. }
  24. }
  25. }
  26. if (!function_exists('array_find')) {
  27. function array_find(array $array, callable $callback) { return p\Php84::array_find($array, $callback); }
  28. }
  29. if (!function_exists('array_find_key')) {
  30. function array_find_key(array $array, callable $callback) { return p\Php84::array_find_key($array, $callback); }
  31. }
  32. if (!function_exists('array_any')) {
  33. function array_any(array $array, callable $callback): bool { return p\Php84::array_any($array, $callback); }
  34. }
  35. if (!function_exists('array_all')) {
  36. function array_all(array $array, callable $callback): bool { return p\Php84::array_all($array, $callback); }
  37. }
  38. if (!function_exists('fpow')) {
  39. function fpow(float $num, float $exponent): float { return p\Php84::fpow($num, $exponent); }
  40. }
  41. if (\PHP_VERSION_ID < 80000) {
  42. require __DIR__.'/bootstrap72.php';
  43. }
  44. if (extension_loaded('mbstring')) {
  45. if (!function_exists('mb_ucfirst')) {
  46. function mb_ucfirst(?string $string, ?string $encoding = null): string { return p\Php84::mb_ucfirst((string) $string, $encoding); }
  47. }
  48. if (!function_exists('mb_lcfirst')) {
  49. function mb_lcfirst(?string $string, ?string $encoding = null): string { return p\Php84::mb_lcfirst((string) $string, $encoding); }
  50. }
  51. if (!function_exists('mb_trim')) {
  52. function mb_trim(?string $string, ?string $characters = null, ?string $encoding = null): string { return p\Php84::mb_trim((string) $string, $characters, $encoding); }
  53. }
  54. if (!function_exists('mb_ltrim')) {
  55. function mb_ltrim(?string $string, ?string $characters = null, ?string $encoding = null): string { return p\Php84::mb_ltrim((string) $string, $characters, $encoding); }
  56. }
  57. if (!function_exists('mb_rtrim')) {
  58. function mb_rtrim(?string $string, ?string $characters = null, ?string $encoding = null): string { return p\Php84::mb_rtrim((string) $string, $characters, $encoding); }
  59. }
  60. }
  61. if (extension_loaded('bcmath')) {
  62. if (!function_exists('bcceil')) {
  63. function bcceil(string $num): string { return p\Php84::bcceil($num); }
  64. }
  65. if (!function_exists('bcdivmod')) {
  66. function bcdivmod(string $num1, string $num2, ?int $scale = null): ?array { return p\Php84::bcdivmod($num1, $num2, $scale); }
  67. }
  68. if (!function_exists('bcfloor')) {
  69. function bcfloor(string $num): string { return p\Php84::bcfloor($num); }
  70. }
  71. if (!function_exists('bcround')) {
  72. function bcround(string $num, int $precision = 0, $mode = RoundingMode::HalfAwayFromZero): string { return p\Php84::bcround($num, $precision, $mode); }
  73. }
  74. }
  75. if (\PHP_VERSION_ID >= 80200) {
  76. return require __DIR__.'/bootstrap82.php';
  77. }
  78. if (extension_loaded('intl') && !function_exists('grapheme_str_split')) {
  79. function grapheme_str_split(string $string, int $length = 1) { return p\Php84::grapheme_str_split($string, $length); }
  80. }