Support PHP 8.5 and work around deprecated method aliases and casts#1118
Open
clue wants to merge 1 commit into
Open
Support PHP 8.5 and work around deprecated method aliases and casts#1118clue wants to merge 1 commit into
clue wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Ratchet to run cleanly on PHP 8.5 by removing usages of newly-deprecated aliases/casts and updating the CI matrix to include PHP 8.5, keeping compatibility with older PHP versions via conditional reflection access.
Changes:
- Replace
SplObjectStorage::{attach,detach,contains}()alias calls withoffset{Set,Unset,Exists}()across runtime code and tests. - Replace non-canonical
(boolean)casts with(bool). - Guard
ReflectionMethod/Property::setAccessible()calls for PHP < 8.1 and add PHP 8.5 to CI.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/Wamp/TopicManagerTest.php | Avoid deprecated reflection setAccessible() on PHP 8.1+; update subscription membership checks to offsetExists(). |
| tests/unit/Wamp/ServerProtocolTest.php | Guard reflection setAccessible() for PHP < 8.1. |
| tests/unit/Session/SessionProviderTest.php | Guard reflection setAccessible() for PHP < 8.1. |
| tests/unit/AppTest.php | Guard reflection setAccessible() for PHP < 8.1. |
| tests/unit/AbstractConnectionDecoratorTest.php | Guard reflection setAccessible() for PHP < 8.1. |
| src/Ratchet/WebSocket/WsServer.php | Replace deprecated SplObjectStorage alias methods with offset* equivalents. |
| src/Ratchet/Wamp/TopicManager.php | Replace deprecated SplObjectStorage alias methods with offset* equivalents for subscription tracking. |
| src/Ratchet/Wamp/Topic.php | Replace deprecated SplObjectStorage alias methods with offset* equivalents for subscriber tracking. |
| src/Ratchet/Wamp/ServerProtocol.php | Replace deprecated SplObjectStorage alias methods; switch (boolean) to (bool) for exclude handling. |
| src/Ratchet/Server/FlashPolicy.php | Switch (boolean) to (bool) when storing the $secure flag. |
| .github/workflows/ci.yml | Add PHP 8.5 to test matrix; update action versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changeset adds support for PHP 8.5 and works around deprecated method aliases and casts. This is part 15 of reviving Ratchet as discussed in #1054, unblocking more future progress.
With these changes applied, the existing test suite recently updated with #1117, #1099, #1097, #1096, #1094, #1093 and #1092 now works fine on PHP 8.5 at last. This aligns with the broader PHP 8.5 rollout across the ReactPHP ecosystem, including the just-released
ratchet/rfc6455v0.4.1 covering ratchetphp/RFC6455#75 and ratchetphp/RFC6455#77, plus recent upstream PHP 8.5 fixes in reactphp/socket#325, reactphp/event-loop#282, and clue/framework-x#297 and related work. Thanks to Ratchet's existing multi-version constraints, no composer.json changes are needed. Composer transparently picks up these latest minor releases on PHP 8.5+ while remaining compatible with legacy PHP 5.4+ on older versions.Specifically, this works around
SplObjectStorage::attach(),detach(), andcontains()method aliases (now usingoffsetSet(),offsetUnset(), andoffsetExists()instead) and the non-canonical(boolean)cast (now using(bool)instead). The test suite also guardsReflectionMethod/Property::setAccessible()calls withif (PHP_VERSION_ID < 80100)since these became no-ops in PHP 8.1+ and were formally deprecated in PHP 8.5.Overall, this required quite a massive effort. If you want to support this project, please consider sponsoring @reactphp ❤️
Builds on top of #1117, #1099, #1097, #1096, #1094, #1093, #1092, #1091 and #1088, one step closer to reviving Ratchet as discussed in #1054