Skip to content

Commit b7e032b

Browse files
Jean85dbu
authored andcommitted
Use HTTPlug 2.0 (#114)
* Adjust client signatures * Lock lower bounds for test dependencies * Use leanphp/phpspec-code-coverage as a maintained fork
1 parent 5496bf2 commit b7e032b

13 files changed

+33
-29
lines changed

.travis.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
language: php
2-
32
sudo: false
43

5-
dist: trusty
6-
74
cache:
85
directories:
96
- $HOME/.composer/cache/files
@@ -19,17 +16,15 @@ branches:
1916
matrix:
2017
fast_finish: true
2118
include:
22-
- php: 7.1
23-
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" DEPENDENCIES="doctrine/instantiator:^1.1"
19+
- php: 7.0
20+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
2421

2522
# Test the latest stable release
26-
- php: 5.4
27-
- php: 5.5
28-
- php: 5.6
2923
- php: 7.0
3024
- php: 7.1
3125
- php: 7.2
32-
env: COVERAGE=true TEST_COMMAND="composer test-ci" DEPENDENCIES="henrikbjorn/phpspec-code-coverage:^1.0"
26+
- php: 7.2
27+
env: COVERAGE=true TEST_COMMAND="composer test-ci" DEPENDENCIES="leanphp/phpspec-code-coverage"
3328

3429
# Test LTS versions
3530
- php: 7.1
@@ -44,9 +39,10 @@ matrix:
4439
env: STABILITY="dev"
4540

4641
allow_failures:
47-
# Latest dev is allowed to fail.
42+
- php: 7.3
43+
sudo: required
4844
- env: STABILITY="dev"
49-
45+
5046
before_install:
5147
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
5248
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;

composer.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^5.4 || ^7.0",
15-
"php-http/httplug": "^1.1",
14+
"php": "^7.0",
15+
"php-http/httplug": "^2.0",
1616
"php-http/message-factory": "^1.0",
1717
"php-http/message": "^1.6",
1818
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0"
1919
},
2020
"require-dev": {
21-
"phpspec/phpspec": "^2.5 || ^3.4 || ^4.2",
22-
"guzzlehttp/psr7": "^1.4"
21+
"doctrine/instantiator": ">=1.0.5",
22+
"guzzlehttp/psr7": "^1.4",
23+
"phpspec/phpspec": "^3.4 || ^4.2",
24+
"phpspec/prophecy": ">=1.8",
25+
"sebastian/comparator": ">=2"
2326
},
2427
"suggest": {
2528
"php-http/logger-plugin": "PSR-3 Logger plugin",
@@ -37,6 +40,7 @@
3740
},
3841
"extra": {
3942
"branch-alias": {
43+
"dev-2.x": "2.x-dev",
4044
"dev-master": "1.8-dev"
4145
}
4246
}

phpspec.ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ suites:
44
psr4_prefix: Http\Client\Common
55
formatter.name: pretty
66
extensions:
7-
- PhpSpec\Extension\CodeCoverageExtension
7+
LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension: ~
88
code_coverage:
99
format: clover
1010
output: build/coverage.xml

