Conversation
General Updates
| $json = json_decode($body_string, true); | ||
|
|
||
| return $json; | ||
| return $json ?? []; |
There was a problem hiding this comment.
Response body API contract changed unexpectedly
Medium Severity
SparkPostResponse::getBody() now returns a StreamInterface instead of decoded JSON data. Existing callers that rely on getBody() returning an array will now receive a stream object, which changes runtime behavior and can break response handling in integrations using this library API.
| $response = $this->promise->wait($unwrap); | ||
|
|
||
| return $response ? new SparkPostResponse($response, $this->request) : $response; | ||
| } catch (\Exception $exception) { |
There was a problem hiding this comment.
wait(false) now violates declared return type
Medium Severity
SparkPostPromise::wait() is now declared to return SparkPostResponse, but it still returns the raw $response when it is falsy. With $unwrap = false, promises can resolve to null, which now causes a return-type TypeError instead of returning normally.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| * @throws \Exception | ||
| */ | ||
| public function __construct($httpClient, array $options) | ||
| public function __construct(ClientInterface $httpClient, array $options) |
There was a problem hiding this comment.
Constructor rejects async-only HTTP clients
Medium Severity
SparkPost::__construct() now type-hints ClientInterface, so passing a valid HttpAsyncClient that does not also implement PSR-18 fails immediately. This conflicts with setHttpClient(), which still accepts HttpAsyncClient, and removes previously supported client implementations.


removed deprecated HttpClient class and updated php-cs-fixer to remove final composer audit issues.
Note
Medium Risk
Updates core request/response construction and exception wrapping to PSR-17/18 factories with stricter typing; behavior should be similar but touches the library’s primary API surface and could affect integrations relying on old body decoding semantics.
Overview
Modernizes the HTTP layer by switching from deprecated HTTPlug
HttpClient/message factory usage to PSR-18ClientInterfaceand PSR-17 factories (request + stream), adding stricter type declarations across resources and promises.Changes request building to always JSON-encode bodies with explicit error handling on
json_encodefailure, and adjusts response handling soSparkPostResponse::getBody()now returns a PSR-7 stream with a newgetBodyDecoded()helper for JSON arrays.Updates dependencies and tooling (PHP >=7.4, add
nyholm/psr7, allow discovery plugin, move examples/tests to Guzzle 7 adapter, bumpphp-cs-fixer, addrector.php) and adds/updates unit tests including a regression test for JSON encoding failure; README notes this is an internal fork.Written by Cursor Bugbot for commit f037c4d. This will update automatically on new commits. Configure here.