Skip to content

Commit

Permalink
Typehint ClientInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Mar 26, 2018
1 parent eb24fe0 commit 0757afa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/Common/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -49,7 +50,7 @@ abstract class AbstractGateway implements GatewayInterface
protected $parameters;

/**
* @var Client
* @var ClientInterface
*/
protected $httpClient;

Expand All @@ -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();
Expand Down Expand Up @@ -326,7 +327,7 @@ protected function createRequest($class, array $parameters)
/**
* Get the global default HTTP client.
*
* @return Client
* @return ClientInterface
*/
protected function getDefaultHttpClient()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Common/GatewayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 4 additions & 3 deletions src/Common/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,7 +76,7 @@ abstract class AbstractRequest implements RequestInterface
/**
* The request client.
*
* @var Client
* @var ClientInterface
*/
protected $httpClient;

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Omnipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Omnipay;

use Omnipay\Common\GatewayFactory;
use Omnipay\Common\Http\Client;
use Omnipay\Common\Http\ClientInterface;

/**
* Omnipay class
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0757afa

Please sign in to comment.