From 526e5fbd107fc56ae52c9e4f7fff1900b7faae0a Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 20 Nov 2026 23:07:23 +0000 Subject: [PATCH 1/3] fix: support PHP 8.6 --- .github/workflows/ci.yml | 2 +- AGENTS.md | 4 ++-- CHANGELOG.md | 7 +++++++ README.md | 2 +- composer.json | 2 +- config.m4 | 4 ++-- pcov.c | 40 ++++++++++++++++++++-------------------- php_pcov.h | 2 +- tests/php86_partial.phpt | 32 ++++++++++++++++++++++++++++++++ 9 files changed, 67 insertions(+), 28 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 tests/php86_partial.phpt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f083d36..b2d6d26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.3", "8.4", "8.5"] + php: ["8.3", "8.4", "8.5", "8.6"] steps: - name: Install build tools diff --git a/AGENTS.md b/AGENTS.md index 84a0a23..2bd04ee 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ This is MageLens's PCOV fork: a native PHP line-coverage extension with synchronous coverage export, immutable executable-line manifests, and optional native Magento GET coverage caching. It is not the upstream `krakjoe/pcov` release. Start with [README.md](README.md) for usage and [docs/manifest-and-records.md](docs/manifest-and-records.md) for the record contract. -The supported release target is Linux, non-thread-safe PHP 8.3, 8.4 and 8.5, as declared by `composer.json`, `config.m4` and CI. Legacy `cfg/701/` through `cfg/704/` and `config.w32` are retained source, not evidence of current PHP 7, Windows or ZTS support. +The supported release target is Linux, non-thread-safe PHP 8.3, 8.4, 8.5 and 8.6, as declared by `composer.json`, `config.m4` and CI. Legacy `cfg/701/` through `cfg/704/` and `config.w32` are retained source, not evidence of current PHP 7, Windows or ZTS support. ## Architecture and navigation @@ -36,7 +36,7 @@ make -j"$(nproc)" NO_INTERACTION=1 REPORT_EXIT_STATUS=1 make test ``` -CI runs these on PHP 8.3, 8.4 and 8.5 NTS. A pass on one runtime does not establish the whole matrix. Inspect skips as well as failures, especially tests requiring native export or HTTP request helpers. There is no PHPUnit or Composer test script; Composer metadata describes a PHP extension. +CI runs these on PHP 8.3, 8.4, 8.5 and 8.6 NTS. A pass on one runtime does not establish the whole matrix. Inspect skips as well as failures, especially tests requiring native export or HTTP request helpers. There is no PHPUnit or Composer test script; Composer metadata describes a PHP extension. For changed PHP helpers use `php -l path/to/file.php`; for benchmark shell changes use `bash -n path/to/script.sh`. CI also rejects trailing whitespace. These syntax checks do not replace PHPT behavior checks. diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8a1fad8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## 2.1.4 + +- Support Linux NTS PHP 8.6 while retaining PHP 8.3–8.5 compatibility. +- Replace removed Zend INI macros with version-compatible functions and preserve const-correct string access. +- Add PHP 8.6 to the strict CI matrix and cover partial function application in the PHPT suite. diff --git a/README.md b/README.md index 3ea37dd..f5157bc 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ across an entire suite, not for a standalone request report. ## Requirements and installation -Release 2.1.3 supports Linux, NTS PHP 8.3, 8.4, and 8.5. It uses the extension +The source supports Linux, NTS PHP 8.3, 8.4, 8.5, and 8.6. It uses the extension name `pcov`, so it replaces and cannot be loaded beside official PCOV. Install with [PIE](https://github.com/php/pie), the PHP extension installer: diff --git a/composer.json b/composer.json index 341dabf..b271b16 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "docs": "https://github.com/MageLens/pcov#readme" }, "require": { - "php": ">=8.3 <8.6" + "php": ">=8.3 <8.7" }, "conflict": { "pecl/pcov": "*" diff --git a/config.m4 b/config.m4 index ae8667b..f9b01d0 100644 --- a/config.m4 +++ b/config.m4 @@ -16,8 +16,8 @@ if test "$PHP_PCOV" != "no"; then AC_MSG_CHECKING(PHP version) - if test $PHP_VERSION -lt 80300 -o $PHP_VERSION -ge 80600; then - AC_MSG_ERROR([this PCOV release supports PHP 8.3, 8.4, and 8.5]) + if test $PHP_VERSION -lt 80300 -o $PHP_VERSION -ge 80700; then + AC_MSG_ERROR([this PCOV release supports PHP 8.3, 8.4, 8.5, and 8.6]) fi AC_MSG_RESULT($PHP_VERSION) diff --git a/pcov.c b/pcov.c index 06911bb..6209b69 100644 --- a/pcov.c +++ b/pcov.c @@ -103,7 +103,7 @@ PHP_PCOV_API bool php_pcov_api_enabled(void) { return false; } - return INI_BOOL("pcov.enabled"); + return zend_ini_long(ZEND_STRL("pcov.enabled"), 0); } #define PHP_PCOV_API_ENABLED_GUARD() do { \ @@ -458,7 +458,7 @@ const char *php_pcov_directory_defaults[] = { /* {{{ */ NULL }; /* }}} */ -static void php_pcov_setup_directory(char *directory) { /* {{{ */ +static void php_pcov_setup_directory(const char *directory) { /* {{{ */ char realpath[MAXPATHLEN]; zend_stat_t statbuf; @@ -483,7 +483,7 @@ static void php_pcov_setup_directory(char *directory) { /* {{{ */ PCG(directory) = zend_string_init(directory, strlen(directory), 0); } /* }}} */ -static zend_always_inline void php_pcov_setup_exclude(char *exclude) { /* {{{ */ +static zend_always_inline void php_pcov_setup_exclude(const char *exclude) { /* {{{ */ zend_string *pattern; if (!exclude || !*exclude) { @@ -517,22 +517,22 @@ PHP_RINIT_FUNCTION(pcov) return SUCCESS; } - PCG(mem) = zend_arena_create(INI_INT("pcov.initial.memory")); + PCG(mem) = zend_arena_create(zend_ini_long(ZEND_STRL("pcov.initial.memory"), 0)); - zend_hash_init(&PCG(files), INI_INT("pcov.initial.files"), NULL, php_pcov_files_dtor, 0); - zend_hash_init(&PCG(waiting), INI_INT("pcov.initial.files"), NULL, NULL, 0); - zend_hash_init(&PCG(ignores), INI_INT("pcov.initial.files"), NULL, NULL, 0); - zend_hash_init(&PCG(wants), INI_INT("pcov.initial.files"), NULL, NULL, 0); - zend_hash_init(&PCG(discovered), INI_INT("pcov.initial.files"), NULL, ZVAL_PTR_DTOR, 0); - zend_hash_init(&PCG(covered), INI_INT("pcov.initial.files"), NULL, php_pcov_covered_dtor, 0); - zend_hash_init(&PCG(fingerprints), INI_INT("pcov.initial.files"), NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(&PCG(files), zend_ini_long(ZEND_STRL("pcov.initial.files"), 0), NULL, php_pcov_files_dtor, 0); + zend_hash_init(&PCG(waiting), zend_ini_long(ZEND_STRL("pcov.initial.files"), 0), NULL, NULL, 0); + zend_hash_init(&PCG(ignores), zend_ini_long(ZEND_STRL("pcov.initial.files"), 0), NULL, NULL, 0); + zend_hash_init(&PCG(wants), zend_ini_long(ZEND_STRL("pcov.initial.files"), 0), NULL, NULL, 0); + zend_hash_init(&PCG(discovered), zend_ini_long(ZEND_STRL("pcov.initial.files"), 0), NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(&PCG(covered), zend_ini_long(ZEND_STRL("pcov.initial.files"), 0), NULL, php_pcov_covered_dtor, 0); + zend_hash_init(&PCG(fingerprints), zend_ini_long(ZEND_STRL("pcov.initial.files"), 0), NULL, ZVAL_PTR_DTOR, 0); PCG(compile_fingerprint_ns) = 0; PCG(compile_fingerprint_files) = 0; memset(&PCG(compile_fingerprint_metrics), 0, sizeof(PCG(compile_fingerprint_metrics))); - php_pcov_setup_directory(INI_STR("pcov.directory")); - php_pcov_setup_exclude(INI_STR("pcov.exclude")); + php_pcov_setup_directory(zend_ini_string_ex(ZEND_STRL("pcov.directory"), 0, NULL)); + php_pcov_setup_exclude(zend_ini_string_ex(ZEND_STRL("pcov.exclude"), 0, NULL)); #ifdef ZEND_COMPILE_NO_JUMPTABLES CG(compiler_options) |= ZEND_COMPILE_NO_JUMPTABLES; @@ -600,8 +600,8 @@ PHP_RSHUTDOWN_FUNCTION(pcov) PHP_MINFO_FUNCTION(pcov) { char info[64]; - char *directory = INI_STR("pcov.directory"); - char *exclude = INI_STR("pcov.exclude"); + const char *directory = zend_ini_string_ex(ZEND_STRL("pcov.directory"), 0, NULL); + const char *exclude = zend_ini_string_ex(ZEND_STRL("pcov.exclude"), 0, NULL); (void) zend_module; php_info_print_table_start(); @@ -614,10 +614,10 @@ PHP_MINFO_FUNCTION(pcov) PHP_PCOV_VERSION); php_info_print_table_row(2, "pcov.large_codebase", - INI_BOOL("pcov.large_codebase") ? "enabled" : "disabled"); + zend_ini_long(ZEND_STRL("pcov.large_codebase"), 0) ? "enabled" : "disabled"); php_info_print_table_row(2, "pcov.request_magento_cache", - INI_BOOL("pcov.request_magento_cache") ? "enabled" : "disabled"); + zend_ini_long(ZEND_STRL("pcov.request_magento_cache"), 0) ? "enabled" : "disabled"); php_info_print_table_row(2, "pcov.directory", directory && *directory ? directory : (PCG(directory) ? ZSTR_VAL(PCG(directory)) : "auto")); @@ -627,13 +627,13 @@ PHP_MINFO_FUNCTION(pcov) snprintf(info, sizeof(info), ZEND_LONG_FMT " bytes", - (zend_long) INI_INT("pcov.initial.memory")); + (zend_long) zend_ini_long(ZEND_STRL("pcov.initial.memory"), 0)); php_info_print_table_row(2, "pcov.initial.memory", info); snprintf(info, sizeof(info), ZEND_LONG_FMT, - (zend_long) INI_INT("pcov.initial.files")); + (zend_long) zend_ini_long(ZEND_STRL("pcov.initial.files"), 0)); php_info_print_table_row(2, "pcov.initial.files", info); @@ -1037,7 +1037,7 @@ PHP_NAMED_FUNCTION(php_pcov_clear) PCG(mem) = zend_arena_create( - INI_INT("pcov.initial.memory")); + zend_ini_long(ZEND_STRL("pcov.initial.memory"), 0)); PCG(start) = NULL; PCG(last) = NULL; diff --git a/php_pcov.h b/php_pcov.h index a132dfb..a156f0b 100644 --- a/php_pcov.h +++ b/php_pcov.h @@ -21,7 +21,7 @@ extern zend_module_entry pcov_module_entry; #define phpext_pcov_ptr &pcov_module_entry -#define PHP_PCOV_VERSION "2.1.3" +#define PHP_PCOV_VERSION "2.1.4" #ifdef PHP_WIN32 # define PHP_PCOV_API __declspec(dllexport) diff --git a/tests/php86_partial.phpt b/tests/php86_partial.phpt new file mode 100644 index 0000000..e40b376 --- /dev/null +++ b/tests/php86_partial.phpt @@ -0,0 +1,32 @@ +--TEST-- +PHP 8.6 partial function application preserves covered and uncovered lines +--SKIPIF-- + +--INI-- +pcov.enabled = 1 +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) From 555cbde1f7deb52a850215d581807910b3e68f35 Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 28 Nov 2026 01:12:29 +0000 Subject: [PATCH 2/3] fix: preserve PHP 8.6 native compilation --- CHANGELOG.md | 2 +- pcov.c | 4 ++++ pcov_request_cache.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a1fad8..d33f89b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,5 +3,5 @@ ## 2.1.4 - Support Linux NTS PHP 8.6 while retaining PHP 8.3–8.5 compatibility. -- Replace removed Zend INI macros with version-compatible functions and preserve const-correct string access. +- Replace removed Zend INI macros with version-compatible functions and preserve const-correct string access and PHP 8.6 CFG index types. - Add PHP 8.6 to the strict CI matrix and cover partial function application in the PHPT suite. diff --git a/pcov.c b/pcov.c index 6209b69..ce8731a 100644 --- a/pcov.c +++ b/pcov.c @@ -672,7 +672,11 @@ static void php_pcov_discover_code( zend_cfg cfg; zend_basic_block *block; zend_op *limit = ops->opcodes + ops->last; +#if PHP_VERSION_ID >= 80600 + uint32_t i = 0; +#else int i = 0; +#endif if (ops->fn_flags & ZEND_ACC_ABSTRACT) { return; diff --git a/pcov_request_cache.h b/pcov_request_cache.h index b12b56c..6789a7a 100644 --- a/pcov_request_cache.h +++ b/pcov_request_cache.h @@ -94,6 +94,7 @@ static zend_string *php_pcov_request_cache_context(zend_string *path) { /* Compare native bytes against the CURRENT validated files and sorted hits. * No URL-only hit can suppress new coverage or reuse a different filter result. * Entries are trusted process-owned records, but bounds are still checked. */ +#ifndef ZTS static zend_bool php_pcov_request_cache_matches(zend_string *record, php_pcov_manifest_file_t *files, size_t file_count, php_pcov_dump_hit_t *hits, size_t hit_count, @@ -131,6 +132,7 @@ static zend_bool php_pcov_request_cache_matches(zend_string *record, #undef PCOV_CACHE_U32 return cursor == end && hit == hit_count; } +#endif static zend_string *php_pcov_request_cache_lookup(zend_string *context, php_pcov_manifest_file_t *files, size_t file_count, From fa08aa47455b8f82173e0e7afcdb4a1941c1dcf0 Mon Sep 17 00:00:00 2001 From: Vitalii Boiko Date: Sat, 28 Nov 2026 13:22:43 +0200 Subject: [PATCH 3/3] fix: run PHP 8.6 CI on NTS image and guard NTS-only cache tests --- .github/workflows/ci.yml | 16 ++++++++++++---- tests/045.phpt | 2 +- tests/046.phpt | 2 +- tests/047.phpt | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2d6d26..ecd91fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,11 +11,19 @@ jobs: linux-nts: name: PHP ${{ matrix.php }} NTS runs-on: ubuntu-latest - container: php:${{ matrix.php }}-cli + container: ${{ matrix.image }} strategy: fail-fast: false matrix: - php: ["8.3", "8.4", "8.5", "8.6"] + include: + - php: "8.3" + image: php:8.3-cli + - php: "8.4" + image: php:8.4-cli + - php: "8.5" + image: php:8.5-cli + - php: "8.6" + image: php:8.6-nts steps: - name: Install build tools @@ -32,9 +40,9 @@ jobs: exit 1 fi - - name: Validate package metadata + - name: Validate package metadata and NTS runtime run: | - php -r "\$json = json_decode(file_get_contents('composer.json'), true, flags: JSON_THROW_ON_ERROR); assert(\$json['type'] === 'php-ext');" + php -d zend.assertions=1 -r "\$json = json_decode(file_get_contents('composer.json'), true, flags: JSON_THROW_ON_ERROR); assert(\$json['type'] === 'php-ext'); assert(!PHP_ZTS);" - name: Configure and build with strict warnings run: | diff --git a/tests/045.phpt b/tests/045.phpt index becd875..290fd5e 100644 --- a/tests/045.phpt +++ b/tests/045.phpt @@ -1,7 +1,7 @@ --TEST-- Native Magento cache needs only the flag and preserves actual hits with the unchanged collector --SKIPIF-- - + --INI-- pcov.enabled=1 pcov.large_codebase=1 diff --git a/tests/046.phpt b/tests/046.phpt index 5007f9d..de2b2ad 100644 --- a/tests/046.phpt +++ b/tests/046.phpt @@ -1,7 +1,7 @@ --TEST-- Native Magento coverage cache works with private no-store responses and stays bounded --SKIPIF-- - + --INI-- pcov.enabled=1 pcov.large_codebase=1 diff --git a/tests/047.phpt b/tests/047.phpt index f209fd8..ef8e123 100644 --- a/tests/047.phpt +++ b/tests/047.phpt @@ -1,7 +1,7 @@ --TEST-- Native Magento cache never bypasses deployment manifest or source validation --SKIPIF-- - + --INI-- pcov.enabled=1 pcov.large_codebase=1