Skip to content

Feature/removed deprecation#218

Draft
virtualLast wants to merge 13 commits intoSparkPost:masterfrom
AshwoodsLightfoot:feature/removed-deprecation
Draft

Feature/removed deprecation#218
virtualLast wants to merge 13 commits intoSparkPost:masterfrom
AshwoodsLightfoot:feature/removed-deprecation

Conversation

@virtualLast
Copy link

@virtualLast virtualLast commented Feb 16, 2026

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-18 ClientInterface and 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_encode failure, and adjusts response handling so SparkPostResponse::getBody() now returns a PSR-7 stream with a new getBodyDecoded() helper for JSON arrays.

Updates dependencies and tooling (PHP >=7.4, add nyholm/psr7, allow discovery plugin, move examples/tests to Guzzle 7 adapter, bump php-cs-fixer, add rector.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.

$json = json_decode($body_string, true);

return $json;
return $json ?? [];
Copy link

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

$response = $this->promise->wait($unwrap);

return $response ? new SparkPostResponse($response, $this->request) : $response;
} catch (\Exception $exception) {
Copy link

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

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)
Copy link

Choose a reason for hiding this comment

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

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.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

1 participant

Comments