From 1fd018d61c4a2034a69525d07a08075dda84f792 Mon Sep 17 00:00:00 2001 From: Tony Thomas <01tonythomas@gmail.com> Date: Fri, 16 Oct 2020 17:46:06 +0200 Subject: [PATCH] fix(#642) HttpApi: Expect client to be of type ClientInterface|PluginClient (#660) * HttpApi: Expect client to be of type ClientInterface|PluginClient * Format with pretty * pretty-fix run on the whole repo * User is_a instead of instance_of for php-stan * Use the namespaced classname in instanceof checks * Fix param documentation for MessageBuilder::parseAddress * Use ClassName::class approach in is_a --- src/Api/HttpApi.php | 10 ++++++++-- src/Message/MessageBuilder.php | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Api/HttpApi.php b/src/Api/HttpApi.php index f3281fe..25a14c1 100644 --- a/src/Api/HttpApi.php +++ b/src/Api/HttpApi.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Mailgun\Api; +use Http\Client\Common\PluginClient; use Mailgun\Exception\HttpClientException; use Mailgun\Exception\HttpServerException; use Mailgun\Exception\UnknownErrorException; @@ -29,7 +30,7 @@ abstract class HttpApi /** * The HTTP client. * - * @var ClientInterface + * @var ClientInterface|PluginClient */ protected $httpClient; @@ -43,8 +44,13 @@ abstract class HttpApi */ protected $requestBuilder; - public function __construct(ClientInterface $httpClient, RequestBuilder $requestBuilder, Hydrator $hydrator) + public function __construct($httpClient, RequestBuilder $requestBuilder, Hydrator $hydrator) { + if (!is_a($httpClient, ClientInterface::class) && + !is_a($httpClient, PluginClient::class)) { + throw new \RuntimeException('httpClient must be an instance of + Psr\Http\Client\ClientInterface or Http\Client\Common\PluginClient'); + } $this->httpClient = $httpClient; $this->requestBuilder = $requestBuilder; if (!$hydrator instanceof NoopHydrator) { diff --git a/src/Message/MessageBuilder.php b/src/Message/MessageBuilder.php index 53fd524..5182202 100644 --- a/src/Message/MessageBuilder.php +++ b/src/Message/MessageBuilder.php @@ -84,6 +84,8 @@ class MessageBuilder } /** + * @param array $variables { + * * @var string * @var string * @var string