php-sparkpost icon indicating copy to clipboard operation
php-sparkpost copied to clipboard

SparkPostResponse incompatible with psr/http-message v2's ResponseInterface

Open shawnlindstrom opened this issue 2 years ago • 4 comments

SparkPost (v2.3.0) requires php-http/message which requires either v1 or 2 of psr/http-message. The Psr\Http\Message\ResponseInterface in v2 of psr/http-message added return type hints. Therefore SparkPost\SparkPostResponse which implements the interface is no longer compatible. You'll either need to update SparkPostResponse to be compatible or make psr/http-message v1 a direct dependency.

Thanks!

shawnlindstrom avatar Jun 30 '23 18:06 shawnlindstrom

Just ran into this as well. In case you want to support both versions of psr/http-message it might be possible to use PHP's #[\ReturnTypeWillChange] attribute withing Sparkpost library.

enumag avatar Sep 05 '23 13:09 enumag

+1

eerootsus avatar Oct 23 '23 12:10 eerootsus

I've created a PR that todes the adaptation to psr http messge 2.0 but with it has a breaking change that can't be avoided due to the interface constraints: the method getBody must return StreamInterface and not the decoded body as an array like is done now.

The PR solves this by creating an additional method named 'getBodyAsJson' so that the libraries that were depending on the getBody method, can change its code to use getBodyAsJson.

Please review, thanks!

omarlopesino avatar Oct 23 '23 12:10 omarlopesino

Link to @omarlopesino PR https://github.com/SparkPost/php-sparkpost/pull/214

michaellopez avatar Nov 09 '23 13:11 michaellopez