Support PHP 8.4 and work around reporting implicitly nullable types #1099
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.4 and works around reporting any implicitly nullable types. This is part 10 of reviving Ratchet as discussed in #1054, unblocking more future progress.
With these changes applied, the existing test suite recently updated with #1097, #1096, #1094, #1093 and #1092 now works fine on PHP 8.4 at last. Once merged, this would conclude the recent PHP version improvements, but there's still more than enough work to be done to clean up the project as suggested in #1054 and elsewhere.
Note that this employs a number of workarounds to avoid raising deprecation notices for implicitly nullable types as discussed in reactphp/promise#260 and related tickets. In particular, we can't use proper nullable types like
?LoopInterfacehere without introducing a massive BC break because this requires PHP 7.1+ while this project still supports ancient PHP 5.4+, see #1003 and others. I've applied some clever workarounds originally suggested in reactphp/stream#179 plus clue/framework-x#225 / https://x.com/another_clue/status/1671189006162464768 / https://github.com/reactphp/promise/pull/246/files#r1235943582. I think it's easy to argue this is either hilarious or disgusting (YMMV). While I agree this isn't exactly perfect, I think it's good enough to get this working on newer PHP versions again without applying a major refactoring and introducing any BC breaks. Future PRs to improve this very much welcome.Overall, this required quite a massive effort. If you want to support this project, please consider sponsoring @reactphp ❤️
Builds on top of #1097, #1096, #1094, #1093, #1092, #1091 and #1088, one step closer to reviving Ratchet as discussed in #1054
Resolves / closes #1003