Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP >= 8 support + updated tests and workflow. #1014

Open
wants to merge 89 commits into
base: master
Choose a base branch
from

Conversation

josh-gaby
Copy link

Includes updated tests and workflow for running tests on PHP 5.4 -> 8.2

Also, due to symfony/http-foundation v6+ including return types and Ratchet supporting PHP < 7.0, there is a not very nice hack involving maintaining two versions of two classes (VirtualProxy and VirtualSessionStorage). This is currently working and passing all tests but definitly needs a better solution long-term.

@CViniciusSDias
Copy link

Hey there, @cboden
This PR could re-live the project.
:-D

@neoteknic
Copy link

why php5.4 its useless... just drop php < 8

@josh-gaby
Copy link
Author

why php5.4 its useless... just drop php < 8

Agreed, however it's not my project so keeping/dropping support isn't up to me, I'm just getting it working again.

@jaxwilko
Copy link

@josh-gaby awesome work, hopefully it can get reviewed and merged soon! :)

@@ -80,61 +114,61 @@ public function run() {
* @param \React\Socket\ConnectionInterface $conn
*/
public function handleConnect($conn) {
$conn->decor = new IoConnection($conn);
$conn->decor->resourceId = (int)$conn->stream;
$io_conn = new IoConnection($conn);

Choose a reason for hiding this comment

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

I'm guessing $conn->decor should still be left to avoid a breaking change

Copy link
Author

Choose a reason for hiding this comment

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

decor is not a property of \React\Socket\ConnectionInterface so can't be left in because php 8 deprecated dynamic property creation.

Copy link

Choose a reason for hiding this comment

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

Then maybe we also make a PR to reactphp/socket to add #[AllowDynamicProperties] to the interface https://github.com/reactphp/socket/blob/3.x/src/ConnectorInterface.php

Copy link

@Tofandel Tofandel Aug 9, 2024

Choose a reason for hiding this comment

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

Or we simply use spl storage locally in IoServer to store the decor and retrieve it when needed

*/
public function handleData($data, $conn) {
public function handleData($data, $io_conn) {
Copy link

@Tofandel Tofandel Jun 28, 2024

Choose a reason for hiding this comment

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

Changing the parameter there and in the other methods is a breaking change, because IoServer can be extended

Copy link
Author

Choose a reason for hiding this comment

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

I agree, this a breaking change, however it was done because \React\Socket\ConnectionInterface doesn't actually have the decor property previously being used to pass the connection around and PHP 8 deprecated dymanic property creation.


if (version_compare(\Composer\InstalledVersions::getVersion('symfony/http-foundation'), '6.0.0') === -1) {
// The version of http-foundation is < 6, include a class without return types
include 'VirtualProxy-HttpFoundation<6.php';

Choose a reason for hiding this comment

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

This is unnecessary, the return types can be added without breaking the signature, it's removing or changing them that's an issue

Copy link
Author

Choose a reason for hiding this comment

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

This is required if support for PHP < 7.0 is to be maintained, earlier versions didn't support return types.

Copy link

@Tofandel Tofandel Aug 9, 2024

Choose a reason for hiding this comment

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

Why keep support for such old php? that's asking for maintenance hell, they have been EOL for more than 6 years, a PR like this can absolutely include such breaking changes

Copy link
Author

Choose a reason for hiding this comment

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

I agree, but like I told the commenter above, it's not my project, so all I'm doing is getting it working again for php 8+

Personally, I would do it as a new major version that supported php >= 7.4 and leave < 7.4 using the current version but that's nothing to do with me.

Also, this pull request has been sitting here for a year now, I'm not sure how likely it is to even get merged at this point to be honest.

Copy link

@Tofandel Tofandel Aug 9, 2024

Choose a reason for hiding this comment

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

There is ongoing work recently on ratchet from the maintainers to get the projects back alive

See

#1054

So it's quite likely

It's okay if it's not your project, you can do a PR with a breaking change and mark it as such so it will be released as a major, otherwise those kind of big PR's are a maintenance pain and it's actually more likely to be accepted if you don't add API breaking changes in your PR but drop support for older php versions because it's 100% sure that to bring it back to life it's a new major that's going to be released next, because they are releasing a major for reactphp/event-loop that also drops support for php7.1-

A compat layer is nice when the project doesn't need a major release, but this project hasn't had a release in 3 years so it will need one

So if you want a high likelihood that your PR is accepted, follow what they are doing with reactphp/event-loop and drop support for <=php7.0 in your PR only keep 7.1+, this will be a step up transition version, so no API breaking change but only php version

And then in the future we'll have another major that adds types to the Interfaces, this is so that users can upgrade painlessly to the new version at first but the next one will need some work from them

@dvdknaap
Copy link

what is still needed to merge this PR ? @josh-gaby @clue ?

Provide a way to set and unset a dynamic property.
@dvdknaap
Copy link

@josh-gaby i don't get why you still havent received any reply yet from the maintainers. i see your still updating your fork.
i'm gonna test it in my project. will let you know if i find something

@josh-gaby
Copy link
Author

@dvdknaap I've been using it in a reasonably sized project for the last year, haven't had any issues at all so far but if you do find anything let me know and I'll try fix it

@dvdknaap
Copy link

dvdknaap commented Dec 6, 2024

@dvdknaap I've been using it in a reasonably sized project for the last year, haven't had any issues at all so far but if you do find anything let me know and I'll try fix it

I also tested it and it;s working without issues !

Could you maybe add support for SF 7 so i can finally upgrade ? :D

@dvdknaap
Copy link

@josh-gaby thanks for the update. It's working without any issues ! 🥳😎

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.

7 participants