Skip to content

Prepare for 2.0 #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ cache:
- $HOME/.composer/cache/files

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
Expand All @@ -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
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
}
],
"require": {
"php": ">=5.4",
"php": "^7.0",
"psr/http-message": "^1.0",
"psr/http-client": "^0.3",
"php-http/promise": "^1.0"
},
"require-dev": {
Expand All @@ -34,7 +35,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
"dev-2.x": "2.0.x-dev"
}
}
}
4 changes: 3 additions & 1 deletion src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace Http\Client;

use Psr\Http\Client\ClientExceptionInterface as PsrClientException;

/**
* Every HTTP Client related Exception must implement this interface.
*
* @author Márk Sági-Kazár <[email protected]>
*/
interface Exception
interface Exception extends PsrClientException
{
}
6 changes: 0 additions & 6 deletions src/Exception/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/Exception/NetworkException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace Http\Client\Exception;

use Psr\Http\Client\NetworkExceptionInterface as PsrNetworkException;

/**
* Thrown when the request cannot be completed because of network issues.
*
* There is no response object as this exception is thrown when no response has been received.
*
* @author Márk Sági-Kazár <[email protected]>
*/
class NetworkException extends RequestException
class NetworkException extends RequestException implements PsrNetworkException
{
}
10 changes: 3 additions & 7 deletions src/Exception/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Http\Client\Exception;

use Psr\Http\Message\RequestInterface;
use Psr\Http\Client\RequestExceptionInterface as PsrRequestException;

/**
* Exception for when a request failed, providing access to the failed request.
Expand All @@ -12,7 +13,7 @@
*
* @author Márk Sági-Kazár <[email protected]>
*/
class RequestException extends TransferException
class RequestException extends TransferException implements PsrRequestException
{
/**
* @var RequestInterface
Expand All @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions src/HttpAsyncClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
9 changes: 3 additions & 6 deletions src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Http\Client;

use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

Expand All @@ -12,17 +13,13 @@
* @author Márk Sági-Kazár <[email protected]>
* @author David Buchmann <[email protected]>
*/
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;
}