From 94c98c68ad18e73c06d6050076c90d2a786be079 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 16:37:01 +0100 Subject: [PATCH 1/7] Require PHP CS fixer and add basic configuration --- .gitignore | 1 + .php_cs | 25 ++++++++++++++++--------- composer.json | 5 ++++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 16b4a20..560b927 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /phpspec.yml /phpunit.xml /vendor/ +/.php_cs.cache diff --git a/.php_cs b/.php_cs index 23ba165..7da3701 100644 --- a/.php_cs +++ b/.php_cs @@ -1,13 +1,20 @@ setRules([ + '@PSR2' => true, + '@Symfony' => true, + 'array_syntax' => [ + 'syntax' => 'short', + ], +]); -use SLLH\StyleCIBridge\ConfigBridge; +$finder = PhpCsFixer\Finder::create(); +$finder->in([ + 'src', + 'spec' +]); -return ConfigBridge::create(); +$config->setFinder($finder); + +return $config; diff --git a/composer.json b/composer.json index fc3d1c1..882758b 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "guzzlehttp/psr7": "^1.4", "phpspec/phpspec": "^3.4 || ^4.2", "phpspec/prophecy": ">=1.8", - "sebastian/comparator": ">=2" + "sebastian/comparator": ">=2", + "friendsofphp/php-cs-fixer": "^2.2" }, "suggest": { "php-http/logger-plugin": "PSR-3 Logger plugin", @@ -35,6 +36,8 @@ } }, "scripts": { + "cs-check": "vendor/bin/php-cs-fixer fix --dry-run", + "cs-fix": "vendor/bin/php-cs-fixer fix", "test": "vendor/bin/phpspec run", "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" }, From 9f6d02cff27d988cfac948a88a041621d6945581 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 16:39:58 +0100 Subject: [PATCH 2/7] Apply the base configuration --- spec/BatchClientSpec.php | 6 +- spec/BatchResultSpec.php | 10 +-- spec/EmulatedHttpAsyncClientSpec.php | 14 ++-- spec/EmulatedHttpClientSpec.php | 15 ++-- spec/Exception/BatchExceptionSpec.php | 11 ++- spec/FlexibleHttpClientSpec.php | 16 ++-- .../LeastUsedClientPoolSpec.php | 1 - spec/HttpClientPoolItemSpec.php | 12 +-- spec/HttpClientRouterSpec.php | 14 ++-- spec/HttpMethodsClientSpec.php | 27 ++++--- spec/Plugin/AddHostPluginSpec.php | 14 ++-- spec/Plugin/AddPathPluginSpec.php | 14 ++-- spec/Plugin/AuthenticationPluginSpec.php | 10 +-- spec/Plugin/BaseUriPluginSpec.php | 14 ++-- spec/Plugin/ContentLengthPluginSpec.php | 10 +-- spec/Plugin/ContentTypePluginSpec.php | 30 ++++---- spec/Plugin/CookiePluginSpec.php | 32 ++++---- spec/Plugin/DecoderPluginSpec.php | 22 +++--- spec/Plugin/ErrorPluginSpec.php | 20 ++--- spec/Plugin/HeaderAppendPluginSpec.php | 7 +- spec/Plugin/HeaderDefaultsPluginSpec.php | 5 +- spec/Plugin/HeaderRemovePluginSpec.php | 5 +- spec/Plugin/HeaderSetPluginSpec.php | 7 +- spec/Plugin/HistoryPluginSpec.php | 14 ++-- spec/Plugin/QueryDefaultsPluginSpec.php | 1 - spec/Plugin/RedirectPluginSpec.php | 74 +++++++++---------- spec/Plugin/RequestMatcherPluginSpec.php | 12 +-- spec/Plugin/RetryPluginSpec.php | 40 +++++----- spec/PluginClientFactorySpec.php | 6 +- spec/PluginClientSpec.php | 19 +++-- src/HttpClientRouter.php | 2 +- src/Plugin.php | 2 +- src/Plugin/BaseUriPlugin.php | 2 +- src/Plugin/ContentTypePlugin.php | 6 +- src/Plugin/ErrorPlugin.php | 2 +- src/Plugin/RetryPlugin.php | 4 +- 36 files changed, 235 insertions(+), 265 deletions(-) diff --git a/spec/BatchClientSpec.php b/spec/BatchClientSpec.php index 962f00a..8b7e96d 100644 --- a/spec/BatchClientSpec.php +++ b/spec/BatchClientSpec.php @@ -9,12 +9,12 @@ class BatchClientSpec extends ObjectBehavior { - function let(HttpClient $client) + public function let(HttpClient $client) { $this->beAnInstanceOf('Http\Client\Common\BatchClient', [$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); @@ -22,7 +22,7 @@ function it_send_multiple_request_using_send_request(HttpClient $client, Request $this->sendRequests([$request1, $request2])->shouldReturnAnInstanceOf('Http\Client\Common\BatchResult'); } - 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'); diff --git a/spec/BatchResultSpec.php b/spec/BatchResultSpec.php index c4618ac..aa3bb14 100644 --- a/spec/BatchResultSpec.php +++ b/spec/BatchResultSpec.php @@ -9,12 +9,12 @@ class BatchResultSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->beAnInstanceOf('Http\Client\Common\BatchResult'); } - function it_is_immutable(RequestInterface $request, ResponseInterface $response) + public function it_is_immutable(RequestInterface $request, ResponseInterface $response) { $new = $this->addResponse($request, $response); @@ -23,7 +23,7 @@ function it_is_immutable(RequestInterface $request, ResponseInterface $response) $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); @@ -33,7 +33,7 @@ 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); @@ -43,7 +43,7 @@ function it_has_a_response_for_a_request(RequestInterface $request, ResponseInte $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); diff --git a/spec/EmulatedHttpAsyncClientSpec.php b/spec/EmulatedHttpAsyncClientSpec.php index b7a9edd..ca8a4d1 100644 --- a/spec/EmulatedHttpAsyncClientSpec.php +++ b/spec/EmulatedHttpAsyncClientSpec.php @@ -9,27 +9,27 @@ class EmulatedHttpAsyncClientSpec extends ObjectBehavior { - function let(HttpClient $httpClient) + public function let(HttpClient $httpClient) { $this->beConstructedWith($httpClient); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\EmulatedHttpAsyncClient'); } - function it_is_an_http_client() + public function it_is_an_http_client() { $this->shouldImplement('Http\Client\HttpClient'); } - function it_is_an_async_http_client() + public function it_is_an_async_http_client() { $this->shouldImplement('Http\Client\HttpAsyncClient'); } - function it_emulates_a_successful_request( + public function it_emulates_a_successful_request( HttpClient $httpClient, RequestInterface $request, ResponseInterface $response @@ -39,14 +39,14 @@ function it_emulates_a_successful_request( $this->sendAsyncRequest($request)->shouldReturnAnInstanceOf('Http\Client\Promise\HttpFulfilledPromise'); } - function it_emulates_a_failed_request(HttpClient $httpClient, RequestInterface $request) + public function it_emulates_a_failed_request(HttpClient $httpClient, RequestInterface $request) { $httpClient->sendRequest($request)->willThrow('Http\Client\Exception\TransferException'); $this->sendAsyncRequest($request)->shouldReturnAnInstanceOf('Http\Client\Promise\HttpRejectedPromise'); } - function it_decorates_the_underlying_client( + public function it_decorates_the_underlying_client( HttpClient $httpClient, RequestInterface $request, ResponseInterface $response diff --git a/spec/EmulatedHttpClientSpec.php b/spec/EmulatedHttpClientSpec.php index 976f772..cf6e076 100644 --- a/spec/EmulatedHttpClientSpec.php +++ b/spec/EmulatedHttpClientSpec.php @@ -3,7 +3,6 @@ namespace spec\Http\Client\Common; use Http\Client\Exception\TransferException; -use Http\Client\HttpClient; use Http\Client\HttpAsyncClient; use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; @@ -12,27 +11,27 @@ class EmulatedHttpClientSpec extends ObjectBehavior { - function let(HttpAsyncClient $httpAsyncClient) + public function let(HttpAsyncClient $httpAsyncClient) { $this->beConstructedWith($httpAsyncClient); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\EmulatedHttpClient'); } - function it_is_an_http_client() + public function it_is_an_http_client() { $this->shouldImplement('Http\Client\HttpClient'); } - function it_is_an_async_http_client() + public function it_is_an_async_http_client() { $this->shouldImplement('Http\Client\HttpAsyncClient'); } - function it_emulates_a_successful_request( + public function it_emulates_a_successful_request( HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise, @@ -47,7 +46,7 @@ function it_emulates_a_successful_request( $this->sendRequest($request)->shouldReturn($response); } - function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise) + public function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise) { $promise->wait()->shouldBeCalled(); $promise->getState()->willReturn(Promise::REJECTED); @@ -58,7 +57,7 @@ function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestI $this->shouldThrow('Http\Client\Exception')->duringSendRequest($request); } - function it_decorates_the_underlying_client( + public function it_decorates_the_underlying_client( HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise diff --git a/spec/Exception/BatchExceptionSpec.php b/spec/Exception/BatchExceptionSpec.php index fa8d8d6..0a32607 100644 --- a/spec/Exception/BatchExceptionSpec.php +++ b/spec/Exception/BatchExceptionSpec.php @@ -3,33 +3,32 @@ namespace spec\Http\Client\Common\Exception; use Http\Client\Common\BatchResult; -use Http\Client\Exception; use PhpSpec\ObjectBehavior; class BatchExceptionSpec extends ObjectBehavior { - function let() + public function let() { $batchResult = new BatchResult(); $this->beConstructedWith($batchResult); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\Exception\BatchException'); } - function it_is_a_runtime_exception() + public function it_is_a_runtime_exception() { $this->shouldHaveType('RuntimeException'); } - function it_is_an_exception() + public function it_is_an_exception() { $this->shouldImplement('Http\Client\Exception'); } - function it_has_a_batch_result() + public function it_has_a_batch_result() { $this->getResult()->shouldHaveType('Http\Client\Common\BatchResult'); } diff --git a/spec/FlexibleHttpClientSpec.php b/spec/FlexibleHttpClientSpec.php index 70e6e4d..769b4c3 100644 --- a/spec/FlexibleHttpClientSpec.php +++ b/spec/FlexibleHttpClientSpec.php @@ -11,34 +11,34 @@ class FlexibleHttpClientSpec extends ObjectBehavior { - function let(HttpClient $httpClient) + public function let(HttpClient $httpClient) { $this->beConstructedWith($httpClient); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\FlexibleHttpClient'); } - function it_is_an_http_client() + public function it_is_an_http_client() { $this->shouldImplement('Http\Client\HttpClient'); } - function it_is_an_async_http_client() + public function it_is_an_async_http_client() { $this->shouldImplement('Http\Client\HttpAsyncClient'); } - function it_throw_exception_if_invalid_client() + public function it_throw_exception_if_invalid_client() { $this->beConstructedWith(null); $this->shouldThrow('\LogicException')->duringInstantiation(); } - function it_emulates_an_async_client( + public function it_emulates_an_async_client( HttpClient $httpClient, RequestInterface $syncRequest, ResponseInterface $syncResponse, @@ -57,7 +57,7 @@ function it_emulates_an_async_client( $promise->wait()->shouldReturn($asyncResponse); } - function it_emulates_a_client( + public function it_emulates_a_client( HttpAsyncClient $httpAsyncClient, RequestInterface $asyncRequest, Promise $promise, @@ -75,7 +75,7 @@ function it_emulates_a_client( $this->sendRequest($syncRequest)->shouldReturn($syncResponse); } - function it_does_not_emulate_a_client($client, RequestInterface $syncRequest, RequestInterface $asyncRequest) + public function it_does_not_emulate_a_client($client, RequestInterface $syncRequest, RequestInterface $asyncRequest) { $client->implement('Http\Client\HttpClient'); $client->implement('Http\Client\HttpAsyncClient'); diff --git a/spec/HttpClientPool/LeastUsedClientPoolSpec.php b/spec/HttpClientPool/LeastUsedClientPoolSpec.php index 82855d9..8642c31 100644 --- a/spec/HttpClientPool/LeastUsedClientPoolSpec.php +++ b/spec/HttpClientPool/LeastUsedClientPoolSpec.php @@ -6,7 +6,6 @@ use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; use Http\Promise\Promise; -use PhpSpec\Exception\Example\SkippingException; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Psr\Http\Message\RequestInterface; diff --git a/spec/HttpClientPoolItemSpec.php b/spec/HttpClientPoolItemSpec.php index 059ec8d..cba68d8 100644 --- a/spec/HttpClientPoolItemSpec.php +++ b/spec/HttpClientPoolItemSpec.php @@ -156,7 +156,7 @@ public function getState() public function wait($unwrap = true) { - if ($this->state === Promise::FULFILLED) { + if (Promise::FULFILLED === $this->state) { if (!$unwrap) { return; } @@ -164,7 +164,7 @@ public function wait($unwrap = true) return $this->response; } - if ($this->state === Promise::REJECTED) { + if (Promise::REJECTED === $this->state) { if (!$unwrap) { return; } @@ -175,7 +175,7 @@ public function wait($unwrap = true) while (count($this->queue) > 0) { $callbacks = array_shift($this->queue); - if ($this->response !== null) { + if (null !== $this->response) { try { $this->response = $callbacks[0]($this->response); $this->exception = null; @@ -183,7 +183,7 @@ public function wait($unwrap = true) $this->response = null; $this->exception = $exception; } - } elseif ($this->exception !== null) { + } elseif (null !== $this->exception) { try { $this->response = $callbacks[1]($this->exception); $this->exception = null; @@ -194,7 +194,7 @@ public function wait($unwrap = true) } } - if ($this->response !== null) { + if (null !== $this->response) { $this->state = Promise::FULFILLED; if ($unwrap) { @@ -202,7 +202,7 @@ public function wait($unwrap = true) } } - if ($this->exception !== null) { + if (null !== $this->exception) { $this->state = Promise::REJECTED; if ($unwrap) { diff --git a/spec/HttpClientRouterSpec.php b/spec/HttpClientRouterSpec.php index 1119722..e43acea 100644 --- a/spec/HttpClientRouterSpec.php +++ b/spec/HttpClientRouterSpec.php @@ -12,22 +12,22 @@ class HttpClientRouterSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\HttpClientRouter'); } - function it_is_an_http_client() + public function it_is_an_http_client() { $this->shouldImplement('Http\Client\HttpClient'); } - function it_is_an_async_http_client() + public function it_is_an_async_http_client() { $this->shouldImplement('Http\Client\HttpAsyncClient'); } - function it_send_request(RequestMatcher $matcher, HttpClient $client, RequestInterface $request, ResponseInterface $response) + public function it_send_request(RequestMatcher $matcher, HttpClient $client, RequestInterface $request, ResponseInterface $response) { $this->addClient($client, $matcher); $matcher->matches($request)->willReturn(true); @@ -36,7 +36,7 @@ function it_send_request(RequestMatcher $matcher, HttpClient $client, RequestInt $this->sendRequest($request)->shouldReturn($response); } - function it_send_async_request(RequestMatcher $matcher, HttpAsyncClient $client, RequestInterface $request, Promise $promise) + public function it_send_async_request(RequestMatcher $matcher, HttpAsyncClient $client, RequestInterface $request, Promise $promise) { $this->addClient($client, $matcher); $matcher->matches($request)->willReturn(true); @@ -45,7 +45,7 @@ function it_send_async_request(RequestMatcher $matcher, HttpAsyncClient $client, $this->sendAsyncRequest($request)->shouldReturn($promise); } - function it_throw_exception_on_send_request(RequestMatcher $matcher, HttpClient $client, RequestInterface $request) + public function it_throw_exception_on_send_request(RequestMatcher $matcher, HttpClient $client, RequestInterface $request) { $this->addClient($client, $matcher); $matcher->matches($request)->willReturn(false); @@ -53,7 +53,7 @@ function it_throw_exception_on_send_request(RequestMatcher $matcher, HttpClient $this->shouldThrow('Http\Client\Exception\RequestException')->duringSendRequest($request); } - function it_throw_exception_on_send_async_request(RequestMatcher $matcher, HttpAsyncClient $client, RequestInterface $request) + public function it_throw_exception_on_send_async_request(RequestMatcher $matcher, HttpAsyncClient $client, RequestInterface $request) { $this->addClient($client, $matcher); $matcher->matches($request)->willReturn(false); diff --git a/spec/HttpMethodsClientSpec.php b/spec/HttpMethodsClientSpec.php index 07c0b47..b68c8c4 100644 --- a/spec/HttpMethodsClientSpec.php +++ b/spec/HttpMethodsClientSpec.php @@ -2,7 +2,6 @@ namespace spec\Http\Client\Common; -use Http\Client\BatchResult; use Http\Client\HttpClient; use Http\Client\Common\HttpMethodsClient; use Http\Message\MessageFactory; @@ -12,73 +11,73 @@ class HttpMethodsClientSpec extends ObjectBehavior { - function let(HttpClient $client, MessageFactory $messageFactory) + public function let(HttpClient $client, MessageFactory $messageFactory) { $this->beAnInstanceOf( 'spec\Http\Client\Common\HttpMethodsClientStub', [ $client, - $messageFactory + $messageFactory, ] ); } - function it_sends_a_get_request() + public function it_sends_a_get_request() { $data = HttpMethodsClientStub::$requestData; $this->get($data['uri'], $data['headers'])->shouldReturn(true); } - function it_sends_a_head_request() + public function it_sends_a_head_request() { $data = HttpMethodsClientStub::$requestData; $this->head($data['uri'], $data['headers'])->shouldReturn(true); } - function it_sends_a_trace_request() + public function it_sends_a_trace_request() { $data = HttpMethodsClientStub::$requestData; $this->trace($data['uri'], $data['headers'])->shouldReturn(true); } - function it_sends_a_post_request() + public function it_sends_a_post_request() { $data = HttpMethodsClientStub::$requestData; $this->post($data['uri'], $data['headers'], $data['body'])->shouldReturn(true); } - function it_sends_a_put_request() + public function it_sends_a_put_request() { $data = HttpMethodsClientStub::$requestData; $this->put($data['uri'], $data['headers'], $data['body'])->shouldReturn(true); } - function it_sends_a_patch_request() + public function it_sends_a_patch_request() { $data = HttpMethodsClientStub::$requestData; $this->patch($data['uri'], $data['headers'], $data['body'])->shouldReturn(true); } - function it_sends_a_delete_request() + public function it_sends_a_delete_request() { $data = HttpMethodsClientStub::$requestData; $this->delete($data['uri'], $data['headers'], $data['body'])->shouldReturn(true); } - function it_sends_a_options_request() + public function it_sends_a_options_request() { $data = HttpMethodsClientStub::$requestData; $this->options($data['uri'], $data['headers'], $data['body'])->shouldReturn(true); } - function it_sends_request_with_underlying_client(HttpClient $client, MessageFactory $messageFactory, RequestInterface $request, ResponseInterface $response) + public function it_sends_request_with_underlying_client(HttpClient $client, MessageFactory $messageFactory, RequestInterface $request, ResponseInterface $response) { $client->sendRequest($request)->shouldBeCalled()->willReturn($response); @@ -90,11 +89,11 @@ function it_sends_request_with_underlying_client(HttpClient $client, MessageFact class HttpMethodsClientStub extends HttpMethodsClient { public static $requestData = [ - 'uri' => '/uri', + 'uri' => '/uri', 'headers' => [ 'Content-Type' => 'text/plain', ], - 'body' => 'body' + 'body' => 'body', ]; /** diff --git a/spec/Plugin/AddHostPluginSpec.php b/spec/Plugin/AddHostPluginSpec.php index caf4f21..a6630bd 100644 --- a/spec/Plugin/AddHostPluginSpec.php +++ b/spec/Plugin/AddHostPluginSpec.php @@ -2,34 +2,32 @@ namespace spec\Http\Client\Common\Plugin; -use Http\Message\StreamFactory; -use Http\Message\UriFactory; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; use PhpSpec\ObjectBehavior; class AddHostPluginSpec extends ObjectBehavior { - function let(UriInterface $uri) + public function let(UriInterface $uri) { $this->beConstructedWith($uri); } - function it_is_initializable(UriInterface $uri) + public function it_is_initializable(UriInterface $uri) { $uri->getHost()->shouldBeCalled()->willReturn('example.com'); $this->shouldHaveType('Http\Client\Common\Plugin\AddHostPlugin'); } - function it_is_a_plugin(UriInterface $uri) + public function it_is_a_plugin(UriInterface $uri) { $uri->getHost()->shouldBeCalled()->willReturn('example.com'); $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_adds_domain( + public function it_adds_domain( RequestInterface $request, UriInterface $host, UriInterface $uri @@ -50,7 +48,7 @@ function it_adds_domain( $this->handleRequest($request, function () {}, function () {}); } - function it_replaces_domain( + public function it_replaces_domain( RequestInterface $request, UriInterface $host, UriInterface $uri @@ -70,7 +68,7 @@ function it_replaces_domain( $this->handleRequest($request, function () {}, function () {}); } - function it_does_nothing_when_domain_exists( + public function it_does_nothing_when_domain_exists( RequestInterface $request, UriInterface $host, UriInterface $uri diff --git a/spec/Plugin/AddPathPluginSpec.php b/spec/Plugin/AddPathPluginSpec.php index a7ec9b5..c95301c 100644 --- a/spec/Plugin/AddPathPluginSpec.php +++ b/spec/Plugin/AddPathPluginSpec.php @@ -2,34 +2,32 @@ namespace spec\Http\Client\Common\Plugin; -use Http\Message\StreamFactory; -use Http\Message\UriFactory; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; use PhpSpec\ObjectBehavior; class AddPathPluginSpec extends ObjectBehavior { - function let(UriInterface $uri) + public function let(UriInterface $uri) { $this->beConstructedWith($uri); } - function it_is_initializable(UriInterface $uri) + public function it_is_initializable(UriInterface $uri) { $uri->getPath()->shouldBeCalled()->willReturn('/api'); $this->shouldHaveType('Http\Client\Common\Plugin\AddPathPlugin'); } - function it_is_a_plugin(UriInterface $uri) + public function it_is_a_plugin(UriInterface $uri) { $uri->getPath()->shouldBeCalled()->willReturn('/api'); $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_adds_path( + public function it_adds_path( RequestInterface $request, UriInterface $host, UriInterface $uri @@ -46,7 +44,7 @@ function it_adds_path( $this->handleRequest($request, function () {}, function () {}); } - function it_throws_exception_on_trailing_slash(UriInterface $host) + public function it_throws_exception_on_trailing_slash(UriInterface $host) { $host->getPath()->shouldBeCalled()->willReturn('/api/'); @@ -54,7 +52,7 @@ function it_throws_exception_on_trailing_slash(UriInterface $host) $this->shouldThrow('\LogicException')->duringInstantiation(); } - function it_throws_exception_on_empty_path(UriInterface $host) + public function it_throws_exception_on_empty_path(UriInterface $host) { $host->getPath()->shouldBeCalled()->willReturn(''); diff --git a/spec/Plugin/AuthenticationPluginSpec.php b/spec/Plugin/AuthenticationPluginSpec.php index 02d1187..549b507 100644 --- a/spec/Plugin/AuthenticationPluginSpec.php +++ b/spec/Plugin/AuthenticationPluginSpec.php @@ -10,26 +10,26 @@ class AuthenticationPluginSpec extends ObjectBehavior { - function let(Authentication $authentication) + public function let(Authentication $authentication) { $this->beConstructedWith($authentication); } - function it_is_initializable(Authentication $authentication) + public function it_is_initializable(Authentication $authentication) { $this->shouldHaveType('Http\Client\Common\Plugin\AuthenticationPlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_sends_an_authenticated_request(Authentication $authentication, RequestInterface $notAuthedRequest, RequestInterface $authedRequest, Promise $promise) + public function it_sends_an_authenticated_request(Authentication $authentication, RequestInterface $notAuthedRequest, RequestInterface $authedRequest, Promise $promise) { $authentication->authenticate($notAuthedRequest)->willReturn($authedRequest); - $next = function (RequestInterface $request) use($authedRequest, $promise) { + $next = function (RequestInterface $request) use ($authedRequest, $promise) { if (Argument::is($authedRequest->getWrappedObject())->scoreArgument($request)) { return $promise->getWrappedObject(); } diff --git a/spec/Plugin/BaseUriPluginSpec.php b/spec/Plugin/BaseUriPluginSpec.php index 2faf769..e2f8c46 100644 --- a/spec/Plugin/BaseUriPluginSpec.php +++ b/spec/Plugin/BaseUriPluginSpec.php @@ -2,20 +2,18 @@ namespace spec\Http\Client\Common\Plugin; -use Http\Message\StreamFactory; -use Http\Message\UriFactory; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; use PhpSpec\ObjectBehavior; class BaseUriPluginSpec extends ObjectBehavior { - function let(UriInterface $uri) + public function let(UriInterface $uri) { $this->beConstructedWith($uri); } - function it_is_initializable(UriInterface $uri) + public function it_is_initializable(UriInterface $uri) { $uri->getHost()->shouldBeCalled()->willReturn('example.com'); $uri->getPath()->shouldBeCalled()->willReturn('/api'); @@ -23,7 +21,7 @@ function it_is_initializable(UriInterface $uri) $this->shouldHaveType('Http\Client\Common\Plugin\BaseUriPlugin'); } - function it_is_a_plugin(UriInterface $uri) + public function it_is_a_plugin(UriInterface $uri) { $uri->getHost()->shouldBeCalled()->willReturn('example.com'); $uri->getPath()->shouldBeCalled()->willReturn('/api'); @@ -31,7 +29,7 @@ function it_is_a_plugin(UriInterface $uri) $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_adds_domain_and_path( + public function it_adds_domain_and_path( RequestInterface $request, UriInterface $host, UriInterface $uri @@ -55,7 +53,7 @@ function it_adds_domain_and_path( $this->handleRequest($request, function () {}, function () {}); } - function it_adds_domain( + public function it_adds_domain( RequestInterface $request, UriInterface $host, UriInterface $uri @@ -77,7 +75,7 @@ function it_adds_domain( $this->handleRequest($request, function () {}, function () {}); } - function it_replaces_domain_and_adds_path( + public function it_replaces_domain_and_adds_path( RequestInterface $request, UriInterface $host, UriInterface $uri diff --git a/spec/Plugin/ContentLengthPluginSpec.php b/spec/Plugin/ContentLengthPluginSpec.php index 4ec2ba7..6624f6c 100644 --- a/spec/Plugin/ContentLengthPluginSpec.php +++ b/spec/Plugin/ContentLengthPluginSpec.php @@ -10,17 +10,17 @@ class ContentLengthPluginSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\Plugin\ContentLengthPlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_adds_content_length_header(RequestInterface $request, StreamInterface $stream) + public function it_adds_content_length_header(RequestInterface $request, StreamInterface $stream) { $request->hasHeader('Content-Length')->shouldBeCalled()->willReturn(false); $request->getBody()->shouldBeCalled()->willReturn($stream); @@ -30,9 +30,9 @@ function it_adds_content_length_header(RequestInterface $request, StreamInterfac $this->handleRequest($request, function () {}, function () {}); } - function it_streams_chunked_if_no_size(RequestInterface $request, StreamInterface $stream) + public function it_streams_chunked_if_no_size(RequestInterface $request, StreamInterface $stream) { - if(defined('HHVM_VERSION')) { + if (defined('HHVM_VERSION')) { throw new SkippingException('Skipping test on hhvm, as there is no chunk encoding on hhvm'); } diff --git a/spec/Plugin/ContentTypePluginSpec.php b/spec/Plugin/ContentTypePluginSpec.php index 3df7d87..d2a6ffa 100644 --- a/spec/Plugin/ContentTypePluginSpec.php +++ b/spec/Plugin/ContentTypePluginSpec.php @@ -2,25 +2,22 @@ namespace spec\Http\Client\Common\Plugin; -use PhpSpec\Exception\Example\SkippingException; use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\StreamInterface; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class ContentTypePluginSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\Plugin\ContentTypePlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_adds_json_content_type_header(RequestInterface $request) + public function it_adds_json_content_type_header(RequestInterface $request) { $request->hasHeader('Content-Type')->shouldBeCalled()->willReturn(false); $request->getBody()->shouldBeCalled()->willReturn(\GuzzleHttp\Psr7\stream_for(json_encode(['foo' => 'bar']))); @@ -29,7 +26,7 @@ function it_adds_json_content_type_header(RequestInterface $request) $this->handleRequest($request, function () {}, function () {}); } - function it_adds_xml_content_type_header(RequestInterface $request) + public function it_adds_xml_content_type_header(RequestInterface $request) { $request->hasHeader('Content-Type')->shouldBeCalled()->willReturn(false); $request->getBody()->shouldBeCalled()->willReturn(\GuzzleHttp\Psr7\stream_for('bar')); @@ -38,7 +35,7 @@ function it_adds_xml_content_type_header(RequestInterface $request) $this->handleRequest($request, function () {}, function () {}); } - function it_does_not_set_content_type_header(RequestInterface $request) + public function it_does_not_set_content_type_header(RequestInterface $request) { $request->hasHeader('Content-Type')->shouldBeCalled()->willReturn(false); $request->getBody()->shouldBeCalled()->willReturn(\GuzzleHttp\Psr7\stream_for('foo')); @@ -47,7 +44,7 @@ function it_does_not_set_content_type_header(RequestInterface $request) $this->handleRequest($request, function () {}, function () {}); } - function it_does_not_set_content_type_header_if_already_one(RequestInterface $request) + public function it_does_not_set_content_type_header_if_already_one(RequestInterface $request) { $request->hasHeader('Content-Type')->shouldBeCalled()->willReturn(true); $request->getBody()->shouldNotBeCalled()->willReturn(\GuzzleHttp\Psr7\stream_for('foo')); @@ -56,7 +53,7 @@ function it_does_not_set_content_type_header_if_already_one(RequestInterface $re $this->handleRequest($request, function () {}, function () {}); } - function it_does_not_set_content_type_header_if_size_0_or_unknown(RequestInterface $request) + public function it_does_not_set_content_type_header_if_size_0_or_unknown(RequestInterface $request) { $request->hasHeader('Content-Type')->shouldBeCalled()->willReturn(false); $request->getBody()->shouldBeCalled()->willReturn(\GuzzleHttp\Psr7\stream_for()); @@ -65,10 +62,10 @@ function it_does_not_set_content_type_header_if_size_0_or_unknown(RequestInterfa $this->handleRequest($request, function () {}, function () {}); } - function it_adds_xml_content_type_header_if_size_limit_is_not_reached_using_default_value(RequestInterface $request) + public function it_adds_xml_content_type_header_if_size_limit_is_not_reached_using_default_value(RequestInterface $request) { $this->beConstructedWith([ - 'skip_detection' => true + 'skip_detection' => true, ]); $request->hasHeader('Content-Type')->shouldBeCalled()->willReturn(false); @@ -78,11 +75,11 @@ function it_adds_xml_content_type_header_if_size_limit_is_not_reached_using_defa $this->handleRequest($request, function () {}, function () {}); } - function it_adds_xml_content_type_header_if_size_limit_is_not_reached(RequestInterface $request) + public function it_adds_xml_content_type_header_if_size_limit_is_not_reached(RequestInterface $request) { $this->beConstructedWith([ 'skip_detection' => true, - 'size_limit' => 32000000 + 'size_limit' => 32000000, ]); $request->hasHeader('Content-Type')->shouldBeCalled()->willReturn(false); @@ -92,11 +89,11 @@ function it_adds_xml_content_type_header_if_size_limit_is_not_reached(RequestInt $this->handleRequest($request, function () {}, function () {}); } - function it_does_not_set_content_type_header_if_size_limit_is_reached(RequestInterface $request) + public function it_does_not_set_content_type_header_if_size_limit_is_reached(RequestInterface $request) { $this->beConstructedWith([ 'skip_detection' => true, - 'size_limit' => 8 + 'size_limit' => 8, ]); $request->hasHeader('Content-Type')->shouldBeCalled()->willReturn(false); @@ -105,5 +102,4 @@ function it_does_not_set_content_type_header_if_size_limit_is_reached(RequestInt $this->handleRequest($request, function () {}, function () {}); } - } diff --git a/spec/Plugin/CookiePluginSpec.php b/spec/Plugin/CookiePluginSpec.php index 2bb47e7..1f021b1 100644 --- a/spec/Plugin/CookiePluginSpec.php +++ b/spec/Plugin/CookiePluginSpec.php @@ -16,24 +16,24 @@ class CookiePluginSpec extends ObjectBehavior { private $cookieJar; - function let() + public function let() { $this->cookieJar = new CookieJar(); $this->beConstructedWith($this->cookieJar); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\Plugin\CookiePlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_loads_cookie(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_loads_cookie(RequestInterface $request, UriInterface $uri, Promise $promise) { $cookie = new Cookie('name', 'value', 86400, 'test.com'); $this->cookieJar->addCookie($cookie); @@ -51,7 +51,7 @@ function it_loads_cookie(RequestInterface $request, UriInterface $uri, Promise $ }, function () {}); } - function it_combines_multiple_cookies_into_one_header(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_combines_multiple_cookies_into_one_header(RequestInterface $request, UriInterface $uri, Promise $promise) { $cookie = new Cookie('name', 'value', 86400, 'test.com'); $cookie2 = new Cookie('name2', 'value2', 86400, 'test.com'); @@ -72,7 +72,7 @@ function it_combines_multiple_cookies_into_one_header(RequestInterface $request, }, function () {}); } - function it_does_not_load_cookie_if_expired(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_does_not_load_cookie_if_expired(RequestInterface $request, UriInterface $uri, Promise $promise) { $cookie = new Cookie('name', 'value', null, 'test.com', false, false, null, (new \DateTime())->modify('-1 day')); $this->cookieJar->addCookie($cookie); @@ -86,7 +86,7 @@ function it_does_not_load_cookie_if_expired(RequestInterface $request, UriInterf }, function () {}); } - function it_does_not_load_cookie_if_domain_does_not_match(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_does_not_load_cookie_if_domain_does_not_match(RequestInterface $request, UriInterface $uri, Promise $promise) { $cookie = new Cookie('name', 'value', 86400, 'test2.com'); $this->cookieJar->addCookie($cookie); @@ -103,7 +103,7 @@ function it_does_not_load_cookie_if_domain_does_not_match(RequestInterface $requ }, function () {}); } - function it_does_not_load_cookie_on_hackish_domains(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_does_not_load_cookie_on_hackish_domains(RequestInterface $request, UriInterface $uri, Promise $promise) { $hackishDomains = [ 'hacktest.com', @@ -126,7 +126,7 @@ function it_does_not_load_cookie_on_hackish_domains(RequestInterface $request, U } } - function it_loads_cookie_on_subdomains(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_loads_cookie_on_subdomains(RequestInterface $request, UriInterface $uri, Promise $promise) { $cookie = new Cookie('name', 'value', 86400, 'test.com'); $this->cookieJar->addCookie($cookie); @@ -144,7 +144,7 @@ function it_loads_cookie_on_subdomains(RequestInterface $request, UriInterface $ }, function () {}); } - function it_does_not_load_cookie_if_path_does_not_match(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_does_not_load_cookie_if_path_does_not_match(RequestInterface $request, UriInterface $uri, Promise $promise) { $cookie = new Cookie('name', 'value', 86400, 'test.com', '/sub'); $this->cookieJar->addCookie($cookie); @@ -162,7 +162,7 @@ function it_does_not_load_cookie_if_path_does_not_match(RequestInterface $reques }, function () {}); } - function it_does_not_load_cookie_when_cookie_is_secure(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_does_not_load_cookie_when_cookie_is_secure(RequestInterface $request, UriInterface $uri, Promise $promise) { $cookie = new Cookie('name', 'value', 86400, 'test.com', null, true); $this->cookieJar->addCookie($cookie); @@ -181,7 +181,7 @@ function it_does_not_load_cookie_when_cookie_is_secure(RequestInterface $request }, function () {}); } - function it_loads_cookie_when_cookie_is_secure(RequestInterface $request, UriInterface $uri, Promise $promise) + public function it_loads_cookie_when_cookie_is_secure(RequestInterface $request, UriInterface $uri, Promise $promise) { $cookie = new Cookie('name', 'value', 86400, 'test.com', null, true); $this->cookieJar->addCookie($cookie); @@ -200,7 +200,7 @@ function it_loads_cookie_when_cookie_is_secure(RequestInterface $request, UriInt }, function () {}); } - function it_saves_cookie(RequestInterface $request, ResponseInterface $response, UriInterface $uri) + public function it_saves_cookie(RequestInterface $request, ResponseInterface $response, UriInterface $uri) { $next = function () use ($response) { return new HttpFulfilledPromise($response->getWrappedObject()); @@ -208,7 +208,7 @@ function it_saves_cookie(RequestInterface $request, ResponseInterface $response, $response->hasHeader('Set-Cookie')->willReturn(true); $response->getHeader('Set-Cookie')->willReturn([ - 'cookie=value; expires=Tuesday, 31-Mar-99 07:42:12 GMT; Max-Age=60; path=/; domain=test.com; secure; HttpOnly' + 'cookie=value; expires=Tuesday, 31-Mar-99 07:42:12 GMT; Max-Age=60; path=/; domain=test.com; secure; HttpOnly', ]); $request->getUri()->willReturn($uri); @@ -220,7 +220,7 @@ function it_saves_cookie(RequestInterface $request, ResponseInterface $response, $promise->wait()->shouldReturnAnInstanceOf('Psr\Http\Message\ResponseInterface'); } - function it_throws_exception_on_invalid_expires_date( + public function it_throws_exception_on_invalid_expires_date( RequestInterface $request, ResponseInterface $response, UriInterface $uri @@ -231,7 +231,7 @@ function it_throws_exception_on_invalid_expires_date( $response->hasHeader('Set-Cookie')->willReturn(true); $response->getHeader('Set-Cookie')->willReturn([ - 'cookie=value; expires=i-am-an-invalid-date;' + 'cookie=value; expires=i-am-an-invalid-date;', ]); $request->getUri()->willReturn($uri); diff --git a/spec/Plugin/DecoderPluginSpec.php b/spec/Plugin/DecoderPluginSpec.php index 7543027..4de938c 100644 --- a/spec/Plugin/DecoderPluginSpec.php +++ b/spec/Plugin/DecoderPluginSpec.php @@ -12,25 +12,25 @@ class DecoderPluginSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\Plugin\DecoderPlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_decodes(RequestInterface $request, ResponseInterface $response, StreamInterface $stream) + public function it_decodes(RequestInterface $request, ResponseInterface $response, StreamInterface $stream) { - if(defined('HHVM_VERSION')) { + if (defined('HHVM_VERSION')) { throw new SkippingException('Skipping test on hhvm, as there is no chunk encoding on hhvm'); } $request->withHeader('TE', ['gzip', 'deflate', 'chunked'])->shouldBeCalled()->willReturn($request); $request->withHeader('Accept-Encoding', ['gzip', 'deflate'])->shouldBeCalled()->willReturn($request); - $next = function () use($response) { + $next = function () use ($response) { return new HttpFulfilledPromise($response->getWrappedObject()); }; @@ -48,11 +48,11 @@ function it_decodes(RequestInterface $request, ResponseInterface $response, Stre $this->handleRequest($request, $next, function () {}); } - function it_decodes_gzip(RequestInterface $request, ResponseInterface $response, StreamInterface $stream) + public function it_decodes_gzip(RequestInterface $request, ResponseInterface $response, StreamInterface $stream) { $request->withHeader('TE', ['gzip', 'deflate', 'chunked'])->shouldBeCalled()->willReturn($request); $request->withHeader('Accept-Encoding', ['gzip', 'deflate'])->shouldBeCalled()->willReturn($request); - $next = function () use($response) { + $next = function () use ($response) { return new HttpFulfilledPromise($response->getWrappedObject()); }; @@ -70,11 +70,11 @@ function it_decodes_gzip(RequestInterface $request, ResponseInterface $response, $this->handleRequest($request, $next, function () {}); } - function it_decodes_deflate(RequestInterface $request, ResponseInterface $response, StreamInterface $stream) + public function it_decodes_deflate(RequestInterface $request, ResponseInterface $response, StreamInterface $stream) { $request->withHeader('TE', ['gzip', 'deflate', 'chunked'])->shouldBeCalled()->willReturn($request); $request->withHeader('Accept-Encoding', ['gzip', 'deflate'])->shouldBeCalled()->willReturn($request); - $next = function () use($response) { + $next = function () use ($response) { return new HttpFulfilledPromise($response->getWrappedObject()); }; @@ -92,13 +92,13 @@ function it_decodes_deflate(RequestInterface $request, ResponseInterface $respon $this->handleRequest($request, $next, function () {}); } - function it_does_not_decode_with_content_encoding(RequestInterface $request, ResponseInterface $response) + public function it_does_not_decode_with_content_encoding(RequestInterface $request, ResponseInterface $response) { $this->beConstructedWith(['use_content_encoding' => false]); $request->withHeader('TE', ['gzip', 'deflate', 'chunked'])->shouldBeCalled()->willReturn($request); $request->withHeader('Accept-Encoding', ['gzip', 'deflate'])->shouldNotBeCalled(); - $next = function () use($response) { + $next = function () use ($response) { return new HttpFulfilledPromise($response->getWrappedObject()); }; diff --git a/spec/Plugin/ErrorPluginSpec.php b/spec/Plugin/ErrorPluginSpec.php index 20fcc25..5a9e90a 100644 --- a/spec/Plugin/ErrorPluginSpec.php +++ b/spec/Plugin/ErrorPluginSpec.php @@ -10,22 +10,22 @@ class ErrorPluginSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->beAnInstanceOf('Http\Client\Common\Plugin\ErrorPlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_throw_client_error_exception_on_4xx_error(RequestInterface $request, ResponseInterface $response) + public function it_throw_client_error_exception_on_4xx_error(RequestInterface $request, ResponseInterface $response) { $response->getStatusCode()->willReturn('400'); $response->getReasonPhrase()->willReturn('Bad request'); - $next = function (RequestInterface $receivedRequest) use($request, $response) { + $next = function (RequestInterface $receivedRequest) use ($request, $response) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($response->getWrappedObject()); } @@ -36,14 +36,14 @@ function it_throw_client_error_exception_on_4xx_error(RequestInterface $request, $promise->shouldThrow('Http\Client\Common\Exception\ClientErrorException')->duringWait(); } - function it_does_not_throw_client_error_exception_on_4xx_error_if_only_server_exception(RequestInterface $request, ResponseInterface $response) + public function it_does_not_throw_client_error_exception_on_4xx_error_if_only_server_exception(RequestInterface $request, ResponseInterface $response) { $this->beConstructedWith(['only_server_exception' => true]); $response->getStatusCode()->willReturn('400'); $response->getReasonPhrase()->willReturn('Bad request'); - $next = function (RequestInterface $receivedRequest) use($request, $response) { + $next = function (RequestInterface $receivedRequest) use ($request, $response) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($response->getWrappedObject()); } @@ -52,12 +52,12 @@ function it_does_not_throw_client_error_exception_on_4xx_error_if_only_server_ex $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Promise\HttpFulfilledPromise'); } - function it_throw_server_error_exception_on_5xx_error(RequestInterface $request, ResponseInterface $response) + public function it_throw_server_error_exception_on_5xx_error(RequestInterface $request, ResponseInterface $response) { $response->getStatusCode()->willReturn('500'); $response->getReasonPhrase()->willReturn('Server error'); - $next = function (RequestInterface $receivedRequest) use($request, $response) { + $next = function (RequestInterface $receivedRequest) use ($request, $response) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($response->getWrappedObject()); } @@ -68,11 +68,11 @@ function it_throw_server_error_exception_on_5xx_error(RequestInterface $request, $promise->shouldThrow('Http\Client\Common\Exception\ServerErrorException')->duringWait(); } - function it_returns_response(RequestInterface $request, ResponseInterface $response) + public function it_returns_response(RequestInterface $request, ResponseInterface $response) { $response->getStatusCode()->willReturn('200'); - $next = function (RequestInterface $receivedRequest) use($request, $response) { + $next = function (RequestInterface $receivedRequest) use ($request, $response) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($response->getWrappedObject()); } diff --git a/spec/Plugin/HeaderAppendPluginSpec.php b/spec/Plugin/HeaderAppendPluginSpec.php index 24b8565..bb10de1 100644 --- a/spec/Plugin/HeaderAppendPluginSpec.php +++ b/spec/Plugin/HeaderAppendPluginSpec.php @@ -2,11 +2,8 @@ namespace spec\Http\Client\Common\Plugin; -use PhpSpec\Exception\Example\SkippingException; use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\StreamInterface; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class HeaderAppendPluginSpec extends ObjectBehavior { @@ -25,8 +22,8 @@ public function it_is_a_plugin() public function it_appends_the_header(RequestInterface $request) { $this->beConstructedWith([ - 'foo'=>'bar', - 'baz'=>'qux' + 'foo' => 'bar', + 'baz' => 'qux', ]); $request->withAddedHeader('foo', 'bar')->shouldBeCalled()->willReturn($request); diff --git a/spec/Plugin/HeaderDefaultsPluginSpec.php b/spec/Plugin/HeaderDefaultsPluginSpec.php index 341f1a5..cd407e3 100644 --- a/spec/Plugin/HeaderDefaultsPluginSpec.php +++ b/spec/Plugin/HeaderDefaultsPluginSpec.php @@ -2,11 +2,8 @@ namespace spec\Http\Client\Common\Plugin; -use PhpSpec\Exception\Example\SkippingException; use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\StreamInterface; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class HeaderDefaultsPluginSpec extends ObjectBehavior { @@ -26,7 +23,7 @@ public function it_sets_the_default_header(RequestInterface $request) { $this->beConstructedWith([ 'foo' => 'bar', - 'baz' => 'qux' + 'baz' => 'qux', ]); $request->hasHeader('foo')->shouldBeCalled()->willReturn(false); diff --git a/spec/Plugin/HeaderRemovePluginSpec.php b/spec/Plugin/HeaderRemovePluginSpec.php index 9ea2752..ec6b069 100644 --- a/spec/Plugin/HeaderRemovePluginSpec.php +++ b/spec/Plugin/HeaderRemovePluginSpec.php @@ -2,11 +2,8 @@ namespace spec\Http\Client\Common\Plugin; -use PhpSpec\Exception\Example\SkippingException; use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\StreamInterface; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class HeaderRemovePluginSpec extends ObjectBehavior { @@ -26,7 +23,7 @@ public function it_removes_the_header(RequestInterface $request) { $this->beConstructedWith([ 'foo', - 'baz' + 'baz', ]); $request->hasHeader('foo')->shouldBeCalled()->willReturn(false); diff --git a/spec/Plugin/HeaderSetPluginSpec.php b/spec/Plugin/HeaderSetPluginSpec.php index f4a340c..4e4efd0 100644 --- a/spec/Plugin/HeaderSetPluginSpec.php +++ b/spec/Plugin/HeaderSetPluginSpec.php @@ -2,11 +2,8 @@ namespace spec\Http\Client\Common\Plugin; -use PhpSpec\Exception\Example\SkippingException; use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\StreamInterface; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class HeaderSetPluginSpec extends ObjectBehavior { @@ -25,8 +22,8 @@ public function it_is_a_plugin() public function it_set_the_header(RequestInterface $request) { $this->beConstructedWith([ - 'foo'=>'bar', - 'baz'=>'qux' + 'foo' => 'bar', + 'baz' => 'qux', ]); $request->withHeader('foo', 'bar')->shouldBeCalled()->willReturn($request); diff --git a/spec/Plugin/HistoryPluginSpec.php b/spec/Plugin/HistoryPluginSpec.php index 24e7f51..77682a7 100644 --- a/spec/Plugin/HistoryPluginSpec.php +++ b/spec/Plugin/HistoryPluginSpec.php @@ -13,24 +13,24 @@ class HistoryPluginSpec extends ObjectBehavior { - function let(Journal $journal) + public function let(Journal $journal) { $this->beConstructedWith($journal); } - function it_is_initializable() + public function it_is_initializable() { $this->beAnInstanceOf('Http\Client\Common\Plugin\JournalPlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_records_success(Journal $journal, RequestInterface $request, ResponseInterface $response) + public function it_records_success(Journal $journal, RequestInterface $request, ResponseInterface $response) { - $next = function (RequestInterface $receivedRequest) use($request, $response) { + $next = function (RequestInterface $receivedRequest) use ($request, $response) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($response->getWrappedObject()); } @@ -41,10 +41,10 @@ function it_records_success(Journal $journal, RequestInterface $request, Respons $this->handleRequest($request, $next, function () {}); } - function it_records_failure(Journal $journal, RequestInterface $request) + public function it_records_failure(Journal $journal, RequestInterface $request) { $exception = new TransferException(); - $next = function (RequestInterface $receivedRequest) use($request, $exception) { + $next = function (RequestInterface $receivedRequest) use ($request, $exception) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpRejectedPromise($exception); } diff --git a/spec/Plugin/QueryDefaultsPluginSpec.php b/spec/Plugin/QueryDefaultsPluginSpec.php index 82d9125..aa50f81 100644 --- a/spec/Plugin/QueryDefaultsPluginSpec.php +++ b/spec/Plugin/QueryDefaultsPluginSpec.php @@ -2,7 +2,6 @@ namespace spec\Http\Client\Common\Plugin; -use Http\Client\Common\Plugin; use Psr\Http\Message\RequestInterface; use PhpSpec\ObjectBehavior; use Psr\Http\Message\UriInterface; diff --git a/spec/Plugin/RedirectPluginSpec.php b/spec/Plugin/RedirectPluginSpec.php index 97197e1..283bfb5 100644 --- a/spec/Plugin/RedirectPluginSpec.php +++ b/spec/Plugin/RedirectPluginSpec.php @@ -13,17 +13,17 @@ class RedirectPluginSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\Plugin\RedirectPlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_redirects_on_302( + public function it_redirects_on_302( UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, @@ -48,14 +48,13 @@ function it_redirects_on_302( $modifiedRequest->getUri()->willReturn($uriRedirect); $modifiedRequest->getMethod()->willReturn('GET'); - - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } }; - $first = function (RequestInterface $receivedRequest) use($modifiedRequest, $promise) { + $first = function (RequestInterface $receivedRequest) use ($modifiedRequest, $promise) { if (Argument::is($modifiedRequest->getWrappedObject())->scoreArgument($receivedRequest)) { return $promise->getWrappedObject(); } @@ -69,7 +68,7 @@ function it_redirects_on_302( $finalPromise->wait()->shouldReturn($finalResponse); } - function it_use_storage_on_301(UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, RequestInterface $modifiedRequest) + public function it_use_storage_on_301(UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, RequestInterface $modifiedRequest) { $this->beAnInstanceOf('spec\Http\Client\Common\Plugin\RedirectPluginStub'); $this->beConstructedWith($uriRedirect, '/original', '301'); @@ -90,7 +89,7 @@ function it_use_storage_on_301(UriInterface $uri, UriInterface $uriRedirect, Req $this->handleRequest($request, $next, function () {}); } - function it_stores_a_301( + public function it_stores_a_301( UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, @@ -99,7 +98,6 @@ function it_stores_a_301( ResponseInterface $finalResponse, Promise $promise ) { - $this->beAnInstanceOf('spec\Http\Client\Common\Plugin\RedirectPluginStub'); $this->beConstructedWith($uriRedirect, '', '301'); @@ -121,13 +119,13 @@ function it_stores_a_301( $uriRedirect->__toString()->willReturn('/redirect'); - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } }; - $first = function (RequestInterface $receivedRequest) use($modifiedRequest, $promise) { + $first = function (RequestInterface $receivedRequest) use ($modifiedRequest, $promise) { if (Argument::is($modifiedRequest->getWrappedObject())->scoreArgument($receivedRequest)) { return $promise->getWrappedObject(); } @@ -140,7 +138,7 @@ function it_stores_a_301( $this->hasStorage('/301-url')->shouldReturn(true); } - function it_replace_full_url( + public function it_replace_full_url( UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, @@ -171,13 +169,13 @@ function it_replace_full_url( $uriRedirect->__toString()->willReturn('/redirect'); - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } }; - $first = function (RequestInterface $receivedRequest) use($modifiedRequest, $promise) { + $first = function (RequestInterface $receivedRequest) use ($modifiedRequest, $promise) { if (Argument::is($modifiedRequest->getWrappedObject())->scoreArgument($receivedRequest)) { return $promise->getWrappedObject(); } @@ -189,9 +187,9 @@ function it_replace_full_url( $this->handleRequest($request, $next, $first); } - function it_throws_http_exception_on_no_location(RequestInterface $request, UriInterface $uri, ResponseInterface $responseRedirect) + public function it_throws_http_exception_on_no_location(RequestInterface $request, UriInterface $uri, ResponseInterface $responseRedirect) { - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } @@ -207,9 +205,9 @@ function it_throws_http_exception_on_no_location(RequestInterface $request, UriI $promise->shouldThrow('Http\Client\Exception\HttpException')->duringWait(); } - function it_throws_http_exception_on_invalid_location(RequestInterface $request, UriInterface $uri, ResponseInterface $responseRedirect) + public function it_throws_http_exception_on_invalid_location(RequestInterface $request, UriInterface $uri, ResponseInterface $responseRedirect) { - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } @@ -227,9 +225,9 @@ function it_throws_http_exception_on_invalid_location(RequestInterface $request, $promise->shouldThrow('Http\Client\Exception\HttpException')->duringWait(); } - function it_throw_multi_redirect_exception_on_300(RequestInterface $request, ResponseInterface $responseRedirect) + public function it_throw_multi_redirect_exception_on_300(RequestInterface $request, ResponseInterface $responseRedirect) { - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } @@ -243,9 +241,9 @@ function it_throw_multi_redirect_exception_on_300(RequestInterface $request, Res $promise->shouldThrow('Http\Client\Common\Exception\MultipleRedirectionException')->duringWait(); } - function it_throw_multi_redirect_exception_on_300_if_no_location(RequestInterface $request, ResponseInterface $responseRedirect) + public function it_throw_multi_redirect_exception_on_300_if_no_location(RequestInterface $request, ResponseInterface $responseRedirect) { - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } @@ -259,7 +257,7 @@ function it_throw_multi_redirect_exception_on_300_if_no_location(RequestInterfac $promise->shouldThrow('Http\Client\Common\Exception\MultipleRedirectionException')->duringWait(); } - function it_switch_method_for_302( + public function it_switch_method_for_302( UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, @@ -288,13 +286,13 @@ function it_switch_method_for_302( $modifiedRequest->getMethod()->willReturn('POST'); $modifiedRequest->withMethod('GET')->willReturn($modifiedRequest); - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } }; - $first = function (RequestInterface $receivedRequest) use($modifiedRequest, $promise) { + $first = function (RequestInterface $receivedRequest) use ($modifiedRequest, $promise) { if (Argument::is($modifiedRequest->getWrappedObject())->scoreArgument($receivedRequest)) { return $promise->getWrappedObject(); } @@ -306,7 +304,7 @@ function it_switch_method_for_302( $this->handleRequest($request, $next, $first); } - function it_clears_headers( + public function it_clears_headers( UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, @@ -338,13 +336,13 @@ function it_clears_headers( $modifiedRequest->withoutHeader('Cookie')->willReturn($modifiedRequest); $modifiedRequest->getUri()->willReturn($uriRedirect); - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } }; - $first = function (RequestInterface $receivedRequest) use($modifiedRequest, $promise) { + $first = function (RequestInterface $receivedRequest) use ($modifiedRequest, $promise) { if (Argument::is($modifiedRequest->getWrappedObject())->scoreArgument($receivedRequest)) { return $promise->getWrappedObject(); } @@ -356,12 +354,12 @@ function it_clears_headers( $this->handleRequest($request, $next, $first); } - function it_throws_circular_redirection_exception(UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, ResponseInterface $responseRedirect, RequestInterface $modifiedRequest) + public function it_throws_circular_redirection_exception(UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, ResponseInterface $responseRedirect, RequestInterface $modifiedRequest) { - $first = function() {}; + $first = function () {}; $this->beAnInstanceOf('spec\Http\Client\Common\Plugin\RedirectPluginStubCircular'); - $this->beConstructedWith(spl_object_hash((object)$first)); + $this->beConstructedWith(spl_object_hash((object) $first)); $request->getUri()->willReturn($uri); $uri->__toString()->willReturn('/original'); @@ -379,7 +377,7 @@ function it_throws_circular_redirection_exception(UriInterface $uri, UriInterfac $uriRedirect->__toString()->willReturn('/redirect'); $modifiedRequest->getMethod()->willReturn('GET'); - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } @@ -390,7 +388,7 @@ function it_throws_circular_redirection_exception(UriInterface $uri, UriInterfac $promise->shouldThrow('Http\Client\Common\Exception\CircularRedirectionException')->duringWait(); } - function it_redirects_http_to_https( + public function it_redirects_http_to_https( UriInterface $uri, UriInterface $uriRedirect, RequestInterface $request, @@ -417,13 +415,13 @@ function it_redirects_http_to_https( $modifiedRequest->getUri()->willReturn($uriRedirect); $modifiedRequest->getMethod()->willReturn('GET'); - $next = function (RequestInterface $receivedRequest) use($request, $responseRedirect) { + $next = function (RequestInterface $receivedRequest) use ($request, $responseRedirect) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($responseRedirect->getWrappedObject()); } }; - $first = function (RequestInterface $receivedRequest) use($modifiedRequest, $promise) { + $first = function (RequestInterface $receivedRequest) use ($modifiedRequest, $promise) { if (Argument::is($modifiedRequest->getWrappedObject())->scoreArgument($receivedRequest)) { return $promise->getWrappedObject(); } @@ -446,7 +444,7 @@ public function __construct(UriInterface $uri, $storedUrl, $status, array $confi $this->redirectStorage[$storedUrl] = [ 'uri' => $uri, - 'status' => $status + 'status' => $status, ]; } @@ -462,8 +460,8 @@ public function __construct($chainHash) { $this->circularDetection = [ $chainHash => [ - '/redirect' - ] + '/redirect', + ], ]; } } diff --git a/spec/Plugin/RequestMatcherPluginSpec.php b/spec/Plugin/RequestMatcherPluginSpec.php index 4fe9aea..bd4e7e4 100644 --- a/spec/Plugin/RequestMatcherPluginSpec.php +++ b/spec/Plugin/RequestMatcherPluginSpec.php @@ -11,22 +11,22 @@ class RequestMatcherPluginSpec extends ObjectBehavior { - function let(RequestMatcher $requestMatcher, Plugin $plugin) + public function let(RequestMatcher $requestMatcher, Plugin $plugin) { $this->beConstructedWith($requestMatcher, $plugin); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\Plugin\RequestMatcherPlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_matches_a_request_and_delegates_to_plugin( + public function it_matches_a_request_and_delegates_to_plugin( RequestInterface $request, RequestMatcher $requestMatcher, Plugin $plugin @@ -37,7 +37,7 @@ function it_matches_a_request_and_delegates_to_plugin( $this->handleRequest($request, function () {}, function () {}); } - function it_does_not_match_a_request( + public function it_does_not_match_a_request( RequestInterface $request, RequestMatcher $requestMatcher, Plugin $plugin, @@ -46,7 +46,7 @@ function it_does_not_match_a_request( $requestMatcher->matches($request)->willReturn(false); $plugin->handleRequest($request, Argument::type('callable'), Argument::type('callable'))->shouldNotBeCalled(); - $next = function (RequestInterface $request) use($promise) { + $next = function (RequestInterface $request) use ($promise) { return $promise->getWrappedObject(); }; diff --git a/spec/Plugin/RetryPluginSpec.php b/spec/Plugin/RetryPluginSpec.php index 37800ae..c439cad 100644 --- a/spec/Plugin/RetryPluginSpec.php +++ b/spec/Plugin/RetryPluginSpec.php @@ -12,19 +12,19 @@ class RetryPluginSpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\Plugin\RetryPlugin'); } - function it_is_a_plugin() + public function it_is_a_plugin() { $this->shouldImplement('Http\Client\Common\Plugin'); } - function it_returns_response(RequestInterface $request, ResponseInterface $response) + public function it_returns_response(RequestInterface $request, ResponseInterface $response) { - $next = function (RequestInterface $receivedRequest) use($request, $response) { + $next = function (RequestInterface $receivedRequest) use ($request, $response) { if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { return new HttpFulfilledPromise($response->getWrappedObject()); } @@ -33,20 +33,20 @@ function it_returns_response(RequestInterface $request, ResponseInterface $respo $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Promise\HttpFulfilledPromise'); } - function it_throws_exception_on_multiple_exceptions(RequestInterface $request) + public function it_throws_exception_on_multiple_exceptions(RequestInterface $request) { $exception1 = new Exception\NetworkException('Exception 1', $request->getWrappedObject()); $exception2 = new Exception\NetworkException('Exception 2', $request->getWrappedObject()); $count = 0; - $next = function (RequestInterface $receivedRequest) use($request, $exception1, $exception2, &$count) { - $count++; + $next = function (RequestInterface $receivedRequest) use ($request, $exception1, $exception2, &$count) { + ++$count; if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { - if ($count == 1) { + if (1 == $count) { return new HttpRejectedPromise($exception1); } - if ($count == 2) { + if (2 == $count) { return new HttpRejectedPromise($exception2); } } @@ -57,19 +57,19 @@ function it_throws_exception_on_multiple_exceptions(RequestInterface $request) $promise->shouldThrow($exception2)->duringWait(); } - function it_returns_response_on_second_try(RequestInterface $request, ResponseInterface $response) + public function it_returns_response_on_second_try(RequestInterface $request, ResponseInterface $response) { $exception = new Exception\NetworkException('Exception 1', $request->getWrappedObject()); $count = 0; - $next = function (RequestInterface $receivedRequest) use($request, $exception, $response, &$count) { - $count++; + $next = function (RequestInterface $receivedRequest) use ($request, $exception, $response, &$count) { + ++$count; if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { - if ($count == 1) { + if (1 == $count) { return new HttpRejectedPromise($exception); } - if ($count == 2) { + if (2 == $count) { return new HttpFulfilledPromise($response->getWrappedObject()); } } @@ -80,19 +80,19 @@ function it_returns_response_on_second_try(RequestInterface $request, ResponseIn $promise->wait()->shouldReturn($response); } - function it_does_not_keep_history_of_old_failure(RequestInterface $request, ResponseInterface $response) + public function it_does_not_keep_history_of_old_failure(RequestInterface $request, ResponseInterface $response) { $exception = new Exception\NetworkException('Exception 1', $request->getWrappedObject()); $count = 0; - $next = function (RequestInterface $receivedRequest) use($request, $exception, $response, &$count) { - $count++; + $next = function (RequestInterface $receivedRequest) use ($request, $exception, $response, &$count) { + ++$count; if (Argument::is($request->getWrappedObject())->scoreArgument($receivedRequest)) { - if ($count % 2 == 1) { + if (1 == $count % 2) { return new HttpRejectedPromise($exception); } - if ($count % 2 == 0) { + if (0 == $count % 2) { return new HttpFulfilledPromise($response->getWrappedObject()); } } @@ -102,7 +102,7 @@ function it_does_not_keep_history_of_old_failure(RequestInterface $request, Resp $this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Promise\HttpFulfilledPromise'); } - function it_has_an_exponential_default_delay(RequestInterface $request, Exception\HttpException $exception) + public function it_has_an_exponential_default_delay(RequestInterface $request, Exception\HttpException $exception) { $this->defaultDelay($request, $exception, 0)->shouldBe(500000); $this->defaultDelay($request, $exception, 1)->shouldBe(1000000); diff --git a/spec/PluginClientFactorySpec.php b/spec/PluginClientFactorySpec.php index 1f8d9e8..fe7e076 100644 --- a/spec/PluginClientFactorySpec.php +++ b/spec/PluginClientFactorySpec.php @@ -7,19 +7,19 @@ class PluginClientFactorySpec extends ObjectBehavior { - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\PluginClientFactory'); } - function it_returns_a_plugin_client(HttpClient $httpClient) + public function it_returns_a_plugin_client(HttpClient $httpClient) { $client = $this->createClient($httpClient); $client->shouldHaveType('Http\Client\Common\PluginClient'); } - function it_does_not_construct_plugin_client_with_client_name_option(HttpClient $httpClient) + public function it_does_not_construct_plugin_client_with_client_name_option(HttpClient $httpClient) { $this->createClient($httpClient, [], ['client_name' => 'Default']); } diff --git a/spec/PluginClientSpec.php b/spec/PluginClientSpec.php index 88406ae..50df636 100644 --- a/spec/PluginClientSpec.php +++ b/spec/PluginClientSpec.php @@ -4,7 +4,6 @@ use Http\Client\HttpAsyncClient; use Http\Client\HttpClient; -use Http\Client\Common\FlexibleHttpClient; use Http\Client\Common\Plugin; use Http\Promise\Promise; use Prophecy\Argument; @@ -14,34 +13,34 @@ class PluginClientSpec extends ObjectBehavior { - function let(HttpClient $httpClient) + public function let(HttpClient $httpClient) { $this->beConstructedWith($httpClient); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Http\Client\Common\PluginClient'); } - function it_is_an_http_client() + public function it_is_an_http_client() { $this->shouldImplement('Http\Client\HttpClient'); } - function it_is_an_http_async_client() + public function it_is_an_http_async_client() { $this->shouldImplement('Http\Client\HttpAsyncClient'); } - function it_sends_request_with_underlying_client(HttpClient $httpClient, RequestInterface $request, ResponseInterface $response) + public function it_sends_request_with_underlying_client(HttpClient $httpClient, RequestInterface $request, ResponseInterface $response) { $httpClient->sendRequest($request)->willReturn($response); $this->sendRequest($request)->shouldReturn($response); } - function it_sends_async_request_with_underlying_client(HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise) + public function it_sends_async_request_with_underlying_client(HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise) { $httpAsyncClient->sendAsyncRequest($request)->willReturn($promise); @@ -49,7 +48,7 @@ function it_sends_async_request_with_underlying_client(HttpAsyncClient $httpAsyn $this->sendAsyncRequest($request)->shouldReturn($promise); } - function it_sends_async_request_if_no_send_request(HttpAsyncClient $httpAsyncClient, RequestInterface $request, ResponseInterface $response, Promise $promise) + public function it_sends_async_request_if_no_send_request(HttpAsyncClient $httpAsyncClient, RequestInterface $request, ResponseInterface $response, Promise $promise) { $this->beConstructedWith($httpAsyncClient); $httpAsyncClient->sendAsyncRequest($request)->willReturn($promise); @@ -58,7 +57,7 @@ function it_sends_async_request_if_no_send_request(HttpAsyncClient $httpAsyncCli $this->sendRequest($request)->shouldReturn($response); } - function it_prefers_send_request($client, RequestInterface $request, ResponseInterface $response) + public function it_prefers_send_request($client, RequestInterface $request, ResponseInterface $response) { $client->implement('Http\Client\HttpClient'); $client->implement('Http\Client\HttpAsyncClient'); @@ -70,7 +69,7 @@ function it_prefers_send_request($client, RequestInterface $request, ResponseInt $this->sendRequest($request)->shouldReturn($response); } - function it_throws_loop_exception(HttpClient $httpClient, RequestInterface $request, Plugin $plugin) + public function it_throws_loop_exception(HttpClient $httpClient, RequestInterface $request, Plugin $plugin) { $plugin ->handleRequest( diff --git a/src/HttpClientRouter.php b/src/HttpClientRouter.php index fa32c56..ac7699c 100644 --- a/src/HttpClientRouter.php +++ b/src/HttpClientRouter.php @@ -62,7 +62,7 @@ public function addClient($client, RequestMatcher $requestMatcher) * * @return HttpClient|HttpAsyncClient */ - protected function chooseHttpClient(RequestInterface $request) + private function chooseHttpClient(RequestInterface $request) { foreach ($this->clients as $client) { if ($client['matcher']->matches($request)) { diff --git a/src/Plugin.php b/src/Plugin.php index 89a2a62..6248fc7 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -26,7 +26,7 @@ interface Plugin * @param callable $next Next middleware in the chain, the request is passed as the first argument * @param callable $first First middleware in the chain, used to to restart a request * - * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient). + * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient) */ public function handleRequest(RequestInterface $request, callable $next, callable $first); } diff --git a/src/Plugin/BaseUriPlugin.php b/src/Plugin/BaseUriPlugin.php index 2c2a775..669c308 100644 --- a/src/Plugin/BaseUriPlugin.php +++ b/src/Plugin/BaseUriPlugin.php @@ -24,7 +24,7 @@ final class BaseUriPlugin implements Plugin private $addPathPlugin = null; /** - * @param UriInterface $uri Has to contain a host name and cans have a path. + * @param UriInterface $uri Has to contain a host name and cans have a path * @param array $hostConfig Config for AddHostPlugin. @see AddHostPlugin::configureOptions */ public function __construct(UriInterface $uri, array $hostConfig = []) diff --git a/src/Plugin/ContentTypePlugin.php b/src/Plugin/ContentTypePlugin.php index 8ef1d62..d0bfa8d 100644 --- a/src/Plugin/ContentTypePlugin.php +++ b/src/Plugin/ContentTypePlugin.php @@ -22,19 +22,19 @@ final class ContentTypePlugin implements Plugin * true skip the content type detection * false detect the content type (default value) */ - protected $skipDetection; + private $skipDetection; /** * Determine the size stream limit for which the detection as to be skipped (default to 16Mb). * * @var int */ - protected $sizeLimit; + private $sizeLimit; /** * @param array $config { * - * @var bool $skip_detection True skip detection if stream size is bigger than $size_limit. + * @var bool $skip_detection true skip detection if stream size is bigger than $size_limit * @var int $size_limit size stream limit for which the detection as to be skipped. * } */ diff --git a/src/Plugin/ErrorPlugin.php b/src/Plugin/ErrorPlugin.php index bcc1c67..4fd7201 100644 --- a/src/Plugin/ErrorPlugin.php +++ b/src/Plugin/ErrorPlugin.php @@ -66,7 +66,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl * * @return ResponseInterface If status code is not in 4xx or 5xx return response */ - protected function transformResponseToException(RequestInterface $request, ResponseInterface $response) + private function transformResponseToException(RequestInterface $request, ResponseInterface $response) { if (!$this->onlyServerException && $response->getStatusCode() >= 400 && $response->getStatusCode() < 500) { throw new ClientErrorException($response->getReasonPhrase(), $request, $response); diff --git a/src/Plugin/RetryPlugin.php b/src/Plugin/RetryPlugin.php index 8446246..0a5b4e7 100644 --- a/src/Plugin/RetryPlugin.php +++ b/src/Plugin/RetryPlugin.php @@ -44,8 +44,8 @@ final class RetryPlugin implements Plugin /** * @param array $config { * - * @var int $retries Number of retries to attempt if an exception occurs before letting the exception bubble up. - * @var callable $decider A callback that gets a request and an exception to decide after a failure whether the request should be retried. + * @var int $retries Number of retries to attempt if an exception occurs before letting the exception bubble up + * @var callable $decider A callback that gets a request and an exception to decide after a failure whether the request should be retried * @var callable $delay A callback that gets a request, an exception and the number of retries and returns how many microseconds we should wait before trying again. * } */ From f966926c4cb3d49657903e73f02b09a54e80d68b Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 16:40:45 +0100 Subject: [PATCH 3/7] Add rules to cleanup PHPDocs --- .php_cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.php_cs b/.php_cs index 7da3701..7039b1e 100644 --- a/.php_cs +++ b/.php_cs @@ -7,6 +7,8 @@ $config->setRules([ 'array_syntax' => [ 'syntax' => 'short', ], + 'no_empty_phpdoc' => true, + 'no_superfluous_phpdoc_tags' => true, ]); $finder = PhpCsFixer\Finder::create(); From 720a0cde7d1a608a70513c784cbc0728e8145a92 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 16:43:55 +0100 Subject: [PATCH 4/7] Remove unuseful PHPDoc automatically --- src/BatchClient.php | 3 --- src/BatchResult.php | 14 -------------- src/EmulatedHttpAsyncClient.php | 3 --- src/EmulatedHttpClient.php | 3 --- src/Exception/BatchException.php | 3 --- src/HttpClientRouter.php | 3 --- src/HttpMethodsClient.php | 11 +---------- src/Plugin.php | 5 ++--- src/Plugin/AddHostPlugin.php | 6 +----- src/Plugin/AddPathPlugin.php | 3 --- src/Plugin/AuthenticationPlugin.php | 3 --- src/Plugin/CookiePlugin.php | 4 ---- src/Plugin/DecoderPlugin.php | 3 +-- src/Plugin/HistoryPlugin.php | 3 --- src/Plugin/RequestMatcherPlugin.php | 4 ---- src/Plugin/RetryPlugin.php | 4 +--- src/PluginClient.php | 2 -- src/PluginClientFactory.php | 2 -- 18 files changed, 6 insertions(+), 73 deletions(-) diff --git a/src/BatchClient.php b/src/BatchClient.php index 2a39904..7ddba4e 100644 --- a/src/BatchClient.php +++ b/src/BatchClient.php @@ -22,9 +22,6 @@ class BatchClient implements HttpClient */ private $client; - /** - * @param HttpClient $client - */ public function __construct(HttpClient $client) { $this->client = $client; diff --git a/src/BatchResult.php b/src/BatchResult.php index 710611d..3f8a2f0 100644 --- a/src/BatchResult.php +++ b/src/BatchResult.php @@ -58,8 +58,6 @@ public function getResponses() /** * Checks if there is a successful response for a request. * - * @param RequestInterface $request - * * @return bool */ public function isSuccessful(RequestInterface $request) @@ -70,8 +68,6 @@ public function isSuccessful(RequestInterface $request) /** * Returns the response for a successful request. * - * @param RequestInterface $request - * * @return ResponseInterface * * @throws \UnexpectedValueException If request was not part of the batch or failed @@ -88,9 +84,6 @@ public function getResponseFor(RequestInterface $request) /** * Adds a response in an immutable way. * - * @param RequestInterface $request - * @param ResponseInterface $response - * * @return BatchResult the new BatchResult with this request-response pair added to it */ public function addResponse(RequestInterface $request, ResponseInterface $response) @@ -130,8 +123,6 @@ public function getExceptions() /** * Checks if there is an exception for a request, meaning the request failed. * - * @param RequestInterface $request - * * @return bool */ public function isFailed(RequestInterface $request) @@ -142,8 +133,6 @@ public function isFailed(RequestInterface $request) /** * Returns the exception for a failed request. * - * @param RequestInterface $request - * * @return Exception * * @throws \UnexpectedValueException If request was not part of the batch or was successful @@ -160,9 +149,6 @@ public function getExceptionFor(RequestInterface $request) /** * Adds an exception in an immutable way. * - * @param RequestInterface $request - * @param Exception $exception - * * @return BatchResult the new BatchResult with this request-exception pair added to it */ public function addException(RequestInterface $request, Exception $exception) diff --git a/src/EmulatedHttpAsyncClient.php b/src/EmulatedHttpAsyncClient.php index 1b16316..64acd59 100644 --- a/src/EmulatedHttpAsyncClient.php +++ b/src/EmulatedHttpAsyncClient.php @@ -17,9 +17,6 @@ class EmulatedHttpAsyncClient implements HttpClient, HttpAsyncClient use HttpAsyncClientEmulator; use HttpClientDecorator; - /** - * @param HttpClient $httpClient - */ public function __construct(HttpClient $httpClient) { $this->httpClient = $httpClient; diff --git a/src/EmulatedHttpClient.php b/src/EmulatedHttpClient.php index 01046c8..3635e9f 100644 --- a/src/EmulatedHttpClient.php +++ b/src/EmulatedHttpClient.php @@ -17,9 +17,6 @@ class EmulatedHttpClient implements HttpClient, HttpAsyncClient use HttpAsyncClientDecorator; use HttpClientEmulator; - /** - * @param HttpAsyncClient $httpAsyncClient - */ public function __construct(HttpAsyncClient $httpAsyncClient) { $this->httpAsyncClient = $httpAsyncClient; diff --git a/src/Exception/BatchException.php b/src/Exception/BatchException.php index 66a9271..8620f9d 100644 --- a/src/Exception/BatchException.php +++ b/src/Exception/BatchException.php @@ -19,9 +19,6 @@ final class BatchException extends TransferException */ private $result; - /** - * @param BatchResult $result - */ public function __construct(BatchResult $result) { $this->result = $result; diff --git a/src/HttpClientRouter.php b/src/HttpClientRouter.php index ac7699c..00ca15f 100644 --- a/src/HttpClientRouter.php +++ b/src/HttpClientRouter.php @@ -45,7 +45,6 @@ public function sendAsyncRequest(RequestInterface $request) * Add a client to the router. * * @param HttpClient|HttpAsyncClient $client - * @param RequestMatcher $requestMatcher */ public function addClient($client, RequestMatcher $requestMatcher) { @@ -58,8 +57,6 @@ public function addClient($client, RequestMatcher $requestMatcher) /** * Choose an HTTP client given a specific request. * - * @param RequestInterface $request - * * @return HttpClient|HttpAsyncClient */ private function chooseHttpClient(RequestInterface $request) diff --git a/src/HttpMethodsClient.php b/src/HttpMethodsClient.php index 0ec1e14..a1ef2c8 100644 --- a/src/HttpMethodsClient.php +++ b/src/HttpMethodsClient.php @@ -50,7 +50,6 @@ public function __construct(HttpClient $httpClient, RequestFactory $requestFacto * Sends a GET request. * * @param string|UriInterface $uri - * @param array $headers * * @throws Exception * @@ -65,7 +64,6 @@ public function get($uri, array $headers = []) * Sends an HEAD request. * * @param string|UriInterface $uri - * @param array $headers * * @throws Exception * @@ -80,7 +78,6 @@ public function head($uri, array $headers = []) * Sends a TRACE request. * * @param string|UriInterface $uri - * @param array $headers * * @throws Exception * @@ -95,7 +92,6 @@ public function trace($uri, array $headers = []) * Sends a POST request. * * @param string|UriInterface $uri - * @param array $headers * @param string|StreamInterface|null $body * * @throws Exception @@ -111,7 +107,6 @@ public function post($uri, array $headers = [], $body = null) * Sends a PUT request. * * @param string|UriInterface $uri - * @param array $headers * @param string|StreamInterface|null $body * * @throws Exception @@ -127,7 +122,6 @@ public function put($uri, array $headers = [], $body = null) * Sends a PATCH request. * * @param string|UriInterface $uri - * @param array $headers * @param string|StreamInterface|null $body * * @throws Exception @@ -143,7 +137,6 @@ public function patch($uri, array $headers = [], $body = null) * Sends a DELETE request. * * @param string|UriInterface $uri - * @param array $headers * @param string|StreamInterface|null $body * * @throws Exception @@ -159,7 +152,6 @@ public function delete($uri, array $headers = [], $body = null) * Sends an OPTIONS request. * * @param string|UriInterface $uri - * @param array $headers * @param string|StreamInterface|null $body * * @throws Exception @@ -174,9 +166,8 @@ public function options($uri, array $headers = [], $body = null) /** * Sends a request with any HTTP method. * - * @param string $method HTTP method to use + * @param string $method HTTP method to use * @param string|UriInterface $uri - * @param array $headers * @param string|StreamInterface|null $body * * @throws Exception diff --git a/src/Plugin.php b/src/Plugin.php index 6248fc7..bfb2668 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -22,9 +22,8 @@ interface Plugin * * @see http://docs.php-http.org/en/latest/plugins/build-your-own.html * - * @param RequestInterface $request - * @param callable $next Next middleware in the chain, the request is passed as the first argument - * @param callable $first First middleware in the chain, used to to restart a request + * @param callable $next Next middleware in the chain, the request is passed as the first argument + * @param callable $first First middleware in the chain, used to to restart a request * * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient) */ diff --git a/src/Plugin/AddHostPlugin.php b/src/Plugin/AddHostPlugin.php index 29ab8ae..050feb1 100644 --- a/src/Plugin/AddHostPlugin.php +++ b/src/Plugin/AddHostPlugin.php @@ -25,8 +25,7 @@ final class AddHostPlugin implements Plugin private $replace; /** - * @param UriInterface $host - * @param array $config { + * @param array $config { * * @var bool $replace True will replace all hosts, false will only add host when none is specified. * } @@ -64,9 +63,6 @@ public function handleRequest(RequestInterface $request, callable $next, callabl return $next($request); } - /** - * @param OptionsResolver $resolver - */ private function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ diff --git a/src/Plugin/AddPathPlugin.php b/src/Plugin/AddPathPlugin.php index 93ded1c..1675088 100644 --- a/src/Plugin/AddPathPlugin.php +++ b/src/Plugin/AddPathPlugin.php @@ -25,9 +25,6 @@ final class AddPathPlugin implements Plugin */ private $alteredRequests = []; - /** - * @param UriInterface $uri - */ public function __construct(UriInterface $uri) { if ('' === $uri->getPath()) { diff --git a/src/Plugin/AuthenticationPlugin.php b/src/Plugin/AuthenticationPlugin.php index 194712f..ff33f9b 100644 --- a/src/Plugin/AuthenticationPlugin.php +++ b/src/Plugin/AuthenticationPlugin.php @@ -18,9 +18,6 @@ final class AuthenticationPlugin implements Plugin */ private $authentication; - /** - * @param Authentication $authentication - */ public function __construct(Authentication $authentication) { $this->authentication = $authentication; diff --git a/src/Plugin/CookiePlugin.php b/src/Plugin/CookiePlugin.php index 523628f..3ab5388 100644 --- a/src/Plugin/CookiePlugin.php +++ b/src/Plugin/CookiePlugin.php @@ -25,9 +25,6 @@ final class CookiePlugin implements Plugin */ private $cookieJar; - /** - * @param CookieJar $cookieJar - */ public function __construct(CookieJar $cookieJar) { $this->cookieJar = $cookieJar; @@ -91,7 +88,6 @@ public function handleRequest(RequestInterface $request, callable $next, callabl /** * Creates a cookie from a string. * - * @param RequestInterface $request * @param $setCookie * * @return Cookie|null diff --git a/src/Plugin/DecoderPlugin.php b/src/Plugin/DecoderPlugin.php index 0239d40..3a28f5b 100644 --- a/src/Plugin/DecoderPlugin.php +++ b/src/Plugin/DecoderPlugin.php @@ -120,8 +120,7 @@ private function decodeOnEncodingHeader($headerName, ResponseInterface $response /** * Decorate a stream given an encoding. * - * @param string $encoding - * @param StreamInterface $stream + * @param string $encoding * * @return StreamInterface|false A new stream interface or false if encoding is not supported */ diff --git a/src/Plugin/HistoryPlugin.php b/src/Plugin/HistoryPlugin.php index 5abddbd..0c59a2a 100644 --- a/src/Plugin/HistoryPlugin.php +++ b/src/Plugin/HistoryPlugin.php @@ -21,9 +21,6 @@ final class HistoryPlugin implements Plugin */ private $journal; - /** - * @param Journal $journal - */ public function __construct(Journal $journal) { $this->journal = $journal; diff --git a/src/Plugin/RequestMatcherPlugin.php b/src/Plugin/RequestMatcherPlugin.php index 5f72b02..dd97b3c 100644 --- a/src/Plugin/RequestMatcherPlugin.php +++ b/src/Plugin/RequestMatcherPlugin.php @@ -23,10 +23,6 @@ final class RequestMatcherPlugin implements Plugin */ private $delegatedPlugin; - /** - * @param RequestMatcher $requestMatcher - * @param Plugin $delegatedPlugin - */ public function __construct(RequestMatcher $requestMatcher, Plugin $delegatedPlugin) { $this->requestMatcher = $requestMatcher; diff --git a/src/Plugin/RetryPlugin.php b/src/Plugin/RetryPlugin.php index 0a5b4e7..96cfbb2 100644 --- a/src/Plugin/RetryPlugin.php +++ b/src/Plugin/RetryPlugin.php @@ -109,9 +109,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl } /** - * @param RequestInterface $request - * @param Exception $e - * @param int $retries The number of retries we made before. First time this get called it will be 0. + * @param int $retries The number of retries we made before. First time this get called it will be 0. * * @return int */ diff --git a/src/PluginClient.php b/src/PluginClient.php index c3a5641..6881c93 100644 --- a/src/PluginClient.php +++ b/src/PluginClient.php @@ -102,8 +102,6 @@ public function sendAsyncRequest(RequestInterface $request) /** * Configure the plugin client. * - * @param array $options - * * @return array */ private function configure(array $options = []) diff --git a/src/PluginClientFactory.php b/src/PluginClientFactory.php index bd4c08f..a262f80 100644 --- a/src/PluginClientFactory.php +++ b/src/PluginClientFactory.php @@ -26,8 +26,6 @@ final class PluginClientFactory * application execution. * * @internal - * - * @param callable $factory */ public static function setFactory(callable $factory) { From 637d01c4bac54a586ba4a16a507f7b9872aa5137 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 16:52:59 +0100 Subject: [PATCH 5/7] Migrate to Travis CI job sequence --- .travis.yml | 96 +++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c9a55f..97908bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,62 +2,64 @@ language: php sudo: false cache: - directories: - - $HOME/.composer/cache/files + directories: + - $HOME/.composer/cache/files env: - global: - - TEST_COMMAND="composer test" + global: + - TEST_COMMAND="composer test" branches: - except: - - /^analysis-.*$/ + except: + - /^analysis-.*$/ + +php: +- 7.0 +- 7.1 +- 7.2 matrix: - fast_finish: true - include: - - php: 7.0 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" - - # Test the latest stable release - - php: 7.0 - - php: 7.1 - - php: 7.2 - - php: 7.2 - env: COVERAGE=true TEST_COMMAND="composer test-ci" DEPENDENCIES="leanphp/phpspec-code-coverage" - - # 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: - - php: 7.3 - sudo: required - - env: STABILITY="dev" + fast_finish: true + allow_failures: + - php: 7.3 + - env: + STABILITY: "dev" + +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.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.3 + 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; - - 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 From ce5a98c779c218c26c3afe9aa34729ac50ccac99 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 17:01:01 +0100 Subject: [PATCH 6/7] Remove CS-fixer under 7.3 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97908bf..796c813 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,6 @@ matrix: fast_finish: true allow_failures: - php: 7.3 - - env: - STABILITY: "dev" jobs: include: @@ -47,6 +45,8 @@ jobs: # Latest dev release - php: 7.3 sudo: required + before_install: + - composer remove --dev friendsofphp/php-cs-fixer - env: STABILITY="dev" before_install: From 1cf0f9efb77e943d9af75095c9ebd34d37acbd47 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Nov 2018 17:36:31 +0100 Subject: [PATCH 7/7] Remove StyleCI config --- .styleci.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .styleci.yml diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 5328b61..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,14 +0,0 @@ -preset: symfony - -finder: - exclude: - - "spec" - path: - - "src" - - "tests" - -enabled: - - short_array_syntax - -disabled: - - phpdoc_annotation_without_dot # This is still buggy: https://github.com/symfony/symfony/pull/19198