{"id":22576108,"url":"https://github.com/colopl/php-colopl_bc","last_synced_at":"2026-03-04T06:31:10.725Z","repository":{"id":174597363,"uuid":"652419002","full_name":"colopl/php-colopl_bc","owner":"colopl","description":"Backwards compatibility Extension and Library for PHP 8.x and later","archived":false,"fork":false,"pushed_at":"2026-02-02T21:33:00.000Z","size":7603,"stargazers_count":19,"open_issues_count":8,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-03T10:59:08.046Z","etag":null,"topics":["extension","library","php","php7","php8"],"latest_commit_sha":null,"homepage":"https://colopl.github.io/php-colopl_bc/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colopl.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-12T03:19:35.000Z","updated_at":"2026-01-08T13:54:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"3360614a-5614-4b5e-8b3a-7ac9dda987d2","html_url":"https://github.com/colopl/php-colopl_bc","commit_stats":null,"previous_names":["colopl/php-colopl_bc"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/colopl/php-colopl_bc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_bc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_bc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_bc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_bc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colopl","download_url":"https://codeload.github.com/colopl/php-colopl_bc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_bc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30074142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T05:31:57.858Z","status":"ssl_error","status_checked_at":"2026-03-04T05:31:38.462Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["extension","library","php","php7","php8"],"created_at":"2024-12-08T04:06:05.815Z","updated_at":"2026-03-04T06:31:10.396Z","avatar_url":"https://github.com/colopl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# colopl_bc\n\nProvides various compatibility functions required for PHP (temporary) migration.\n\n\u003e [!WARNING]\n\u003e This extension is intended for temporary use only. In other words, code in the production environment should not rely on this implementation as much as possible, and should be gradually phased out when it is safe to do so.\n\n## Supported Versions\n\n- Extension: PHP \u003e= 8.0, 8.4 \u003e= PHP\n- Library: PHP \u003e= 7.4, 8.4 \u003e= PHP\n\nLibrary is introduced for migration to PHP 8.x with the same code base. If you do not need to work with the same code base, you can use only the Extension.\n\n## Usage\n\n### Install\n\nThis repository contains an Extension that provides the main compatibility and an assisting Library, each of which must be installed separately.\n\nExtension can be installed in the following steps. Note that the PHP common build tool chain is required.\n\n```bash\n$ cd \"ext\"\n$ phpize\n$ ./configure\n$ make -j$(nproc)\n$ make test\n$ sudo make install\n```\n\nDon't forget to enable extension. (Maybe create a `*.ini` file or use `docker-php-ext-enable`)\n\n```bash\n$ echo \"extension=colopl_bc\" | sudo tee \"$(php-config --ini-dir)/10-colopl_bc.ini\"\n$ php -m | grep \"colopl_bc\"\ncolopl_bc\n```\n\nThe library is installed in the following steps.\n\n```bash\n$ composer require \"colopl/colopl_bc\"\n```\n\n**Be sure to keep the Extension and Library the same version.**\n\n### Code conversion with Rector\n\nThe `colopl/colopl_bc` package contains Rector rules to convert your code to the functions provided by the existing `ext-colopl_bc`. This can be utilized to save time when dealing with large code bases.\n\nFor each rule, check the rule definition file `src/Rector`. The most common configuration for migrating from PHP 7.x to 8.x is as follows:\n\n```rector.php\n\u003c?php\n/* ~~~ */\n    $rectorConfig-\u003erules([\n        SwitchCaseToEqualRector::class,\n        ArrayFuncToBCMigrateRector::class,\n        SortToBCMigrateRector::class,\n        EqualToBCMigrateRector::class,\n        GreaterToBCMigrateRector::class,\n        GreaterOrEqualToBCMigrateRector::class,\n        NotEqualToBCMigrateRector::class,\n        SmallerToBCMigrateRector::class,\n        SmallerOrEqualToBCMigrateRector::class,\n        SpaceshipToBCMigrateRector::class\n    ]);\n/* ~~~ */\n```\n\n## API references\n\n### INI directives\n\n#### `colopl_bc.php74.compare_mode` (default: `0`)\n\nSets the compatibility check mode for various comparison operators (e.g. `==`).\n\n- 0 (`COLOPL_BC_PHP74_COMPARE_MODE_SILENT`)\n\nIt does not perform compatibility checks and always uses the results of older behavior. Suitable for use in production environments.\n\n- 1 (`COLOPL_BC_PHP74_COMPARE_MODE_DEPRECATED`)\n\nCompares the result with the result of a native PHP operator and raises an error equivalent to `E_DEPRECATED` if the results are different.\n\n- 2 (`COLOPL_BC_PHP74_COMPARE_MODE_LOG`)\n\nCompares the results of native PHP operators and sends a log to the running SAPI if the results are different.\n\n#### `colopl_bc.php74.sort_mode` (default: `0`)\n\nSets the compatibility check mode for various unstable sort algorithms.\n\n- 0 (`COLOPL_BC_PHP74_COMPARE_MODE_SILENT`)\n\nIt does not perform compatibility checks and always uses the results of older behavior. Suitable for use in production environments.\n\n- 1 (`COLOPL_BC_PHP74_COMPARE_MODE_DEPRECATED`)\n\nCompares the result with the result of a native PHP function and raises an error equivalent to `E_DEPRECATED` if the results are different.\n\n- 2 (`COLOPL_BC_PHP74_COMPARE_MODE_LOG`)\n\nCompares the results of native PHP functions and sends a log to the running SAPI if the results are different.\n\n### Constants \n\nPlease check the settings of the corresponding ini directives.\n\n- `COLOPL_BC_PHP74_COMPARE_MODE_SILENT` = 0\n- `COLOPL_BC_PHP74_COMPARE_MODE_DEPRECATED` = 1\n- `COLOPL_BC_PHP75_COMPARE_MODE_LOG` = 2\n- `COLOPL_BC_PHP74_SORT_MODE_SILENT` = 0\n- `COLOPL_BC_PHP74_SORT_MODE_DEPRECATED` = 1\n- `COLOPL_BC_PHP75_SORT_MODE_LOG` = 2\n\n### Functions\n\n- `Colopl\\ColoplBc\\Php74\\ksort()`\n- `Colopl\\ColoplBc\\Php74\\krsort()`\n- `Colopl\\ColoplBc\\Php74\\asort()`\n- `Colopl\\ColoplBc\\Php74\\arsort()`\n- `Colopl\\ColoplBc\\Php74\\sort()`\n- `Colopl\\ColoplBc\\Php74\\rsort()`\n- `Colopl\\ColoplBc\\Php74\\usort()`\n- `Colopl\\ColoplBc\\Php74\\uasort()`\n- `Colopl\\ColoplBc\\Php74\\uksort()`\n- `Colopl\\ColoplBc\\Php74\\array_multisort()`\n\nSorting is performed using the previous unstable sorting algorithm.\n\nThese compatibilities can also be checked at runtime. See the `colopl_bc.php74.sort_mode` INI directive for details.\n\n- `Colopl\\ColoplBc\\Php74\\in_array()`\n- `Colopl\\ColoplBc\\Php74\\array_search()`\n- `Colopl\\ColoplBc\\Php74\\array_keys()`\n\nThese functions use older comparison algorithms than PHP 8.0 for their internal use.\n\nThese compatibilities can also be checked at runtime. See the `colopl_bc.php74.compare_mode` INI directive for details.\n\n- `Colopl\\ColoplBc\\Php74\\eq()` (`==`)\n- `Colopl\\ColoplBc\\Php74\\neq()` (`!=`)\n- `Colopl\\ColoplBc\\Php74\\lt()` (`\u003c`)\n- `Colopl\\ColoplBc\\Php74\\lte()` (`\u003c=`)\n- `Colopl\\ColoplBc\\Php74\\gt()` (`\u003e`)\n- `Colopl\\ColoplBc\\Php74\\gte()` (`\u003e=`)\n- `Colopl\\ColoplBc\\Php74\\spaceship()` (`\u003c=\u003e`)\n\nFor the corresponding comparison operator, returns results that reproduce the older behavior.\n\nThese compatibilities can also be checked at runtime. See the `colopl_bc.php74.compare_mode` INI directive for details.\n\n- `Colopl\\ColoplBc\\Php70\\srand()`\n\nSeed random numbers.\n\n\u003e [!WARNING]\n\u003e `srand()` provided by colopl_bc are based on the glibc `srand()` / `rand()` algorithm. The results may differ from those of the non glibc environments, e.g. Alpine Linux.\n\n- `Colopl\\ColoplBc\\Php70\\rand()`\n\nGenerate random numbers.\n\n\u003e [!WARNING]\n\u003e `rand()` provided by colopl_bc are based on the glibc `srand()` / `rand()` algorithm. The results may differ from those of the non glibc environments, e.g. Alpine Linux.\n\n- `Colopl\\ColoplBc\\Php70\\getrandmax()`\n\nReturns the maximum value that can be returned by a call to `Colopl\\ColoplBc\\Php70\\rand()`.\n\n\u003e [!WARNING]\n\u003e `rand()` provided by colopl_bc are based on the glibc `srand()` / `rand()` algorithm. The results may differ from those of the non glibc environments, e.g. Alpine Linux.\n\n\n- `Colopl\\ColoplBc\\Php70\\shuffle()`\n\nThis function shuffles (randomizes the order of the elements in) an array.\n\n\u003e [!WARNING]\n\u003e `shuffle()` use `Colopl\\ColoplBc\\Php70\\rand()` algorithm internally, by colopl_bc are based on the glibc `srand()` / `rand()` algorithm. The results may differ from those of the non glibc environments, e.g. Alpine Linux.\n\n- `Colopl\\ColoplBc\\Php70\\str_shuffle()`\n\nstr_shuffle() shuffles a string. One permutation of all possible is created.\n\n\n\u003e [!WARNING]\n\u003e `str_shuffle()` use `Colopl\\ColoplBc\\Php70\\rand()` algorighm internally, by colopl_bc are based on the glibc `srand()` / `rand()` algorithm. The results may differ from those of the non glibc environments, e.g. Alpine Linux.\n\n- `Colopl\\ColoplBc\\Php70\\array_rand()`\n\nPicks one or more random entries out of an array, and returns the key (or keys) of the random entries.\n\n\u003e [!WARNING]\n\u003e `array_rand()` use `Colopl\\ColoplBc\\Php70\\rand()` algorithm internally, by colopl_bc are based on the glibc `srand()` / `rand()` algorithm. The results may differ from those of the non glibc environments, e.g. Alpine Linux.\n\n- `Colopl\\ColoplBc\\Php70\\mt_srand()`\n\nAlways initialize the state using a **broken** Mersenne twister.\n\n- `Colopl\\ColoplBc\\Php70\\mt_rand()`\n\nGenerate random numbers.\n\n\u003e [!WARNING]\n\u003e This function previously caused undefined behavior and returned different results depending on the CPU architecture. The current behavior is forced to mimic the gcc + amd64 results, and may return different results for PHP in other environments.\n\n- `Colopl\\ColoplBc\\Php70\\date_create()`\n- `Colopl\\ColoplBc\\Php70\\date_create_immutable()`\n\nAlways instantiate DateTime without milliseconds.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolopl%2Fphp-colopl_bc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolopl%2Fphp-colopl_bc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolopl%2Fphp-colopl_bc/lists"}