algolia / algoliasearch-client-php

⚡️ A fully-featured and blazing-fast PHP API client to interact with Algolia.
https://www.algolia.com/doc/api-client/php/getting-started/
MIT License
671 stars 116 forks source link

Add support for psr/http-message ^2.0 #719

Closed damcou closed 1 year ago

damcou commented 1 year ago

This includes:

jacobclarke92 commented 1 year ago

Just FYI this actually breaks support with psr/http-message ^1
Probably worth changing composer file to reflect that.
Solution for me was to pin to 3.3.2

Reason why it breaks is because of a bunch of bunch of return type incompatibilities e.g.

Fatal error:  
Declaration of Algolia\AlgoliaSearch\Http\Psr7\Uri::withScheme(string $scheme): Psr\Http\Message\UriInterface must be compatible with Psr\Http\Message\UriInterface::withScheme($scheme)  
in /Users/jacobclarke/Projects/hutchies/vendor/algolia/algoliasearch-client-php/src/Http/Psr7/Uri.php  
on line 439
Stoux commented 1 year ago

I've missed that, didn't test it with the lowest version. It does indeed break on psr/http-message:~1.0.0 as it sees the new types as more restrictive and thus deem it incompatible.

@damcou Bumping the requirement to "psr/http-message": "^1.1 || ^2.0", should suffice, otherwise you would have to revert the 2.0 support.

@jacobclarke92 Upgrading psr/http-message to 1.1 (or 2.0) should fix it, if you don't have any dependencies that lock it to 1.0 of course.

damcou commented 1 year ago

I've missed that, didn't test it with the lowest version. It does indeed break on psr/http-message:~1.0.0 as it sees the new types as more restrictive and thus deem it incompatible.

@damcou Bumping the requirement to "psr/http-message": "^1.1 || ^2.0", should suffice, otherwise you would have to revert the 2.0 support.

Just released v3.4.1 with this changes which should indeed solve the issue. Thanks for the suggestion !