diff --git a/.travis.yml b/.travis.yml index 6af5f34..0c9a55f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: php - sudo: false -dist: trusty - cache: directories: - $HOME/.composer/cache/files @@ -19,17 +16,15 @@ branches: matrix: fast_finish: true include: - - php: 7.1 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" DEPENDENCIES="doctrine/instantiator:^1.1" + - php: 7.0 + env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" # Test the latest stable release - - php: 5.4 - - php: 5.5 - - php: 5.6 - php: 7.0 - php: 7.1 - php: 7.2 - env: COVERAGE=true TEST_COMMAND="composer test-ci" DEPENDENCIES="henrikbjorn/phpspec-code-coverage:^1.0" + - php: 7.2 + env: COVERAGE=true TEST_COMMAND="composer test-ci" DEPENDENCIES="leanphp/phpspec-code-coverage" # Test LTS versions - php: 7.1 @@ -44,9 +39,10 @@ matrix: env: STABILITY="dev" allow_failures: - # Latest dev is allowed to fail. + - php: 7.3 + sudo: required - env: STABILITY="dev" - + before_install: - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi - if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; diff --git a/composer.json b/composer.json index 4695c4c..fc3d1c1 100644 --- a/composer.json +++ b/composer.json @@ -11,15 +11,18 @@ } ], "require": { - "php": "^5.4 || ^7.0", - "php-http/httplug": "^1.1", + "php": "^7.0", + "php-http/httplug": "^2.0", "php-http/message-factory": "^1.0", "php-http/message": "^1.6", "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.4 || ^4.2", - "guzzlehttp/psr7": "^1.4" + "doctrine/instantiator": ">=1.0.5", + "guzzlehttp/psr7": "^1.4", + "phpspec/phpspec": "^3.4 || ^4.2", + "phpspec/prophecy": ">=1.8", + "sebastian/comparator": ">=2" }, "suggest": { "php-http/logger-plugin": "PSR-3 Logger plugin", @@ -37,6 +40,7 @@ }, "extra": { "branch-alias": { + "dev-2.x": "2.x-dev", "dev-master": "1.8-dev" } } diff --git a/phpspec.ci.yml b/phpspec.ci.yml index 0838ef5..d8e1383 100644 --- a/phpspec.ci.yml +++ b/phpspec.ci.yml @@ -4,7 +4,7 @@ suites: psr4_prefix: Http\Client\Common formatter.name: pretty extensions: - - PhpSpec\Extension\CodeCoverageExtension + LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension: ~ code_coverage: format: clover output: build/coverage.xml diff --git a/spec/HttpClientPool/LeastUsedClientPoolSpec.php b/spec/HttpClientPool/LeastUsedClientPoolSpec.php index a976c31..82855d9 100644 --- a/spec/HttpClientPool/LeastUsedClientPoolSpec.php +++ b/spec/HttpClientPool/LeastUsedClientPoolSpec.php @@ -72,10 +72,6 @@ public function it_reenable_client(HttpClient $client, RequestInterface $request public function it_uses_the_lowest_request_client(HttpClientPoolItem $client1, HttpClientPoolItem $client2, RequestInterface $request, ResponseInterface $response) { - if (extension_loaded('xdebug')) { - throw new SkippingException('This test fail when xdebug is enable on PHP < 7'); - } - $this->addHttpClient($client1); $this->addHttpClient($client2); diff --git a/src/BatchClient.php b/src/BatchClient.php index 2036355..2a39904 100644 --- a/src/BatchClient.php +++ b/src/BatchClient.php @@ -6,6 +6,7 @@ use Http\Client\HttpClient; use Http\Client\Common\Exception\BatchException; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; /** * BatchClient allow to sends multiple request and retrieve a Batch Result. @@ -32,7 +33,7 @@ public function __construct(HttpClient $client) /** * {@inheritdoc} */ - public function sendRequest(RequestInterface $request) + public function sendRequest(RequestInterface $request): ResponseInterface { return $this->client->sendRequest($request); } diff --git a/src/HttpAsyncClientEmulator.php b/src/HttpAsyncClientEmulator.php index c0ba354..ce16f84 100644 --- a/src/HttpAsyncClientEmulator.php +++ b/src/HttpAsyncClientEmulator.php @@ -5,6 +5,7 @@ use Http\Client\Exception; use Http\Client\Promise; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; /** * Emulates an HTTP Async Client in an HTTP Client. @@ -18,7 +19,7 @@ trait HttpAsyncClientEmulator * * @see HttpClient::sendRequest */ - abstract public function sendRequest(RequestInterface $request); + abstract public function sendRequest(RequestInterface $request): ResponseInterface; /** * {@inheritdoc} diff --git a/src/HttpClientDecorator.php b/src/HttpClientDecorator.php index a33d5ef..da5a1bb 100644 --- a/src/HttpClientDecorator.php +++ b/src/HttpClientDecorator.php @@ -4,6 +4,7 @@ use Http\Client\HttpClient; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; /** * Decorates an HTTP Client. @@ -22,7 +23,7 @@ trait HttpClientDecorator * * @see HttpClient::sendRequest */ - public function sendRequest(RequestInterface $request) + public function sendRequest(RequestInterface $request): ResponseInterface { return $this->httpClient->sendRequest($request); } diff --git a/src/HttpClientEmulator.php b/src/HttpClientEmulator.php index dbec1ab..8e6472a 100644 --- a/src/HttpClientEmulator.php +++ b/src/HttpClientEmulator.php @@ -3,6 +3,7 @@ namespace Http\Client\Common; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; /** * Emulates an HTTP Client in an HTTP Async Client. @@ -16,7 +17,7 @@ trait HttpClientEmulator * * @see HttpClient::sendRequest */ - public function sendRequest(RequestInterface $request) + public function sendRequest(RequestInterface $request): ResponseInterface { $promise = $this->sendAsyncRequest($request); diff --git a/src/HttpClientPool.php b/src/HttpClientPool.php index 7ac292c..6f4597f 100644 --- a/src/HttpClientPool.php +++ b/src/HttpClientPool.php @@ -6,6 +6,7 @@ use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; /** * A http client pool allows to send requests on a pool of different http client using a specific strategy (least used, @@ -52,7 +53,7 @@ public function sendAsyncRequest(RequestInterface $request) /** * {@inheritdoc} */ - public function sendRequest(RequestInterface $request) + public function sendRequest(RequestInterface $request): ResponseInterface { return $this->chooseHttpClient()->sendRequest($request); } diff --git a/src/HttpClientPoolItem.php b/src/HttpClientPoolItem.php index 09cd6dd..a46ee2f 100644 --- a/src/HttpClientPoolItem.php +++ b/src/HttpClientPoolItem.php @@ -6,6 +6,7 @@ use Http\Client\HttpClient; use Psr\Http\Message\RequestInterface; use Http\Client\Exception; +use Psr\Http\Message\ResponseInterface; /** * A HttpClientPoolItem represent a HttpClient inside a Pool. @@ -50,7 +51,7 @@ public function __construct($client, $reenableAfter = null) /** * {@inheritdoc} */ - public function sendRequest(RequestInterface $request) + public function sendRequest(RequestInterface $request): ResponseInterface { if ($this->isDisabled()) { throw new Exception\RequestException('Cannot send the request as this client has been disabled', $request); diff --git a/src/HttpClientRouter.php b/src/HttpClientRouter.php index 9f72133..fa32c56 100644 --- a/src/HttpClientRouter.php +++ b/src/HttpClientRouter.php @@ -7,6 +7,7 @@ use Http\Client\HttpClient; use Http\Message\RequestMatcher; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; /** * Route a request to a specific client in the stack based using a RequestMatcher. @@ -23,7 +24,7 @@ final class HttpClientRouter implements HttpClient, HttpAsyncClient /** * {@inheritdoc} */ - public function sendRequest(RequestInterface $request) + public function sendRequest(RequestInterface $request): ResponseInterface { $client = $this->chooseHttpClient($request); diff --git a/src/HttpMethodsClient.php b/src/HttpMethodsClient.php index 58804fc..0ec1e14 100644 --- a/src/HttpMethodsClient.php +++ b/src/HttpMethodsClient.php @@ -198,7 +198,7 @@ public function send($method, $uri, array $headers = [], $body = null) * * {@inheritdoc} */ - public function sendRequest(RequestInterface $request) + public function sendRequest(RequestInterface $request): ResponseInterface { return $this->httpClient->sendRequest($request); } diff --git a/src/PluginClient.php b/src/PluginClient.php index 93aea8f..7413152 100644 --- a/src/PluginClient.php +++ b/src/PluginClient.php @@ -9,6 +9,7 @@ use Http\Client\Promise\HttpFulfilledPromise; use Http\Client\Promise\HttpRejectedPromise; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\OptionsResolver\OptionsResolver; /** @@ -67,7 +68,7 @@ public function __construct($client, array $plugins = [], array $options = []) /** * {@inheritdoc} */ - public function sendRequest(RequestInterface $request) + public function sendRequest(RequestInterface $request): ResponseInterface { // If we don't have an http client, use the async call if (!($this->client instanceof HttpClient)) {