Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Drop support for PHP 7.2 and 7.3
* Require `guzzlehttp/guzzle` ^8.0, `guzzlehttp/promises` ^3.0, and `guzzlehttp/psr7` ^3.0
* Add generic PHPDoc return types to asynchronous service client APIs
* Reject native PHP serialization of `ServiceClient`
* Require custom implementations and subclasses of public command APIs to match native method signatures
* Require service client response transformers to return `ResultInterface` values
* Require custom middleware, transformers, and `executeAll()` callbacks to accept exact argument types instead of relying on scalar coercion
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ the command key. `executeAllAsync()` callback annotations include the same first
two arguments plus the aggregate promise as a third argument. Lower-arity
userland callbacks continue to work at runtime when PHP accepts them.

#### Native PHP Serialization of Service Clients

`ServiceClient` no longer supports native PHP `serialize()` or `unserialize()`.
Persist command names and parameter arrays instead of runtime client objects.

1.0 from 0.8
------------

Expand Down
21 changes: 21 additions & 0 deletions src/NonSerializableTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace GuzzleHttp\Command;

/**
* @internal
*/
trait NonSerializableTrait
{
public function __serialize(): array
{
throw new \LogicException(static::class.' should never be serialized');
}

public function __unserialize(array $data): void
{
throw new \LogicException(static::class.' should never be unserialized');
}
}
2 changes: 2 additions & 0 deletions src/ServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class ServiceClient implements ServiceClientInterface
{
use NonSerializableTrait;

private HttpClient $httpClient;

/** @var HandlerStack<callable(CommandInterface): PromiseInterface<ResultInterface, mixed>> */
Expand Down