Skip to content

Support PHP 8.5 and work around deprecated method aliases and casts#1118

Open
clue wants to merge 1 commit into
ratchetphp:0.4.xfrom
clue-labs:php8.5
Open

Support PHP 8.5 and work around deprecated method aliases and casts#1118
clue wants to merge 1 commit into
ratchetphp:0.4.xfrom
clue-labs:php8.5

Conversation

@clue
Copy link
Copy Markdown
Member

@clue clue commented Jun 6, 2026

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/rfc6455 v0.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(), and contains() method aliases (now using offsetSet(), offsetUnset(), and offsetExists() instead) and the non-canonical (boolean) cast (now using (bool) instead). The test suite also guards ReflectionMethod/Property::setAccessible() calls with if (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

@clue clue added this to the 0.4.5 milestone Jun 6, 2026
@clue clue requested a review from Copilot June 6, 2026 23:04
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 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 with offset{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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants