Skip to content

Constructor parameter prevents usage with php-http/discovery #1

@seebeen

Description

@seebeen

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.
     */
    public function __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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions