Skip to content

Allow HTTPlug 2.0 #114

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 17 commits into from
Nov 6, 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
18 changes: 7 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
language: php

sudo: false

dist: trusty

cache:
directories:
- $HOME/.composer/cache/files
Expand All @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously on PHP 7.1 due to doctrine/istantiator 1.1, which is no longer required. I've added a conflict rule below.

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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a maintained fork of the previous package, which is now abandoned.


# Test LTS versions
- php: 7.1
Expand All @@ -44,9 +39,10 @@ matrix:
env: STABILITY="dev"

allow_failures:
# Latest dev is allowed to fail.
- php: 7.3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not working for now, but the issue is on Travis' side. Will work as soon as they fix it.

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;
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
}
],
"require": {
"php": "^5.4 || ^7.0",
"php-http/httplug": "^1.1",
"php": "^7.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not go directly to 7.1? afaik 7.0 is EOL already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's the same of PSR-18 and HTTPlug 2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im fine with 7.1. For psr18 it did not really matter. It was not using any php7.1 features.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as we agree that dropping 7.0 support is a minor change and we "just do it" if 7.0 becomes a pain for some reason, i am fine with allowing it for now ;-)

"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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping 2.x which was needed only to run under PHP 5.x

"phpspec/prophecy": ">=1.8",
"sebastian/comparator": ">=2"
},
"suggest": {
"php-http/logger-plugin": "PSR-3 Logger plugin",
Expand All @@ -37,6 +40,7 @@
},
"extra": {
"branch-alias": {
"dev-2.x": "2.x-dev",
"dev-master": "1.8-dev"
}
}
Expand Down
2 changes: 1 addition & 1 deletion phpspec.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions spec/HttpClientPool/LeastUsedClientPoolSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/BatchClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/HttpAsyncClientEmulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -18,7 +19,7 @@ trait HttpAsyncClientEmulator
*
* @see HttpClient::sendRequest
*/
abstract public function sendRequest(RequestInterface $request);
abstract public function sendRequest(RequestInterface $request): ResponseInterface;

/**
* {@inheritdoc}
Expand Down
3 changes: 2 additions & 1 deletion src/HttpClientDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

/**
* Decorates an HTTP Client.
Expand All @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/HttpClientEmulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -16,7 +17,7 @@ trait HttpClientEmulator
*
* @see HttpClient::sendRequest
*/
public function sendRequest(RequestInterface $request)
public function sendRequest(RequestInterface $request): ResponseInterface
{
$promise = $this->sendAsyncRequest($request);

Expand Down
3 changes: 2 additions & 1 deletion src/HttpClientPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/HttpClientPoolItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/HttpClientRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/HttpMethodsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/PluginClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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)) {
Expand Down