diff --git a/.travis.yml b/.travis.yml index b84eea2..ad1cb28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,6 @@ cache: - $HOME/.composer/cache/files php: - - 5.4 - - 5.5 - - 5.6 - 7.0 - 7.1 - 7.2 @@ -25,14 +22,11 @@ branches: matrix: fast_finish: true include: - - php: 5.4 + - php: 7.0 env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" - - php: hhvm - dist: trusty before_install: - - if [[ $COVERAGE != true && $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini || true; fi - - travis_retry composer self-update + - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi install: - travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction diff --git a/CHANGELOG.md b/CHANGELOG.md index 42824b4..8ba4c8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Change Log +## 2.0.0 - UNRELEASED + +This version is no BC break for consumers using HTTPlug. However, HTTP clients that +implement HTTPlug need to adjust because we add return type declarations. + +### Added + +- Support for PSR-18 (HTTP client). + +### Removed + +- PHP 5 support + +### Changed + +- [BC Break] `HttpClient::sendRequest(RequestInterface $request)` has a return type annotation. The new +signature is `HttpClient::sendRequest(RequestInterface $request): ResponseInterface`. +- [BC Break] `RequestException::getRequest()` has a return type annotation. The new +signature is `RequestException::getRequest(): RequestInterface`. ## 1.1.0 - 2016-08-31 diff --git a/composer.json b/composer.json index 9bf58c1..256dbe0 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,9 @@ } ], "require": { - "php": ">=5.4", + "php": "^7.0", "psr/http-message": "^1.0", + "psr/http-client": "^0.1", "php-http/promise": "^1.0" }, "require-dev": { @@ -34,7 +35,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "2.0-dev" } } } diff --git a/src/Exception.php b/src/Exception.php index e7382c3..41e3958 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -2,11 +2,13 @@ namespace Http\Client; +use Psr\Http\Client\ClientException as PsrClientException; + /** * Every HTTP Client related Exception must implement this interface. * * @author Márk Sági-Kazár */ -interface Exception +interface Exception extends PsrClientException { } diff --git a/src/Exception/HttpException.php b/src/Exception/HttpException.php index f4f32a4..5857b01 100644 --- a/src/Exception/HttpException.php +++ b/src/Exception/HttpException.php @@ -49,12 +49,6 @@ public function getResponse() /** * Factory method to create a new exception with a normalized error message. - * - * @param RequestInterface $request - * @param ResponseInterface $response - * @param \Exception|null $previous - * - * @return HttpException */ public static function create( RequestInterface $request, diff --git a/src/Exception/NetworkException.php b/src/Exception/NetworkException.php index f2198e5..69b4a4e 100644 --- a/src/Exception/NetworkException.php +++ b/src/Exception/NetworkException.php @@ -2,6 +2,8 @@ namespace Http\Client\Exception; +use Psr\Http\Client\Exception\NetworkException as PsrNetworkException; + /** * Thrown when the request cannot be completed because of network issues. * @@ -9,6 +11,6 @@ * * @author Márk Sági-Kazár */ -class NetworkException extends RequestException +class NetworkException extends RequestException implements PsrNetworkException { } diff --git a/src/Exception/RequestException.php b/src/Exception/RequestException.php index cdce14b..f95d8d9 100644 --- a/src/Exception/RequestException.php +++ b/src/Exception/RequestException.php @@ -3,6 +3,7 @@ namespace Http\Client\Exception; use Psr\Http\Message\RequestInterface; +use Psr\Http\Client\Exception\RequestException as PsrRequestException; /** * Exception for when a request failed, providing access to the failed request. @@ -12,7 +13,7 @@ * * @author Márk Sági-Kazár */ -class RequestException extends TransferException +class RequestException extends TransferException implements PsrRequestException { /** * @var RequestInterface @@ -31,12 +32,7 @@ public function __construct($message, RequestInterface $request, \Exception $pre parent::__construct($message, 0, $previous); } - /** - * Returns the request. - * - * @return RequestInterface - */ - public function getRequest() + public function getRequest(): RequestInterface { return $this->request; } diff --git a/src/HttpAsyncClient.php b/src/HttpAsyncClient.php index 492e511..bc9d5ee 100644 --- a/src/HttpAsyncClient.php +++ b/src/HttpAsyncClient.php @@ -17,8 +17,6 @@ interface HttpAsyncClient * * Exceptions related to processing the request are available from the returned Promise. * - * @param RequestInterface $request - * * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception. * * @throws \Exception If processing the request is impossible (eg. bad configuration). diff --git a/src/HttpClient.php b/src/HttpClient.php index 0e51749..9dda516 100644 --- a/src/HttpClient.php +++ b/src/HttpClient.php @@ -2,6 +2,7 @@ namespace Http\Client; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -12,17 +13,13 @@ * @author Márk Sági-Kazár * @author David Buchmann */ -interface HttpClient +interface HttpClient extends ClientInterface { /** * Sends a PSR-7 request. * - * @param RequestInterface $request - * - * @return ResponseInterface - * * @throws \Http\Client\Exception If an error happens during processing the request. * @throws \Exception If processing the request is impossible (eg. bad configuration). */ - public function sendRequest(RequestInterface $request); + public function sendRequest(RequestInterface $request): ResponseInterface; }