Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
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
Expand All @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 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.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
Expand Down
4 changes: 2 additions & 2 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
44 changes: 24 additions & 20 deletions pcov.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down Expand Up @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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"));
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1037,7 +1041,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;
Expand Down
2 changes: 2 additions & 0 deletions pcov_request_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion php_pcov.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/045.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Native Magento cache needs only the flag and preserves actual hits with the unchanged collector
--SKIPIF--
<?php if (!extension_loaded('pcov') || !function_exists('proc_open')) print 'skip'; ?>
<?php if (!extension_loaded('pcov') || !function_exists('proc_open')) print 'skip'; elseif (PHP_ZTS) print 'skip NTS required'; ?>
--INI--
pcov.enabled=1
pcov.large_codebase=1
Expand Down
2 changes: 1 addition & 1 deletion tests/046.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Native Magento coverage cache works with private no-store responses and stays bounded
--SKIPIF--
<?php if (!extension_loaded('pcov') || !function_exists('proc_open')) print 'skip'; ?>
<?php if (!extension_loaded('pcov') || !function_exists('proc_open')) print 'skip'; elseif (PHP_ZTS) print 'skip NTS required'; ?>
--INI--
pcov.enabled=1
pcov.large_codebase=1
Expand Down
2 changes: 1 addition & 1 deletion tests/047.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Native Magento cache never bypasses deployment manifest or source validation
--SKIPIF--
<?php if (!extension_loaded('pcov') || !function_exists('proc_open')) print 'skip'; ?>
<?php if (!extension_loaded('pcov') || !function_exists('proc_open')) print 'skip'; elseif (PHP_ZTS) print 'skip NTS required'; ?>
--INI--
pcov.enabled=1
pcov.large_codebase=1
Expand Down
32 changes: 32 additions & 0 deletions tests/php86_partial.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
PHP 8.6 partial function application preserves covered and uncovered lines
--SKIPIF--
<?php
if (!extension_loaded("pcov")) die("skip pcov required");
if (PHP_VERSION_ID < 80600) die("skip PHP 8.6 required");
?>
--INI--
pcov.enabled = 1
--FILE--
<?php
function partialTarget($prefix, $value) {
return $prefix . $value;
}
function unusedTarget($value) {
return $value;
}
\pcov\start();
$partial = partialTarget('prefix-', ?);
$result = $partial('value');
\pcov\stop();
$lines = \pcov\collect()[__FILE__];
var_dump($result === 'prefix-value');
var_dump($lines[3] === 1);
var_dump($lines[6] === -1);
var_dump($lines[9] === 1 && $lines[10] === 1);
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
Loading