diff --git a/composer.json b/composer.json index 8626f9e..3872206 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,9 @@ "require": { "php": ">=5.4", "php-http/httplug": "1.0.0-beta", - "php-http/client-tools": "^0.1@dev", "php-http/message-factory": "^1.0", + "php-http/promise": "^0.1.1", + "php-http/client-common": "^0.1", "symfony/options-resolver": "^2.6|^3.0" }, "require-dev": { diff --git a/spec/CachePluginSpec.php b/spec/CachePluginSpec.php index 36f19e7..6824f4f 100644 --- a/spec/CachePluginSpec.php +++ b/spec/CachePluginSpec.php @@ -2,8 +2,8 @@ namespace spec\Http\Client\Plugin; -use Http\Client\Tools\Promise\FulfilledPromise; use Http\Message\StreamFactory; +use Http\Promise\FulfilledPromise; use PhpSpec\ObjectBehavior; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; @@ -115,4 +115,4 @@ function it_calculate_age_from_response(CacheItemPoolInterface $pool, CacheItemI $this->handleRequest($request, $next, function () {}); } -} \ No newline at end of file +} diff --git a/spec/CookiePluginSpec.php b/spec/CookiePluginSpec.php index e1faba5..36c93d2 100644 --- a/spec/CookiePluginSpec.php +++ b/spec/CookiePluginSpec.php @@ -2,7 +2,7 @@ namespace spec\Http\Client\Plugin; -use Http\Client\Tools\Promise\FulfilledPromise; +use Http\Promise\FulfilledPromise; use Http\Cookie\Cookie; use Http\Cookie\CookieJar; use Http\Promise\Promise; diff --git a/spec/DecoderPluginSpec.php b/spec/DecoderPluginSpec.php index 98866eb..6227380 100644 --- a/spec/DecoderPluginSpec.php +++ b/spec/DecoderPluginSpec.php @@ -2,7 +2,7 @@ namespace spec\Http\Client\Plugin; -use Http\Client\Tools\Promise\FulfilledPromise; +use Http\Promise\FulfilledPromise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; diff --git a/spec/ErrorPluginSpec.php b/spec/ErrorPluginSpec.php index e4b32a3..f93e8ec 100644 --- a/spec/ErrorPluginSpec.php +++ b/spec/ErrorPluginSpec.php @@ -2,7 +2,7 @@ namespace spec\Http\Client\Plugin; -use Http\Client\Tools\Promise\FulfilledPromise; +use Http\Promise\FulfilledPromise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use PhpSpec\ObjectBehavior; @@ -30,7 +30,7 @@ function it_throw_request_exception_on_500_error(RequestInterface $request, Resp } }; - $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\RejectedPromise'); + $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Promise\RejectedPromise'); } function it_returns_response(RequestInterface $request, ResponseInterface $response) @@ -43,7 +43,7 @@ function it_returns_response(RequestInterface $request, ResponseInterface $respo } }; - $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\FulfilledPromise'); + $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Promise\FulfilledPromise'); } function it_throws_request_exception_on_custom_regex(RequestInterface $request, ResponseInterface $response) @@ -57,6 +57,6 @@ function it_throws_request_exception_on_custom_regex(RequestInterface $request, } }; - $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\RejectedPromise'); + $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Promise\RejectedPromise'); } } diff --git a/spec/HistoryPluginSpec.php b/spec/HistoryPluginSpec.php index e3e466b..91c5b8b 100644 --- a/spec/HistoryPluginSpec.php +++ b/spec/HistoryPluginSpec.php @@ -4,8 +4,8 @@ use Http\Client\Exception\TransferException; use Http\Client\Plugin\Journal\Journal; -use Http\Client\Tools\Promise\FulfilledPromise; -use Http\Client\Tools\Promise\RejectedPromise; +use Http\Promise\FulfilledPromise; +use Http\Promise\RejectedPromise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use PhpSpec\ObjectBehavior; diff --git a/spec/LoggerPluginSpec.php b/spec/LoggerPluginSpec.php index 8c4eba1..90f77a6 100644 --- a/spec/LoggerPluginSpec.php +++ b/spec/LoggerPluginSpec.php @@ -4,8 +4,8 @@ use Http\Client\Exception\HttpException; use Http\Client\Exception\NetworkException; -use Http\Client\Tools\Promise\FulfilledPromise; -use Http\Client\Tools\Promise\RejectedPromise; +use Http\Promise\FulfilledPromise; +use Http\Promise\RejectedPromise; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Psr\Http\Message\RequestInterface; diff --git a/spec/RedirectPluginSpec.php b/spec/RedirectPluginSpec.php index 43c0f08..9e3ecba 100644 --- a/spec/RedirectPluginSpec.php +++ b/spec/RedirectPluginSpec.php @@ -3,7 +3,7 @@ namespace spec\Http\Client\Plugin; use Http\Client\Plugin\RedirectPlugin; -use Http\Client\Tools\Promise\FulfilledPromise; +use Http\Promise\FulfilledPromise; use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -63,7 +63,7 @@ function it_redirects_on_302( $promise->wait()->shouldBeCalled()->willReturn($finalResponse); $finalPromise = $this->handleRequest($request, $next, $first); - $finalPromise->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\FulfilledPromise'); + $finalPromise->shouldReturnAnInstanceOf('Http\Promise\FulfilledPromise'); $finalPromise->wait()->shouldReturn($finalResponse); } @@ -192,7 +192,7 @@ function it_throws_http_exception_on_no_location(RequestInterface $request, Resp $responseRedirect->hasHeader('Location')->willReturn(false); $promise = $this->handleRequest($request, $next, function () {}); - $promise->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\RejectedPromise'); + $promise->shouldReturnAnInstanceOf('Http\Promise\RejectedPromise'); $promise->shouldThrow('Http\Client\Exception\HttpException')->duringWait(); } @@ -211,7 +211,7 @@ function it_throws_http_exception_on_invalid_location(RequestInterface $request, $responseRedirect->hasHeader('Location')->willReturn(true); $promise = $this->handleRequest($request, $next, function () {}); - $promise->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\RejectedPromise'); + $promise->shouldReturnAnInstanceOf('Http\Promise\RejectedPromise'); $promise->shouldThrow('Http\Client\Exception\HttpException')->duringWait(); } @@ -227,7 +227,7 @@ function it_throw_multi_redirect_exception_on_300(RequestInterface $request, Res $responseRedirect->getStatusCode()->willReturn('300'); $promise = $this->handleRequest($request, $next, function () {}); - $promise->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\RejectedPromise'); + $promise->shouldReturnAnInstanceOf('Http\Promise\RejectedPromise'); $promise->shouldThrow('Http\Client\Plugin\Exception\MultipleRedirectionException')->duringWait(); } @@ -243,7 +243,7 @@ function it_throw_multi_redirect_exception_on_300_if_no_location(RequestInterfac $responseRedirect->hasHeader('Location')->willReturn(false); $promise = $this->handleRequest($request, $next, function () {}); - $promise->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\RejectedPromise'); + $promise->shouldReturnAnInstanceOf('Http\Promise\RejectedPromise'); $promise->shouldThrow('Http\Client\Plugin\Exception\MultipleRedirectionException')->duringWait(); } @@ -370,7 +370,7 @@ function it_throws_circular_redirection_exception(UriInterface $uri, UriInterfac }; $promise = $this->handleRequest($request, $next, $first); - $promise->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\RejectedPromise'); + $promise->shouldReturnAnInstanceOf('Http\Promise\RejectedPromise'); $promise->shouldThrow('Http\Client\Plugin\Exception\CircularRedirectionException')->duringWait(); } } diff --git a/spec/RetryPluginSpec.php b/spec/RetryPluginSpec.php index c00086f..5187216 100644 --- a/spec/RetryPluginSpec.php +++ b/spec/RetryPluginSpec.php @@ -3,8 +3,8 @@ namespace spec\Http\Client\Plugin; use Http\Client\Exception; -use Http\Client\Tools\Promise\FulfilledPromise; -use Http\Client\Tools\Promise\RejectedPromise; +use Http\Promise\FulfilledPromise; +use Http\Promise\RejectedPromise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use PhpSpec\ObjectBehavior; @@ -30,7 +30,7 @@ function it_returns_response(RequestInterface $request, ResponseInterface $respo } }; - $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\FulfilledPromise'); + $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Promise\FulfilledPromise'); } function it_throws_exception_on_multiple_exceptions(RequestInterface $request) @@ -53,7 +53,7 @@ function it_throws_exception_on_multiple_exceptions(RequestInterface $request) }; $promise = $this->handleRequest($request, $next, function () {}); - $promise->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\RejectedPromise'); + $promise->shouldReturnAnInstanceOf('Http\Promise\RejectedPromise'); $promise->shouldThrow($exception2)->duringWait(); } @@ -76,7 +76,7 @@ function it_returns_response_on_second_try(RequestInterface $request, ResponseIn }; $promise = $this->handleRequest($request, $next, function () {}); - $promise->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\FulfilledPromise'); + $promise->shouldReturnAnInstanceOf('Http\Promise\FulfilledPromise'); $promise->wait()->shouldReturn($response); } @@ -98,7 +98,7 @@ function it_does_not_keep_history_of_old_failure(RequestInterface $request, Resp } }; - $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\FulfilledPromise'); - $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Tools\Promise\FulfilledPromise'); + $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Promise\FulfilledPromise'); + $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Promise\FulfilledPromise'); } } diff --git a/spec/StopwatchPluginSpec.php b/spec/StopwatchPluginSpec.php index 2c68503..2cc2141 100644 --- a/spec/StopwatchPluginSpec.php +++ b/spec/StopwatchPluginSpec.php @@ -3,8 +3,8 @@ namespace spec\Http\Client\Plugin; use Http\Client\Exception\NetworkException; -use Http\Client\Tools\Promise\FulfilledPromise; -use Http\Client\Tools\Promise\RejectedPromise; +use Http\Promise\FulfilledPromise; +use Http\Promise\RejectedPromise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Symfony\Component\Stopwatch\Stopwatch; diff --git a/src/CachePlugin.php b/src/CachePlugin.php index 6d1bb9c..741c1fe 100644 --- a/src/CachePlugin.php +++ b/src/CachePlugin.php @@ -2,8 +2,8 @@ namespace Http\Client\Plugin; -use Http\Client\Tools\Promise\FulfilledPromise; use Http\Message\StreamFactory; +use Http\Promise\FulfilledPromise; use Psr\Cache\CacheItemPoolInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; diff --git a/src/EmulateAsyncClient.php b/src/EmulateAsyncClient.php index 05953d3..2dc4c85 100644 --- a/src/EmulateAsyncClient.php +++ b/src/EmulateAsyncClient.php @@ -4,11 +4,13 @@ use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; -use Http\Client\Tools\HttpAsyncClientEmulator; -use Http\Client\Tools\HttpClientDecorator; +use Http\Client\Common\HttpAsyncClientEmulator; +use Http\Client\Common\HttpClientDecorator; /** * Emulate an async client. + * + * This should be replaced by an anonymous class in PHP 7. */ class EmulateAsyncClient implements HttpClient, HttpAsyncClient {