Repository navigation
Issue/595 Raise the minimum PHP version to 8.1 and test 8.1, 8.2 and 8.3 in CI - #600
Conversation
…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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
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
left a comment
There was a problem hiding this comment.
In rector config the php version also need to be rasied to 8.1
…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.
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.jsonrequiresphp^8.1, and PHPStan analyses the code as PHP 8.1.ResponseHeaders(offsetGet,current,key) andDatabaseHandler(gc) declare the return types PHP 8.1 expects:mixedandint|false, both valid on PHP 8.0 too.DatabaseHandler::gc()returns the number of deleted sessions, asSessionHandlerInterface::gc()documents. It returned0after any successful delete, andfalsewhen SleekDB had nothing to delete.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,ResponseHeadersandDatabaseHandlerraise a deprecation when the class loads, because the interface methods they implement have return types. Quantum's error handler throws anErrorExceptionfor 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 becausephpunit.xmlsetserror_reportingtoE_ALL & ~E_DEPRECATED.Breaking changes
Testing
ResponseHeadersTestand the newDatabaseHandlerTestcheck that each method of the interfaces they implement declares a return type. The cases foroffsetGet,current,keyandgcfail without the change.srcon 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 return2and keep the active one; no expired session returns0; a failing delete returnsfalse. The first fails without the change.gc()and Rector commits, the full suite on PHP 8.0 and 8.1 gave the same results asmasterapart from the added tests.Notes for reviewers
ReadOnlyPropertyRectorand the two first-class callable rules skipped. Applying them changes 52 files and breaks four tests (two that replace a property by reflection, two that inspect the array callableErrorHandlerregisters), so they are applied in a separate change, Adopt the PHP 8.1 syntax Rector proposes and remove its skips #601.NULL. That is tracked in Fix the PDO::quote() null deprecation in Idiorm query logging on PHP 8.1+ #598.doctrine/annotations(Write the OpenAPI docs in the API templates as attributes and drop doctrine/annotations #597), allowingpsr/log3 (Allow psr/log 3 next to psr/log 2 #599), and adopting the PHP 8.1 syntax Rector proposes (Adopt the PHP 8.1 syntax Rector proposes and remove its skips #601).Summary by CodeRabbit