Skip to content

2.x to become the new master #134

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 41 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b7e032b
Use HTTPlug 2.0 (#114)
Jean85 Nov 6, 2018
1adbf74
[2.0] Remove deprecations (#116)
Jean85 Nov 19, 2018
859f4c5
[2.0] Remove plugin chain debug (#119)
Jean85 Nov 20, 2018
94c98c6
Require PHP CS fixer and add basic configuration
Jean85 Nov 20, 2018
9f6d02c
Apply the base configuration
Jean85 Nov 20, 2018
f966926
Add rules to cleanup PHPDocs
Jean85 Nov 20, 2018
720a0cd
Remove unuseful PHPDoc automatically
Jean85 Nov 20, 2018
637d01c
Migrate to Travis CI job sequence
Jean85 Nov 20, 2018
ce5a98c
Remove CS-fixer under 7.3
Jean85 Nov 20, 2018
1cf0f9e
Remove StyleCI config
Jean85 Nov 20, 2018
bb98f24
Merge pull request #120 from Jean85/add-cs-fixer
dbu Nov 20, 2018
543b2a2
[2.0] Add types (#117)
Jean85 Nov 22, 2018
14a2a39
Update phpcs
sagikazarmark Nov 22, 2018
8616247
make redirect plugin final and refactor phpspec test to support that
dbu Dec 4, 2018
18e36cc
adjust decider to not retry client errors (#125)
dbu Dec 9, 2018
d838a40
Merge pull request #127 from php-http/final-redirect-plugin
dbu Dec 13, 2018
b9a862c
Merge remote-tracking branch 'origin/master' into 2.x
dbu Dec 14, 2018
5541efd
fix AddPathPluginSpec for strict return types
dbu Dec 15, 2018
fadb51a
mark classes as final and methods and properties as private
dbu Dec 2, 2018
4d59cc4
Merge pull request #123 from php-http/mark-as-final
dbu Dec 25, 2018
db9afa6
Remove php-cs-fixer from dependencies
Nyholm Dec 26, 2018
b4d5bbc
Merge pull request #131 from Nyholm/patch-cs
dbu Dec 27, 2018
3e3eed0
Test on PHP 7.3
Nyholm Dec 26, 2018
6975385
Merge pull request #130 from Nyholm/patch-73
dbu Dec 27, 2018
700fbb4
Merge remote-tracking branch 'origin/master' into 2.x
dbu Dec 29, 2018
53bddb2
Support PSR-18 (#135)
Nyholm Dec 29, 2018
724f0a1
Added declare strict types (#137)
gmponos Dec 29, 2018
9472484
Added backwards compatibility layer (#133)
Nyholm Dec 29, 2018
d375665
Merge remote-tracking branch 'origin/master' into 2.x
dbu Dec 30, 2018
7d5fe4d
init
Nyholm Dec 31, 2018
54b7683
Small test to prove a bug.
Nyholm Dec 31, 2018
aea5936
cs
Nyholm Dec 31, 2018
7b6cdbe
fix cs violation introduced when merging master to 2.x
dbu Jan 2, 2019
af5e870
Merge pull request #146 from php-http/cs
dbu Jan 2, 2019
3feffd5
Merge pull request #144 from php-http/patch-unittest
dbu Jan 3, 2019
7d80627
add missing type declarations
dbu Jan 2, 2019
fc04c8e
Dont add path to an url we already added a path to. (#141)
Nyholm Jan 3, 2019
c216f92
Merge remote-tracking branch 'origin/master' into 2.x
dbu Jan 3, 2019
0bf5422
Merge pull request #149 from php-http/update-from-master
dbu Jan 3, 2019
6a2df0d
Merge pull request #145 from php-http/more-typing
dbu Jan 3, 2019
414cde1
update composer.json branch alias
dbu Jan 3, 2019
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/.php_cs
/.php_cs.cache
/behat.yml
/build/
/composer.lock
Expand Down
13 changes: 0 additions & 13 deletions .php_cs

This file was deleted.

23 changes: 23 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* Configuration for fabpot/php-cs-fixer
*
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
*/

$finder = PhpCsFixer\Finder::create()
->in('src')
->in('spec')
;
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'array_syntax' => [
'syntax' => 'short',
],
'no_empty_phpdoc' => true,
'no_superfluous_phpdoc_tags' => true,
])
->setFinder($finder);
14 changes: 0 additions & 14 deletions .styleci.yml

This file was deleted.

96 changes: 42 additions & 54 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,55 @@
language: php

sudo: false

dist: trusty

cache:
directories:
- $HOME/.composer/cache/files
directories:
- $HOME/.composer/cache/files

env:
global:
- TEST_COMMAND="composer test"

branches:
except:
- /^analysis-.*$/
php:
- 7.0
- 7.1
- 7.2
- 7.3

matrix:
fast_finish: true
include:
- php: 7.1
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" DEPENDENCIES="doctrine/instantiator:^1.1"

# 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"
fast_finish: true

jobs:
include:
- php: 7.0
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- php: 7.2
env: COVERAGE=true DEPENDENCIES="leanphp/phpspec-code-coverage"
script:
- composer test-ci
after_success:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml --revision=$TRAVIS_COMMIT
# Test LTS versions
- php: 7.2
env: DEPENDENCIES="dunglas/symfony-lock:^2"
- php: 7.2
env: DEPENDENCIES="dunglas/symfony-lock:^3"
- php: 7.2
env: DEPENDENCIES="dunglas/symfony-lock:^4"
- php: 7.2
env: TEST_COMMAND="./vendor/bin/phpunit" DEPENDENCIES="phpunit/phpunit:^7.5 nyholm/psr7:^1.0"

# Latest dev release
- php: 7.3
env: STABILITY="dev"

# Test LTS versions
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^2"
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^3"
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^4" STABILITY="rc"

# Latest dev release
- php: 7.1
env: STABILITY="dev"

allow_failures:
# Latest dev is allowed to fail.
- 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;
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;

install:
- cat composer.json
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
- cat composer.json
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction

script:
- composer validate --strict --no-check-lock
- $TEST_COMMAND

after_success:
- if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
- composer validate --strict --no-check-lock
- composer test
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

## 2.0 (unreleased)

### Changed
- RetryPlugin will no longer retry requests when the response failed with a HTTP code < 500.
- Abstract method `HttpClientPool::chooseHttpClient()` has now an explicit return type (`Http\Client\Common\HttpClientPoolItem`)
- Interface method `Plugin::handleRequest(...)` has now an explicit return type (`Http\Promise\Promise`)
- Made classes final that are not intended to be extended.
Added interfaces for BatchClient, HttpClientRouter and HttpMethodsClient.
(These interfaces use the `Interface` suffix to avoid name collisions.)
- Added an interface for HttpClientPool and moved the abstract class to the HttpClientPool sub namespace.
- AddPathPlugin: Do not add the prefix if the URL already has the same prefix.

### Removed
- Deprecated option `debug_plugins` has been removed from `PluginClient`

## 1.9.0 - 2019-01-03

### Added
Expand All @@ -10,7 +25,7 @@

### Changed

- [RetryPlugin] Renamed the configuration options for the exception retry callback from `decider` to `exception_decider`
- RetryPlugin: Renamed the configuration options for the exception retry callback from `decider` to `exception_decider`
and `delay` to `exception_delay`. The old names still work but are deprecated.

## 1.8.2 - 2018-12-14
Expand Down
20 changes: 15 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
}
],
"require": {
"php": "^5.4 || ^7.0",
"php-http/httplug": "^1.1",
"php": "^7.0",
"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",
"phpspec/prophecy": ">=1.8",
"sebastian/comparator": ">=2"
},
"suggest": {
"ext-json": "To detect JSON responses with the ContentTypePlugin",
"ext-libxml": "To detect XML responses with the ContentTypePlugin",
"php-http/logger-plugin": "PSR-3 Logger plugin",
"php-http/cache-plugin": "PSR-6 Cache plugin",
"php-http/stopwatch-plugin": "Symfony Stopwatch plugin"
Expand All @@ -31,13 +36,18 @@
"Http\\Client\\Common\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"spec\\Http\\Client\\Common\\": "spec/"
}
},
"scripts": {
"test": "vendor/bin/phpspec run",
"test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml"
},
"extra": {
"branch-alias": {
"dev-master": "1.9.x-dev"
"dev-master": "2.x-dev"
}
}
}
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
14 changes: 14 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">

<testsuites>
<testsuite name="HTTPlug unit tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
18 changes: 11 additions & 7 deletions spec/BatchClientSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use PhpSpec\ObjectBehavior;
use Http\Client\Common\BatchClient;
use Http\Client\Common\BatchResult;
use Http\Client\Exception\HttpException;
use Http\Client\Common\Exception\BatchException;

class BatchClientSpec extends ObjectBehavior
{
function let(HttpClient $client)
public function let(HttpClient $client)
{
$this->beAnInstanceOf('Http\Client\Common\BatchClient', [$client]);
$this->beAnInstanceOf(BatchClient::class, [$client]);
}

function it_send_multiple_request_using_send_request(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response1, ResponseInterface $response2)
public function it_send_multiple_request_using_send_request(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response1, ResponseInterface $response2)
{
$client->sendRequest($request1)->willReturn($response1);
$client->sendRequest($request2)->willReturn($response2);

$this->sendRequests([$request1, $request2])->shouldReturnAnInstanceOf('Http\Client\Common\BatchResult');
$this->sendRequests([$request1, $request2])->shouldReturnAnInstanceOf(BatchResult::class);
}

function it_throw_batch_exception_if_one_or_more_request_failed(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response)
public function it_throw_batch_exception_if_one_or_more_request_failed(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response)
{
$client->sendRequest($request1)->willReturn($response);
$client->sendRequest($request2)->willThrow('Http\Client\Exception\HttpException');
$client->sendRequest($request2)->willThrow(HttpException::class);

$this->shouldThrow('Http\Client\Common\Exception\BatchException')->duringSendRequests([$request1, $request2]);
$this->shouldThrow(BatchException::class)->duringSendRequests([$request1, $request2]);
}
}
17 changes: 9 additions & 8 deletions spec/BatchResultSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use PhpSpec\ObjectBehavior;
use Http\Client\Common\BatchResult;

class BatchResultSpec extends ObjectBehavior
{
function it_is_initializable()
public function it_is_initializable()
{
$this->beAnInstanceOf('Http\Client\Common\BatchResult');
$this->beAnInstanceOf(BatchResult::class);
}

function it_is_immutable(RequestInterface $request, ResponseInterface $response)
public function it_is_immutable(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

$this->getResponses()->shouldReturn([]);
$new->shouldHaveType('Http\Client\Common\BatchResult');
$new->shouldHaveType(BatchResult::class);
$new->getResponses()->shouldReturn([$response]);
}

function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
public function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

Expand All @@ -33,17 +34,17 @@ function it_has_a_responses(RequestInterface $request, ResponseInterface $respon
$new->getResponses()->shouldReturn([$response]);
}

function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
public function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

$this->shouldThrow('UnexpectedValueException')->duringGetResponseFor($request);
$this->shouldThrow(\UnexpectedValueException::class)->duringGetResponseFor($request);
$this->isSuccessful($request)->shouldReturn(false);
$new->getResponseFor($request)->shouldReturn($response);
$new->isSuccessful($request)->shouldReturn(true);
}

function it_keeps_exception_after_add_request(RequestInterface $request1, Exception $exception, RequestInterface $request2, ResponseInterface $response)
public function it_keeps_exception_after_add_request(RequestInterface $request1, Exception $exception, RequestInterface $request2, ResponseInterface $response)
{
$new = $this->addException($request1, $exception);
$new = $new->addResponse($request2, $response);
Expand Down
Loading