From 0757afa037512dc5c59dcdfde57b1a3fae6639b2 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 26 Mar 2018 21:24:20 +0200 Subject: [PATCH] Typehint ClientInterface --- src/Common/AbstractGateway.php | 9 +++++---- src/Common/GatewayFactory.php | 6 +++--- src/Common/Message/AbstractRequest.php | 7 ++++--- src/Omnipay.php | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Common/AbstractGateway.php b/src/Common/AbstractGateway.php index 1663efa7..719fbeac 100755 --- a/src/Common/AbstractGateway.php +++ b/src/Common/AbstractGateway.php @@ -6,6 +6,7 @@ namespace Omnipay\Common; use Omnipay\Common\Http\Client; +use Omnipay\Common\Http\ClientInterface; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request as HttpRequest; @@ -49,7 +50,7 @@ abstract class AbstractGateway implements GatewayInterface protected $parameters; /** - * @var Client + * @var ClientInterface */ protected $httpClient; @@ -61,10 +62,10 @@ abstract class AbstractGateway implements GatewayInterface /** * Create a new gateway instance * - * @param Client $httpClient A HTTP client to make API calls with + * @param ClientInterface $httpClient A HTTP client to make API calls with * @param HttpRequest $httpRequest A Symfony HTTP request object */ - public function __construct(Client $httpClient = null, HttpRequest $httpRequest = null) + public function __construct(ClientInterface $httpClient = null, HttpRequest $httpRequest = null) { $this->httpClient = $httpClient ?: $this->getDefaultHttpClient(); $this->httpRequest = $httpRequest ?: $this->getDefaultHttpRequest(); @@ -326,7 +327,7 @@ protected function createRequest($class, array $parameters) /** * Get the global default HTTP client. * - * @return Client + * @return ClientInterface */ protected function getDefaultHttpClient() { diff --git a/src/Common/GatewayFactory.php b/src/Common/GatewayFactory.php index 2058b75b..afb0da7b 100644 --- a/src/Common/GatewayFactory.php +++ b/src/Common/GatewayFactory.php @@ -6,7 +6,7 @@ namespace Omnipay\Common; use Omnipay\Common\Exception\RuntimeException; -use Omnipay\Common\Http\Client; +use Omnipay\Common\Http\ClientInterface; use Symfony\Component\HttpFoundation\Request as HttpRequest; /** @@ -73,12 +73,12 @@ public function register($className) * Create a new gateway instance * * @param string $class Gateway name - * @param Client|null $httpClient A HTTP Client implementation + * @param ClientInterface|null $httpClient A HTTP Client implementation * @param HttpRequest|null $httpRequest A Symfony HTTP Request implementation * @throws RuntimeException If no such gateway is found * @return GatewayInterface An object of class $class is created and returned */ - public function create($class, Client $httpClient = null, HttpRequest $httpRequest = null) + public function create($class, ClientInterface $httpClient = null, HttpRequest $httpRequest = null) { $class = Helper::getGatewayClassName($class); diff --git a/src/Common/Message/AbstractRequest.php b/src/Common/Message/AbstractRequest.php index 911ec1e0..cd0e726d 100644 --- a/src/Common/Message/AbstractRequest.php +++ b/src/Common/Message/AbstractRequest.php @@ -16,6 +16,7 @@ use Omnipay\Common\Exception\RuntimeException; use Omnipay\Common\Helper; use Omnipay\Common\Http\Client; +use Omnipay\Common\Http\ClientInterface; use Omnipay\Common\ItemBag; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request as HttpRequest; @@ -75,7 +76,7 @@ abstract class AbstractRequest implements RequestInterface /** * The request client. * - * @var Client + * @var ClientInterface */ protected $httpClient; @@ -111,10 +112,10 @@ abstract class AbstractRequest implements RequestInterface /** * Create a new Request * - * @param Client $httpClient A HTTP client to make API calls with + * @param ClientInterface $httpClient A HTTP client to make API calls with * @param HttpRequest $httpRequest A Symfony HTTP request object */ - public function __construct(Client $httpClient, HttpRequest $httpRequest) + public function __construct(ClientInterface $httpClient, HttpRequest $httpRequest) { $this->httpClient = $httpClient; $this->httpRequest = $httpRequest; diff --git a/src/Omnipay.php b/src/Omnipay.php index ecc91934..b98898bd 100644 --- a/src/Omnipay.php +++ b/src/Omnipay.php @@ -6,7 +6,7 @@ namespace Omnipay; use Omnipay\Common\GatewayFactory; -use Omnipay\Common\Http\Client; +use Omnipay\Common\Http\ClientInterface; /** * Omnipay class @@ -47,7 +47,7 @@ * @method static array find() * @method static array getSupportedGateways() * @codingStandardsIgnoreStart - * @method static \Omnipay\Common\GatewayInterface create(string $class, Client $httpClient = null, \Symfony\Component\HttpFoundation\Request $httpRequest = null) + * @method static \Omnipay\Common\GatewayInterface create(string $class, ClientInterface $httpClient = null, \Symfony\Component\HttpFoundation\Request $httpRequest = null) * @codingStandardsIgnoreEnd * * @see Omnipay\Common\GatewayFactory