Skip to content

Commit a454a15

Browse files
authored
Merge pull request #145 from php-http/2.x
Prepare for 2.0
2 parents 7e29605 + 6b9b48a commit a454a15

9 files changed

+36
-31
lines changed

.travis.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ cache:
77
- $HOME/.composer/cache/files
88

99
php:
10-
- 5.4
11-
- 5.5
12-
- 5.6
1310
- 7.0
1411
- 7.1
1512
- 7.2
@@ -25,12 +22,11 @@ branches:
2522
matrix:
2623
fast_finish: true
2724
include:
28-
- php: 5.4
25+
- php: 7.0
2926
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"
3027

3128
before_install:
32-
- if [[ $COVERAGE != true && $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini || true; fi
33-
- travis_retry composer self-update
29+
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
3430

3531
install:
3632
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Change Log
22

3+
## 2.0.0 - UNRELEASED
4+
5+
This version is no BC break for consumers using HTTPlug. However, HTTP clients that
6+
implement HTTPlug need to adjust because we add return type declarations.
7+
8+
### Added
9+
10+
- Support for PSR-18 (HTTP client).
11+
12+
### Removed
13+
14+
- PHP 5 support
15+
16+
### Changed
17+
18+
- [BC Break] `HttpClient::sendRequest(RequestInterface $request)` has a return type annotation. The new
19+
signature is `HttpClient::sendRequest(RequestInterface $request): ResponseInterface`.
20+
- [BC Break] `RequestException::getRequest()` has a return type annotation. The new
21+
signature is `RequestException::getRequest(): RequestInterface`.
322

423
## 1.1.0 - 2016-08-31
524

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=5.4",
18+
"php": "^7.0",
1919
"psr/http-message": "^1.0",
20+
"psr/http-client": "^0.3",
2021
"php-http/promise": "^1.0"
2122
},
2223
"require-dev": {
@@ -34,7 +35,7 @@
3435
},
3536
"extra": {
3637
"branch-alias": {
37-
"dev-master": "1.2-dev"
38+
"dev-2.x": "2.0.x-dev"
3839
}
3940
}
4041
}

src/Exception.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
namespace Http\Client;
44

5+
use Psr\Http\Client\ClientExceptionInterface as PsrClientException;
6+
57
/**
68
* Every HTTP Client related Exception must implement this interface.
79
*
810
* @author Márk Sági-Kazár <[email protected]>
911
*/
10-
interface Exception
12+
interface Exception extends PsrClientException
1113
{
1214
}

src/Exception/HttpException.php

-6
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ public function getResponse()
4949

5050
/**
5151
* Factory method to create a new exception with a normalized error message.
52-
*
53-
* @param RequestInterface $request
54-
* @param ResponseInterface $response
55-
* @param \Exception|null $previous
56-
*
57-
* @return HttpException
5852
*/
5953
public static function create(
6054
RequestInterface $request,

src/Exception/NetworkException.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
namespace Http\Client\Exception;
44

5+
use Psr\Http\Client\NetworkExceptionInterface as PsrNetworkException;
6+
57
/**
68
* Thrown when the request cannot be completed because of network issues.
79
*
810
* There is no response object as this exception is thrown when no response has been received.
911
*
1012
* @author Márk Sági-Kazár <[email protected]>
1113
*/
12-
class NetworkException extends RequestException
14+
class NetworkException extends RequestException implements PsrNetworkException
1315
{
1416
}

src/Exception/RequestException.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Http\Client\Exception;
44

55
use Psr\Http\Message\RequestInterface;
6+
use Psr\Http\Client\RequestExceptionInterface as PsrRequestException;
67

78
/**
89
* Exception for when a request failed, providing access to the failed request.
@@ -12,7 +13,7 @@
1213
*
1314
* @author Márk Sági-Kazár <[email protected]>
1415
*/
15-
class RequestException extends TransferException
16+
class RequestException extends TransferException implements PsrRequestException
1617
{
1718
/**
1819
* @var RequestInterface
@@ -31,12 +32,7 @@ public function __construct($message, RequestInterface $request, \Exception $pre
3132
parent::__construct($message, 0, $previous);
3233
}
3334

34-
/**
35-
* Returns the request.
36-
*
37-
* @return RequestInterface
38-
*/
39-
public function getRequest()
35+
public function getRequest(): RequestInterface
4036
{
4137
return $this->request;
4238
}

src/HttpAsyncClient.php

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ interface HttpAsyncClient
1717
*
1818
* Exceptions related to processing the request are available from the returned Promise.
1919
*
20-
* @param RequestInterface $request
21-
*
2220
* @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception.
2321
*
2422
* @throws \Exception If processing the request is impossible (eg. bad configuration).

src/HttpClient.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Http\Client;
44

5+
use Psr\Http\Client\ClientInterface;
56
use Psr\Http\Message\RequestInterface;
67
use Psr\Http\Message\ResponseInterface;
78

@@ -12,17 +13,13 @@
1213
* @author Márk Sági-Kazár <[email protected]>
1314
* @author David Buchmann <[email protected]>
1415
*/
15-
interface HttpClient
16+
interface HttpClient extends ClientInterface
1617
{
1718
/**
1819
* Sends a PSR-7 request.
1920
*
20-
* @param RequestInterface $request
21-
*
22-
* @return ResponseInterface
23-
*
2421
* @throws \Http\Client\Exception If an error happens during processing the request.
2522
* @throws \Exception If processing the request is impossible (eg. bad configuration).
2623
*/
27-
public function sendRequest(RequestInterface $request);
24+
public function sendRequest(RequestInterface $request): ResponseInterface;
2825
}

0 commit comments

Comments
 (0)