From 2ab9522482a2cae55aac0bafcd0ed331d05d578f Mon Sep 17 00:00:00 2001 From: Rick Lam Date: Thu, 28 May 2026 11:44:59 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Support=20PHP=208.0=E2=80=938.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Widen the PHP requirement from `^7.4` to `^7.4 || ^8.0` so the library can be installed on PHP 8.0 through 8.5. Two changes required for PHP 8.4+ deprecation cleanliness: the constructors of `Terminal`, `DiffConsoleOutput`, and `ConsoleDiff` each took a parameter typed `T $param = null`, which PHP 8.4 deprecates as an implicit-nullable. Made the nullability explicit with the leading `?` (`?T $param = null`). The change is forward- compatible with PHP 7.4. CI matrix expanded to run `highest` resolution against PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5. The `lowest` (`--prefer-lowest`) matrix entry stays pinned to PHP 7.4 only -- it tests the floor of each dependency, which lives at PHP 7.4 (e.g. symfony/console 3.4 and mockery 1.3 don't run on PHP 8.x, even though composer would otherwise happily install them under `--prefer-lowest` because their composer.json declares no upper PHP bound). Verified locally on PHP 7.4 (Docker) and PHP 8.5 (host): phpcs clean, 112 PHPUnit tests pass under both. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/ci.yml | 7 +++++-- composer.json | 2 +- composer.lock | 4 ++-- src/Diff/ConsoleDiff.php | 2 +- src/DiffConsoleOutput.php | 4 ++-- src/Terminal/Terminal.php | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e3b3c9..86b719c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,11 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4'] - dependencies: [highest, lowest] + php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + dependencies: [highest] + include: + - php: '7.4' + dependencies: lowest steps: - uses: actions/checkout@v6 diff --git a/composer.json b/composer.json index edf8ab6..e2349e7 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ } ], "require": { - "php": "^7.4", + "php": "^7.4 || ^8.0", "symfony/console": "^3.4 | ^4.0 | ^5.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 1f1065c..2da5391 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ad3c92c419ec035c3134e447270994bb", + "content-hash": "45bd62a296a29299ed7ec69b6e2332f7", "packages": [ { "name": "psr/container", @@ -2951,7 +2951,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.4" + "php": "^7.4 || ^8.0" }, "platform-dev": {}, "platform-overrides": { diff --git a/src/Diff/ConsoleDiff.php b/src/Diff/ConsoleDiff.php index b9e5693..0197c5b 100644 --- a/src/Diff/ConsoleDiff.php +++ b/src/Diff/ConsoleDiff.php @@ -28,7 +28,7 @@ class ConsoleDiff extends FirstDiff * * @param CursorInterface|null $cursor The cursor used to move around the screen */ - public function __construct(CursorInterface $cursor = null) + public function __construct(?CursorInterface $cursor = null) { $this->cursor = $cursor ?: new ANSI(); } diff --git a/src/DiffConsoleOutput.php b/src/DiffConsoleOutput.php index 7fb3e91..97cb9fd 100644 --- a/src/DiffConsoleOutput.php +++ b/src/DiffConsoleOutput.php @@ -49,8 +49,8 @@ class DiffConsoleOutput implements OutputInterface */ public function __construct( OutputInterface $output, - TerminalInterface $terminal = null, - Wrapper $wrapper = null + ?TerminalInterface $terminal = null, + ?Wrapper $wrapper = null ) { $this->output = $output; $this->terminal = $terminal ?: new Terminal(); diff --git a/src/Terminal/Terminal.php b/src/Terminal/Terminal.php index b57d59b..a3293d1 100644 --- a/src/Terminal/Terminal.php +++ b/src/Terminal/Terminal.php @@ -26,7 +26,7 @@ class Terminal implements TerminalInterface * @param CursorInterface|null $cursor * @param DimensionsInterface $dimensions */ - public function __construct(CursorInterface $cursor = null, DimensionsInterface $dimensions = null) + public function __construct(?CursorInterface $cursor = null, ?DimensionsInterface $dimensions = null) { $this->cursor = $cursor ?: new ANSI(); $this->dimensions = $dimensions ?: new TerminalDimensions(); From 6ceaa7d7b1a5333f138ec062836a10be0cb3da1a Mon Sep 17 00:00:00 2001 From: Rick Lam Date: Thu, 28 May 2026 11:49:59 +0100 Subject: [PATCH 2/2] ci: align composer platform.php with matrix PHP version Copilot review on PR #20 noted that composer.json's `config.platform.php = 7.4` propagates into the CI jobs, so even the PHP 8.x matrix entries were resolving dependencies as if running on PHP 7.4 -- they were validating "7.4-compatible deps happen to run on 8.x", not "what an 8.x user would install". Add a step before `ramsey/composer-install` that runs `composer config platform.php ${{ matrix.php }}`, overriding the pin per matrix entry. The pin stays at 7.4 in composer.json itself for local-dev lock determinism. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86b719c..55b2a68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,9 @@ jobs: php-version: ${{ matrix.php }} tools: composer:v2 + - name: Align composer platform.php with matrix PHP version + run: composer config platform.php ${{ matrix.php }} + - name: Install dependencies uses: ramsey/composer-install@v4 with: