You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to you your library with php-http/discovery, HandlerStack parameter in WpClient needs to be nullable because ClassDiscovery calls the constructor without parameters.
Set HandlerStack like this.
class WpClient {
/** * Constructor. * * @param HandlerInterface $handler The handler to use for dispatching requests and receiving responses. * @param UriInterface|null $baseUri Optional base URI for all relative requests sent using this client. * * @throws InvalidArgumentException If the "base_uri" option is present and is not a valid URI. */publicfunction__construct( ?HandlerInterface$handler = null, ?UriInterface$baseUri = null ) {
$this->handler = $handler ?? HandlerStack::CreateDefault();
$this->baseUri = $baseUri;
}
}
This make your http client compatible with the discovery library.
The text was updated successfully, but these errors were encountered:
seebeen
changed the title
Set default HandlerStack in constructor
Constructor parameter prevents usage with php-http/discovery
Feb 1, 2025
In order to you your library with
php-http/discovery
, HandlerStack parameter inWpClient
needs to be nullable becauseClassDiscovery
calls the constructor without parameters.Set HandlerStack like this.
This make your http client compatible with the discovery library.
The text was updated successfully, but these errors were encountered: