From 788418cfe1da5d0c3331e4c812ab96c4834eed8f Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Fri, 4 Dec 2026 15:48:33 +0100 Subject: [PATCH] #87 - Add PHP 8.6 support: tests on PHP 8.6, PHPStan and Rector on PHP 8.6, require symfony/polyfill-php86 and symfony/dependency-injection 7.4.17 or 8.1.5 Co-Authored-By: Claude Opus 5.5 --- .docker/php/Dockerfile | 3 +++ .github/workflows/quality.yml | 6 ++++-- .github/workflows/test.yml | 20 +++++++++++++++++--- CHANGELOG.md | 1 + CONTRIBUTING.md | 6 +++--- composer.json | 3 ++- 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile index a4c0c3c..e665b13 100644 --- a/.docker/php/Dockerfile +++ b/.docker/php/Dockerfile @@ -1,3 +1,6 @@ +# Stays on PHP 8.5 until a pcov release builds on PHP 8.6 (1.0.12 does not, krakjoe/pcov#134) and PHP-CS-Fixer supports +# it (PHP-CS-Fixer/PHP-CS-Fixer#9954). The php:8.6 images no longer ship mbstring: install it with oniguruma-dev, +# without deleting oniguruma afterwards (libonig is needed at runtime). FROM php:8.5-fpm-alpine ARG UID diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 48d69e1..3eba3d9 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -45,7 +45,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2 with: - php-version: '8.5' + php-version: '8.6' coverage: none tools: composer:v2 - name: Install Composer dependencies (locked) @@ -63,6 +63,8 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2 with: + # PHP-CS-Fixer does not support PHP 8.6 yet (it refuses to run on it): stay on 8.5 until a release supports + # it, see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/9954 php-version: '8.5' coverage: none tools: composer:v2 @@ -81,7 +83,7 @@ jobs: - name: Install PHP with extensions uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2 with: - php-version: '8.5' + php-version: '8.6' coverage: none tools: composer:v2 - name: Install Composer dependencies (locked) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e8c2d0..51ef9d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,13 +33,15 @@ jobs: # Lowest versions allowed by composer.json, on the lowest and the highest supported PHP versions (the old # versions of a dependency may trigger deprecations of the recent PHP versions) - { php-version: '8.3', dependencies: lowest, symfony-require: '' } - - { php-version: '8.5', dependencies: lowest, symfony-require: '' } + - { php-version: '8.6', dependencies: lowest, symfony-require: '' } # Highest versions, for each supported Symfony version (8.x requires PHP 8.4) - { php-version: '8.3', dependencies: highest, symfony-require: 7.4.* } - { php-version: '8.4', dependencies: highest, symfony-require: 7.4.* } - { php-version: '8.4', dependencies: highest, symfony-require: 8.* } - { php-version: '8.5', dependencies: highest, symfony-require: 7.4.* } - { php-version: '8.5', dependencies: highest, symfony-require: 8.* } + - { php-version: '8.6', dependencies: highest, symfony-require: 7.4.* } + - { php-version: '8.6', dependencies: highest, symfony-require: 8.* } steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 @@ -47,8 +49,20 @@ jobs: uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2 with: php-version: ${{ matrix.php-version }} - coverage: pcov - tools: composer:v2, flex + # No pcov release builds on PHP 8.6 yet (1.0.12 fails): it is built from source in the next step + coverage: ${{ matrix.php-version == '8.6' && 'none' || 'pcov' }} + tools: composer:v2, flex, phpize, php-config + # Coverage is required: a missing #[CoversClass] / #[UsesClass] is only reported as risky when it is collected. + # The PHP 8.6 build fix (krakjoe/pcov#134) is not released yet: remove this step and the coverage condition + # above once a pcov release supports PHP 8.6. + - name: Build pcov from source (PHP 8.6) + if: matrix.php-version == '8.6' + run: | + curl -fsSL https://github.com/krakjoe/pcov/archive/3795c08561d69ca7f55f693492de59a65a6a182d.tar.gz | tar xz -C /tmp + cd /tmp/pcov-3795c08561d69ca7f55f693492de59a65a6a182d + phpize && ./configure && make -j"$(nproc)" && sudo make install + echo 'extension=pcov' | sudo tee "$(php-config --ini-dir)/20-pcov.ini" + php --ri pcov - name: Add PHPUnit matcher run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Install Composer dependencies (${{ matrix.dependencies }}) diff --git a/CHANGELOG.md b/CHANGELOG.md index be618ae..9f8c1ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Latest ### Changes * [#84](https://github.com/cleverage/cache-process-bundle/issues/84) Tests on PHPUnit 12.5 and 13 (PHPUnit 10 and 11 dropped), with the lowest dependencies on PHP 8.3 and 8.5. +* [#87](https://github.com/cleverage/cache-process-bundle/issues/87) Support PHP 8.6: tests on PHP 8.6 (lowest dependencies, highest with Symfony 7.4 and 8.x), PHPStan and Rector on PHP 8.6, `symfony/polyfill-php86` is required so that the PHP 8.6 functions can be used on PHP 8.3 to 8.5, `symfony/dependency-injection` 7.4.17 or 8.1.5 is required (the former versions call `spl_object_hash()`, deprecated by PHP 8.6). v2.4 ------ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e84ad0c..da86366 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,9 +43,9 @@ make tests ## PHP version The bundle supports PHP 8.3 and later: do not use a syntax introduced by a later version (property hooks, asymmetric -visibility, pipe operator...). The functions of PHP 8.4 and 8.5 (`array_find()`, `array_any()`, `mb_trim()`, -`array_first()`...) can be used: they are provided by the required `symfony/polyfill-php84` and -`symfony/polyfill-php85` packages on the older versions. Rector (`make quality`) is configured accordingly. +visibility, pipe operator...). The functions of PHP 8.4, 8.5 and 8.6 (`array_find()`, `array_any()`, `mb_trim()`, +`array_first()`, `clamp()`...) can be used: they are provided by the required `symfony/polyfill-php84`, +`symfony/polyfill-php85` and `symfony/polyfill-php86` packages on the older versions. Rector (`make quality`) is configured accordingly. ## Deprecations notices diff --git a/composer.json b/composer.json index c39ef15..49e033d 100644 --- a/composer.json +++ b/composer.json @@ -55,12 +55,13 @@ "psr/cache": "^2|^3", "symfony/cache": "^7.4|^8", "symfony/config": "^7.4|^8", - "symfony/dependency-injection": "^7.4|^8", + "symfony/dependency-injection": "^7.4.17|^8.1.5", "symfony/deprecation-contracts": "^2.5|^3", "symfony/http-kernel": "^7.4|^8", "symfony/options-resolver": "^7.4|^8", "symfony/polyfill-php84": "^1.33", "symfony/polyfill-php85": "^1.33", + "symfony/polyfill-php86": "^1.34", "symfony/service-contracts": "^2.5|^3" }, "require-dev": {