Skip to content

Issue/595 Raise the minimum PHP version to 8.1 and test 8.1, 8.2 and 8.3 in CI - #600

Merged
armanist merged 6 commits into
quantum-php:masterfrom
armanist:issue/595-php-8-1-minimum
Oct 23, 2026
Merged

armanist merged 6 commits into
quantum-php:masterfrom
armanist:issue/595-php-8-1-minimum

Conversation

@armanist

@armanist armanist commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #595. The changelog entry is written in a final pull request, after the sub-issues (#596 to #599 and #601).

What changed

  • composer.json requires php ^8.1, and PHPStan analyses the code as PHP 8.1.
  • ResponseHeaders (offsetGet, current, key) and DatabaseHandler (gc) declare the return types PHP 8.1 expects: mixed and int|false, both valid on PHP 8.0 too.
  • The CI matrix runs PHP 8.1, 8.2 and 8.3. PHP 8.0 is dropped.
  • DatabaseHandler::gc() returns the number of deleted sessions, as SessionHandlerInterface::gc() documents. It returned 0 after any successful delete, and false when SleekDB had nothing to delete.
  • Rector uses the PHP 8.1 level set, with three rules skipped (see the notes).

Why

PHP 8.0 no longer receives security fixes from the PHP project, and CI never ran a branch newer than 8.2.

Raising the minimum exposed a bug that is already on master. On PHP 8.1 and newer, ResponseHeaders and DatabaseHandler raise a deprecation when the class loads, because the interface methods they implement have return types. Quantum's error handler throws an ErrorException for every reported error, so in an application that reports deprecations (the PHP default in development) loading either class is a fatal error. The test suite never saw it because phpunit.xml sets error_reporting to E_ALL & ~E_DEPRECATED.

Breaking changes

  • PHP 8.0 can no longer install the framework. Applications on PHP 8.0 stay on 3.0.x.

Testing

  • ResponseHeadersTest and the new DatabaseHandlerTest check that each method of the interfaces they implement declares a return type. The cases for offsetGet, current, key and gc fail without the change.
  • Loading every class file under src on PHP 8.1 with all errors reported: 4 deprecations before the change, 0 after.
  • gc() is covered by tests that insert the sessions directly (a handler serves one session, so writing several through one handler overwrites a single row): two expired sessions and one active session return 2 and keep the active one; no expired session returns 0; a failing delete returns false. The first fails without the change.
  • Before the gc() and Rector commits, the full suite on PHP 8.0 and 8.1 gave the same results as master apart from the added tests.
  • PHPStan targeting PHP 8.3 with dynamic property checks enabled reports nothing.
  • Known gap: PHP 8.2 and 8.3 run only in CI. The Redis and Memcached tests also run only in CI.

Notes for reviewers

Summary by CodeRabbit

  • Compatibility
    • The minimum supported PHP version is now 8.1. Compatibility checks cover PHP 8.1, 8.2, and 8.3.
  • Bug Fixes
    • Expired-session cleanup now reports how many sessions were deleted, returns zero when none were expired, and reports failure when deletion fails.
  • Developer Updates
    • Added explicit return types to response-header and database-session methods.
    • Added tests for return types and session-cleanup results.

…eHeaders and DatabaseHandler

On PHP 8.1 and newer, ResponseHeaders (offsetGet, current, key) and DatabaseHandler (gc) raise a deprecation when the class loads, because the interface methods they implement have return types. Quantum's error handler turns a reported deprecation into an exception, which is a fatal error during class loading. The methods now declare mixed and int|false, which are valid on PHP 8.0 too.
composer.json requires ^8.1 and PHPStan analyses the code as PHP 8.1. Applications on PHP 8.0 stay on 3.0.x.
The matrix drops PHP 8.0, which no longer receives security fixes and is below the new minimum, and adds 8.3.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bff07437-0775-40d9-bcae-89d86cd5bf09
📥 Commits

Reviewing files that changed from the base of the PR and between 514dcaf and 3acc171.

📒 Files selected for processing: 3
  • rector.php
  • src/Session/Adapters/Database/DatabaseHandler.php
  • tests/Unit/Session/Adapters/Database/DatabaseHandlerTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The package now requires PHP 8.1 or later. CI, PHPStan, and Rector target PHP 8.1. Selected methods declare return types, and tests cover those declarations and database session garbage collection.

Changes: PHP 8.1 Compatibility

Layer / File(s) Summary
Set PHP version targets
composer.json, phpstan.neon.dist, .github/workflows/php.yml, rector.php
Composer now requires PHP ^8.1. PHPStan and Rector target PHP 8.1, with specified Rector rules skipped. The CI matrix now covers PHP 8.1, 8.2, and 8.3.
Declare and test ResponseHeaders return types
src/HttpClient/ResponseHeaders.php, tests/Unit/HttpClient/ResponseHeadersTest.php
Three ResponseHeaders methods now declare mixed return types. A reflection-based test checks the return-type declarations of the listed interface methods.
Count database session garbage collection
src/Session/Adapters/Database/DatabaseHandler.php, tests/Unit/Session/Adapters/Database/DatabaseHandlerTest.php
DatabaseHandler::gc now declares `int

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Other

Possibly related issues

  • Issue 595 describes the PHP 8.1 minimum, return types, PHPStan target, and CI matrix updated here.
  • Issue 601 concerns the Rector PHP 8.1 update and the skipped readonly-property and first-class-callable transformations.

Suggested reviewers: andrey-smaelov

Merge Risk: ⚪ Minimal · up to 3acc1

No issue identified here requires a change before merging; normal validation can proceed.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 58.82% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main changes: raising the minimum PHP version to 8.1 and updating the CI test matrix to PHP 8.1, 8.2, and 8.3.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

gc() had no test. It now has one for deleting the expired sessions and keeping the others, and one for returning false when the sessions cannot be deleted.

@andrey-smaelov andrey-smaelov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In rector config the php version also need to be rasied to 8.1

Comment thread tests/Unit/Session/Adapters/Database/DatabaseHandlerTest.php Outdated
…Handler::gc()

SessionHandlerInterface::gc() returns the number of deleted sessions, or false on failure. The handler returned 0 after any successful delete, and returned false when SleekDB had nothing to delete. It now counts the expired sessions first: 0 when there are none, otherwise the number deleted. The tests insert the sessions directly, because one handler serves one session.
ReadOnlyPropertyRector and the two first-class callable rules are skipped, because applying them changes 52 files and breaks four tests. They are applied in a separate change.
@armanist
armanist merged commit 22f2d5b into quantum-php:master Oct 23, 2026
7 checks passed
@armanist
armanist deleted the issue/595-php-8-1-minimum branch October 23, 2026 12:54
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