{"id":13409074,"url":"https://github.com/symfony/polyfill","last_synced_at":"2025-05-14T08:05:10.491Z","repository":{"id":37742844,"uuid":"44726463","full_name":"symfony/polyfill","owner":"symfony","description":"PHP polyfills","archived":false,"fork":false,"pushed_at":"2025-05-02T09:41:00.000Z","size":2920,"stargazers_count":2763,"open_issues_count":19,"forks_count":143,"subscribers_count":41,"default_branch":"1.x","last_synced_at":"2025-05-07T07:12:46.752Z","etag":null,"topics":["component","php","polyfill","portability","symfony","symfony-component"],"latest_commit_sha":null,"homepage":"https://symfony.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/symfony.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"fabpot","tidelift":"packagist/symfony/symfony","custom":"https://symfony.com/sponsor"}},"created_at":"2015-10-22T06:30:37.000Z","updated_at":"2025-05-06T08:15:13.000Z","dependencies_parsed_at":"2024-01-09T21:22:57.762Z","dependency_job_id":"dbd88c56-c96d-43ca-8a4f-4913d9a6dab7","html_url":"https://github.com/symfony/polyfill","commit_stats":{"total_commits":584,"total_committers":144,"mean_commits":4.055555555555555,"dds":0.6523972602739726,"last_synced_commit":"a5ae13211e892f1b1e955f9a22d29eb1f9581c1f"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symfony%2Fpolyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symfony%2Fpolyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symfony%2Fpolyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/symfony%2Fpolyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/symfony","download_url":"https://codeload.github.com/symfony/polyfill/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253453142,"owners_count":21911048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","php","polyfill","portability","symfony","symfony-component"],"created_at":"2024-07-30T20:00:57.803Z","updated_at":"2025-05-14T08:05:10.474Z","avatar_url":"https://github.com/symfony.png","language":"PHP","funding_links":["https://github.com/sponsors/fabpot","https://tidelift.com/funding/github/packagist/symfony/symfony","https://symfony.com/sponsor"],"categories":["PHP","类库"],"sub_categories":["未归类"],"readme":"Symfony Polyfill\n================\n\nThis project backports features found in the latest PHP versions and provides\ncompatibility layers for some extensions and functions. It is intended to be\nused when portability across PHP versions and extensions is desired.\n\nPolyfills are provided for:\n- the `apcu` extension when the legacy `apc` extension is installed;\n- the `ctype` extension when PHP is compiled without ctype;\n- the `mbstring` and `iconv` extensions;\n- the `uuid` extension;\n- the `MessageFormatter` class and the `msgfmt_format_message` functions;\n- the `Normalizer` class and the `grapheme_*` functions;\n- the `utf8_encode` and `utf8_decode` functions from the `xml` extension or PHP-7.2 core;\n- the `Collator`, `NumberFormatter`, `Locale` and `IntlDateFormatter` classes,\n  limited to the \"en\" locale;\n- the `intl_error_name`, `intl_get_error_code`, `intl_get_error_message` and\n  `intl_is_failure` functions;\n- the `idn_to_ascii` and `idn_to_utf8` functions;\n- a `Binary` utility class to be used when compatibility with\n  `mbstring.func_overload` is required;\n- the `spl_object_id` and `stream_isatty` functions introduced in PHP 7.2;\n- the `mb_ord`, `mb_chr` and `mb_scrub` functions introduced in PHP 7.2 from the `mbstring` extension\n- the `sapi_windows_vt100_support` function (Windows only) introduced in PHP 7.2;\n- the `PHP_FLOAT_*` constant introduced in PHP 7.2;\n- the `PHP_OS_FAMILY` constant introduced in PHP 7.2;\n- the `is_countable` function introduced in PHP 7.3;\n- the `array_key_first` and `array_key_last` functions introduced in PHP 7.3;\n- the `hrtime` function introduced in PHP 7.3;\n- the `JsonException` class introduced in PHP 7.3;\n- the `get_mangled_object_vars`, `mb_str_split` and `password_algos` functions\n  introduced in PHP 7.4;\n- the `fdiv` function introduced in PHP 8.0;\n- the `get_debug_type` function introduced in PHP 8.0;\n- the `preg_last_error_msg` function introduced in PHP 8.0;\n- the `str_contains` function introduced in PHP 8.0;\n- the `str_starts_with` and `str_ends_with` functions introduced in PHP 8.0;\n- the `ValueError` class introduced in PHP 8.0;\n- the `UnhandledMatchError` class introduced in PHP 8.0;\n- the `FILTER_VALIDATE_BOOL` constant introduced in PHP 8.0;\n- the `get_resource_id` function introduced in PHP 8.0;\n- the `Attribute` class introduced in PHP 8.0;\n- the `Stringable` interface introduced in PHP 8.0;\n- the `PhpToken` class introduced in PHP 8.0 when the tokenizer extension is enabled;\n- the `array_is_list` function introduced in PHP 8.1;\n- the `enum_exists` function introduced in PHP 8.1;\n- the `MYSQLI_REFRESH_REPLICA` constant introduced in PHP 8.1;\n- the `ReturnTypeWillChange` attribute introduced in PHP 8.1;\n- the `CURLStringFile` class introduced in PHP 8.1 (but only if PHP \u003e= 7.4 is used);\n- the `AllowDynamicProperties` attribute introduced in PHP 8.2;\n- the `SensitiveParameter` attribute introduced in PHP 8.2;\n- the `SensitiveParameterValue` class introduced in PHP 8.2;\n- the `Random\\Engine` interface introduced in PHP 8.2;\n- the `Random\\CryptoSafeEngine` interface introduced in PHP 8.2;\n- the `Random\\Engine\\Secure` class introduced in PHP 8.2 (check [arokettu/random-polyfill](https://packagist.org/packages/arokettu/random-polyfill) for more engines);\n- the `odbc_connection_string_is_quoted` function introduced in PHP 8.2;\n- the `odbc_connection_string_should_quote` function introduced in PHP 8.2;\n- the `odbc_connection_string_quote` function introduced in PHP 8.2;\n- the `ini_parse_quantity` function introduced in PHP 8.2;\n- the `json_validate` function introduced in PHP 8.3;\n- the `Override` attribute introduced in PHP 8.3;\n- the `mb_str_pad` function introduced in PHP 8.3;\n- the `ldap_exop_sync` function introduced in PHP 8.3;\n- the `ldap_connect_wallet` function introduced in PHP 8.3;\n- the `stream_context_set_options` function introduced in PHP 8.3;\n- the `str_increment` and `str_decrement` functions introduced in PHP 8.3;\n- the `Date*Exception/Error` classes introduced in PHP 8.3;\n- the `SQLite3Exception` class introduced in PHP 8.3;\n- the `mb_ucfirst` and `mb_lcfirst` functions introduced in PHP 8.4;\n- the `array_find`, `array_find_key`, `array_any` and `array_all` functions introduced in PHP 8.4;\n- the `Deprecated` attribute introduced in PHP 8.4;\n- the `mb_trim`, `mb_ltrim` and `mb_rtrim` functions introduced in PHP 8.4;\n- the `CURL_HTTP_VERSION_3` and `CURL_HTTP_VERSION_3ONLY` constants introduced in PHP 8.4;\n- the `get_error_handler` and `get_exception_handler` functions introduced in PHP 8.5;\n- the `NoDiscard` attribute introduced in PHP 8.5;\n\nIt is strongly recommended to upgrade your PHP version and/or install the missing\nextensions whenever possible. This polyfill should be used only when there is no\nbetter choice or when portability is a requirement.\n\nCompatibility notes\n===================\n\nTo write portable code between PHP5 and PHP7, some care must be taken:\n- `\\*Error` exceptions must be caught before `\\Exception`;\n- after calling `error_clear_last()`, the result of `$e = error_get_last()` must be\n  verified using `isset($e['message'][0])` instead of `null !== $e`.\n\nUsage\n=====\n\nWhen using [Composer](https://getcomposer.org/) to manage your dependencies, you\nshould **not** `require` the `symfony/polyfill` package, but the standalone ones:\n- `symfony/polyfill-apcu` for using the `apcu_*` functions,\n- `symfony/polyfill-ctype` for using the ctype functions,\n- `symfony/polyfill-php54` for using the PHP 5.4 functions,\n- `symfony/polyfill-php55` for using the PHP 5.5 functions,\n- `symfony/polyfill-php56` for using the PHP 5.6 functions,\n- `symfony/polyfill-php70` for using the PHP 7.0 functions,\n- `symfony/polyfill-php71` for using the PHP 7.1 functions,\n- `symfony/polyfill-php72` for using the PHP 7.2 functions,\n- `symfony/polyfill-php73` for using the PHP 7.3 functions,\n- `symfony/polyfill-php74` for using the PHP 7.4 functions,\n- `symfony/polyfill-php80` for using the PHP 8.0 functions,\n- `symfony/polyfill-php81` for using the PHP 8.1 functions,\n- `symfony/polyfill-php82` for using the PHP 8.2 functions,\n- `symfony/polyfill-php83` for using the PHP 8.3 functions,\n- `symfony/polyfill-php84` for using the PHP 8.4 functions,\n- `symfony/polyfill-php85` for using the PHP 8.5 functions,\n- `symfony/polyfill-iconv` for using the iconv functions,\n- `symfony/polyfill-intl-grapheme` for using the `grapheme_*` functions,\n- `symfony/polyfill-intl-idn` for using the `idn_to_ascii` and `idn_to_utf8` functions,\n- `symfony/polyfill-intl-icu` for using the intl functions and classes,\n- `symfony/polyfill-intl-messageformatter` for using the intl messageformatter,\n- `symfony/polyfill-intl-normalizer` for using the intl normalizer,\n- `symfony/polyfill-mbstring` for using the mbstring functions,\n- `symfony/polyfill-util` for using the polyfill utility helpers.\n- `symfony/polyfill-uuid` for using the `uuid_*` functions,\n\nRequiring `symfony/polyfill` directly would prevent Composer from sharing\ncorrectly polyfills in dependency graphs. As such, it would likely install\nmore code than required.\n\nDesign\n======\n\nThis package is designed for low overhead and high quality polyfilling.\n\nIt adds only a few lightweight `require` statements to the bootstrap process\nto support all polyfills. Implementations are then loaded on-demand when\nneeded during code execution.\n\nIf your project requires a minimum PHP version it is advisable to add polyfills\nfor lower PHP versions to the `replace` section of your `composer.json`.\nThis removes any overhead from these polyfills as they are no longer part of your project.\nThe same can be done for polyfills for extensions that you require.\n\nIf your project requires php 7.0, and needs the mb extension, the replace section would look\nsomething like this:\n\n```json\n{\n    \"replace\": {\n        \"symfony/polyfill-php54\": \"*\",\n        \"symfony/polyfill-php55\": \"*\",\n        \"symfony/polyfill-php56\": \"*\",\n        \"symfony/polyfill-php70\": \"*\",\n        \"symfony/polyfill-mbstring\": \"*\"\n    }\n}\n```\n\nPolyfills are unit-tested alongside their native implementation so that\nfeature and behavior parity can be proven and enforced in the long run.\n\nLicense\n=======\n\nThis library is released under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymfony%2Fpolyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsymfony%2Fpolyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymfony%2Fpolyfill/lists"}