spec/HttpClientPool/LeastUsedClientPoolSpec.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ public function it_reenable_client(HttpClient $client, RequestInterface $request
7272

7373
public function it_uses_the_lowest_request_client(HttpClientPoolItem $client1, HttpClientPoolItem $client2, RequestInterface $request, ResponseInterface $response)
7474
{
75-
if (extension_loaded('xdebug')) {
76-
throw new SkippingException('This test fail when xdebug is enable on PHP < 7');
77-
}
78-
7975
$this->addHttpClient($client1);
8076
$this->addHttpClient($client2);
8177

src/BatchClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Http\Client\HttpClient;
77
use Http\Client\Common\Exception\BatchException;
88
use Psr\Http\Message\RequestInterface;
9+
use Psr\Http\Message\ResponseInterface;
910

1011
/**
1112
* BatchClient allow to sends multiple request and retrieve a Batch Result.
@@ -32,7 +33,7 @@ public function __construct(HttpClient $client)
3233
/**
3334
* {@inheritdoc}
3435
*/
35-
public function sendRequest(RequestInterface $request)
36+
public function sendRequest(RequestInterface $request): ResponseInterface
3637
{
3738
return $this->client->sendRequest($request);
3839
}

src/HttpAsyncClientEmulator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Http\Client\Exception;
66
use Http\Client\Promise;
77
use Psr\Http\Message\RequestInterface;
8+
use Psr\Http\Message\ResponseInterface;
89

910
/**
1011
* Emulates an HTTP Async Client in an HTTP Client.
@@ -18,7 +19,7 @@ trait HttpAsyncClientEmulator
1819
*
1920
* @see HttpClient::sendRequest
2021
*/
21-
abstract public function sendRequest(RequestInterface $request);
22+
abstract public function sendRequest(RequestInterface $request): ResponseInterface;
2223

2324
/**
2425
* {@inheritdoc}

src/HttpClientDecorator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Http\Client\HttpClient;
66
use Psr\Http\Message\RequestInterface;
7+
use Psr\Http\Message\ResponseInterface;
78

89
/**
910
* Decorates an HTTP Client.
@@ -22,7 +23,7 @@ trait HttpClientDecorator
2223
*
2324
* @see HttpClient::sendRequest
2425
*/
25-
public function sendRequest(RequestInterface $request)
26+
public function sendRequest(RequestInterface $request): ResponseInterface
2627
{
2728
return $this->httpClient->sendRequest($request);
2829
}

src/HttpClientEmulator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Http\Client\Common;
44

55
use Psr\Http\Message\RequestInterface;
6+
use Psr\Http\Message\ResponseInterface;
67

78
/**
89
* Emulates an HTTP Client in an HTTP Async Client.
@@ -16,7 +17,7 @@ trait HttpClientEmulator
1617
*
1718
* @see HttpClient::sendRequest
1819
*/
19-
public function sendRequest(RequestInterface $request)
20+
public function sendRequest(RequestInterface $request): ResponseInterface
2021
{
2122
$promise = $this->sendAsyncRequest($request);
2223

src/HttpClientPool.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Http\Client\HttpAsyncClient;
77
use Http\Client\HttpClient;
88
use Psr\Http\Message\RequestInterface;
9+
use Psr\Http\Message\ResponseInterface;
910

1011
/**
1112
* 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)
5253
/**
5354
* {@inheritdoc}
5455
*/
55-
public function sendRequest(RequestInterface $request)
56+
public function sendRequest(RequestInterface $request): ResponseInterface
5657
{
5758
return $this->chooseHttpClient()->sendRequest($request);
5859
}

src/HttpClientPoolItem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Http\Client\HttpClient;
77
use Psr\Http\Message\RequestInterface;
88
use Http\Client\Exception;
9+
use Psr\Http\Message\ResponseInterface;
910

1011
/**
1112
* A HttpClientPoolItem represent a HttpClient inside a Pool.
@@ -50,7 +51,7 @@ public function __construct($client, $reenableAfter = null)
5051
/**
5152
* {@inheritdoc}
5253
*/
53-
public function sendRequest(RequestInterface $request)
54+
public function sendRequest(RequestInterface $request): ResponseInterface
5455
{
5556
if ($this->isDisabled()) {
5657
throw new Exception\RequestException('Cannot send the request as this client has been disabled', $request);

src/HttpClientRouter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Http\Client\HttpClient;
88
use Http\Message\RequestMatcher;
99
use Psr\Http\Message\RequestInterface;
10+
use Psr\Http\Message\ResponseInterface;
1011

1112
/**
1213
* Route a request to a specific client in the stack based using a RequestMatcher.
@@ -23,7 +24,7 @@ final class HttpClientRouter implements HttpClient, HttpAsyncClient
2324
/**
2425
* {@inheritdoc}
2526
*/
26-
public function sendRequest(RequestInterface $request)
27+
public function sendRequest(RequestInterface $request): ResponseInterface
2728
{
2829
$client = $this->chooseHttpClient($request);
2930

src/HttpMethodsClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function send($method, $uri, array $headers = [], $body = null)
198198
*
199199
* {@inheritdoc}
200200
*/
201-
public function sendRequest(RequestInterface $request)
201+
public function sendRequest(RequestInterface $request): ResponseInterface
202202
{
203203
return $this->httpClient->sendRequest($request);
204204
}

src/PluginClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Http\Client\Promise\HttpFulfilledPromise;
1010
use Http\Client\Promise\HttpRejectedPromise;
1111
use Psr\Http\Message\RequestInterface;
12+
use Psr\Http\Message\ResponseInterface;
1213
use Symfony\Component\OptionsResolver\OptionsResolver;
1314

1415
/**
@@ -67,7 +68,7 @@ public function __construct($client, array $plugins = [], array $options = [])
6768
/**
6869
* {@inheritdoc}
6970
*/
70-
public function sendRequest(RequestInterface $request)
71+
public function sendRequest(RequestInterface $request): ResponseInterface
7172
{
7273
// If we don't have an http client, use the async call
7374
if (!($this->client instanceof HttpClient)) {

0 commit comments

Comments
 (0)