Skip to content

Support PHP 8.0–8.5#20

Merged
rick-lam merged 2 commits into
masterfrom
support-php-8
May 28, 2026
Merged

Support PHP 8.0–8.5#20
rick-lam merged 2 commits into
masterfrom
support-php-8

Conversation

@rick-lam
Copy link
Copy Markdown
Contributor

Summary

Widens the PHP requirement from ^7.4 to ^7.4 || ^8.0 so the library can be installed on PHP 8.0 through 8.5.

Changes

File(s) Change Why
composer.json php: ^7.4^7.4 || ^8.0 Allow installs on PHP 8.x
src/Terminal/Terminal.php, src/DiffConsoleOutput.php, src/Diff/ConsoleDiff.php Added explicit ? to nullable constructor parameters (?T $param = null instead of T $param = null) PHP 8.4 deprecates implicit-nullable parameters. Forward-compatible with PHP 7.4
.github/workflows/ci.yml Matrix expanded: highest runs on PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5; lowest stays pinned to PHP 7.4 only The floor of each dependency lives at PHP 7.4 (e.g. symfony/console 3.4 and mockery 1.3 don't run on PHP 8.x). Running --prefer-lowest on PHP 8 would happily install those — composer doesn't reject them since their composer.json has no upper PHP bound — but they'd fail at runtime. Restricting lowest to 7.4 tests what we actually care about
composer.lock Regenerated against the new constraint Pick up the wider PHP range

Verification

Verified locally on PHP 7.4 (Docker graze/php-alpine:7.4-test) and PHP 8.5 (host): phpcs clean, 112 PHPUnit tests pass under both.

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 28, 2026 10:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR broadens the package’s declared PHP support to include PHP 8.x and updates constructor signatures to avoid PHP 8.4 implicit-nullable deprecations.

Changes:

  • Widened Composer PHP requirement from PHP 7.4 only to PHP 7.4 or PHP 8.x.
  • Added explicit nullable type declarations for constructor parameters that default to null.
  • Expanded CI to run highest-dependency tests across PHP 7.4–8.5, while keeping lowest-dependency testing on PHP 7.4.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
composer.json Widens the package PHP requirement.
composer.lock Updates lockfile metadata for the widened PHP platform constraint.
.github/workflows/ci.yml Expands CI PHP matrix and keeps lowest dependency job on PHP 7.4.
src/Terminal/Terminal.php Makes nullable constructor parameters explicit.
src/DiffConsoleOutput.php Makes nullable constructor parameters explicit.
src/Diff/ConsoleDiff.php Makes nullable constructor parameter explicit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread composer.json
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) <noreply@anthropic.com>
@rick-lam rick-lam merged commit 029e693 into master May 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants