reactphp / http

Event-driven, streaming HTTP client and server implementation for ReactPHP.
https://reactphp.org/http/
MIT License
747 stars 143 forks source link

Update PSR dependency #511

Closed cracksalad closed 11 months ago

cracksalad commented 11 months ago

Allow usage of psr/http-message v2.0.

When using reactphp/http composer outdated shows:

psr/http-message 1.1   2.0   Common interface for HTTP messages

and composer why psr/http-message says:

react/http       v1.9.0     requires psr/http-message (^1.0)
ringcentral/psr7 1.3.0      requires psr/http-message (~1.0)

So as long as #485 is not resolved (and ringcentral/psr7 is not updated), this PR does not change anything.

For compatibility concerns see PSR Meta Document. The new version restriction still allows to use psr/http-message v1.0 and v1.1 if e.g. newer versions are not compatible with your PHP version, but it also allows to use v2.0.

SimonFrings commented 11 months ago

Hey @cracksalad, thanks for your input on the psr/http-message v2 topic. I opened a ticket to add support for psr/http-message v2 in #513. This ticket should include all necessary information for the v2 upgrade.

You're right that we first need to remove the dependency on ringcentral/psr7 in order to proceed with upgrading to psr/http-message v2. The upgrade though will also include some workarounds for older PHP versions with additional tests, so just including the version in the composer.json won't do it.

I'll close this PR for now, as the suggested change won't work with the current project setup. Further discussion will happen in #513.

cracksalad commented 11 months ago

@SimonFrings

The upgrade though will also include some workarounds for older PHP versions with additional tests, so just including the version in the composer.json won't do it.

A "psr/http-message": "^1.0 || ^2.0" would allow composer to update to v2 if your setup (especially PHP itself) supports it. If it does not, composer just would not update and continue to use v1. So there should not be any problem with older PHP versions. The one case that could be problematic is, if reactphp/http is not fully compatible with psr/http-message v2 e.g. because of type issues. Is there anything I am missing? I am just a bit confused by your explanation. Other than that I am totally fine with your rearrangement of PRs and issues.

WyriHaximus commented 11 months ago

@cracksalad In short the PSR-7 implementation we're currently using isn't compatible with v2, which should change in v3 of this package. (We're skipping v2 and are going to jump to v3 while also bumping the minimum PHP version and a whole lot of other changes.)

SimonFrings commented 10 months ago

The one case that could be problematic is, if reactphp/http is not fully compatible with psr/http-message v2 e.g. because of type issues.

@cracksalad This is the case here, like @WyriHaximus said, we're currently using their interfaces in a few classes, which are not compatible to the v2. For example, one thing we need to add for compatibility are return types as described in https://www.php-fig.org/psr/psr-7/meta/#72-type-additions.