diff --git a/.travis.yml b/.travis.yml index 730574d..5acdf9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,9 @@ env: matrix: fast_finish: true include: - - php: 7.0 - dist: xenial - env: deps=low - php: 7.1 dist: bionic + env: deps=low - php: 7.2 dist: bionic - php: 7.3 diff --git a/README.md b/README.md index 2397ed8..5b266bc 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,14 @@ You can sign up for a Clearhaus account at https://www.clearhaus.com/. ## Requirements -* PHP 7.0+ +* PHP 7.1+ * [php-http/client-common ^1.3](https://github.com/php-http/client-common) -* [php-http/discovery ^1.0](https://github.com/php-http/discovery) +* [php-http/discovery ^1.6](https://github.com/php-http/discovery) * [php-http/httplug ^1.0](https://github.com/php-http/httplug) +* [php-http/message-factory ^1.0.2](https://github.com/php-http/message-factory) +* [phpseclib/phpseclib ^2.0](https://github.com/phpseclib/phpseclib) +* [psr/container ^1.0](https://github.com/php-fig/container) +* [psr/http-message ^1.0](https://github.com/php-fig/http-message) ## Installation diff --git a/composer.json b/composer.json index 9a1c8c4..f71c96b 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ } }, "require": { - "php": "^7.0", + "php": "^7.1", "php-http/client-common": "^1.3", "php-http/discovery": "^1.6", "php-http/httplug": "^1.0", @@ -35,9 +35,10 @@ "psr/http-message": "^1.0" }, "require-dev": { - "phpspec/phpspec": "^4.0 || ^5.0 || ^6.0", + "phpspec/phpspec": "^5.0 || ^6.0", "phpspec/prophecy": "^1.6.2", - "laminas/laminas-diactoros": "^1.6 || ^2.0" + "guzzlehttp/psr7": "^1.6", + "http-interop/http-factory-guzzle": "^1.0" }, "suggest": { "ext-openssl": "Allow to sign requests using RSA signature of the HTTP body." diff --git a/spec/Api/AbstractSpec.php b/spec/Api/AbstractSpec.php index 5e5c57b..4d07894 100644 --- a/spec/Api/AbstractSpec.php +++ b/spec/Api/AbstractSpec.php @@ -3,16 +3,15 @@ namespace spec\Clearhaus\Api; use Clearhaus\Client; +use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\Response; use PhpSpec\ObjectBehavior; -use Laminas\Diactoros\Response; -use Laminas\Diactoros\Stream; abstract class AbstractSpec extends ObjectBehavior { protected function createHttpResponse(array $body) : Response { - $stream = new Stream('php://memory', 'rw'); - $stream->write(json_encode($body, JSON_FORCE_OBJECT)); + $stream = Psr7\stream_for(\json_encode($body, JSON_FORCE_OBJECT)); $stream->rewind(); $httpResponse = (new Response()) diff --git a/spec/ClientSpec.php b/spec/ClientSpec.php index e3f6468..64d0a2a 100644 --- a/spec/ClientSpec.php +++ b/spec/ClientSpec.php @@ -26,7 +26,7 @@ function it_is_initializable() function it_should_enable_signature(Builder $builder) { - $builder->addPlugin(Argument::type(Plugin::class))->willReturn(null); + $builder->addPlugin(Argument::type(Plugin::class))->shouldBeCalled(); $builder->addPlugin(Argument::type(SignaturePlugin::class))->shouldBeCalled(); @@ -35,7 +35,7 @@ function it_should_enable_signature(Builder $builder) function it_should_return_http_client(Builder $builder, HttpMethodsClient $httpMethodsClient) { - $builder->addPlugin(Argument::type(Plugin::class))->willReturn(null); + $builder->addPlugin(Argument::type(Plugin::class))->shouldBeCalled(); $builder->build()->willReturn($httpMethodsClient); diff --git a/spec/HttpClient/Plugin/ErrorPluginSpec.php b/spec/HttpClient/Plugin/ErrorPluginSpec.php index 3272389..98f5cf4 100644 --- a/spec/HttpClient/Plugin/ErrorPluginSpec.php +++ b/spec/HttpClient/Plugin/ErrorPluginSpec.php @@ -9,13 +9,13 @@ use Clearhaus\Exception\ValidationFailedException; use Clearhaus\HttpClient\Plugin\ErrorPlugin; use Exception; +use GuzzleHttp\Psr7; +use GuzzleHttp\Psr7\Response; use Http\Promise\FulfilledPromise; use Http\Promise\Promise; use Http\Promise\RejectedPromise; use PhpSpec\ObjectBehavior; use Psr\Http\Message\RequestInterface; -use Laminas\Diactoros\Response; -use Laminas\Diactoros\Stream; class ErrorPluginSpec extends ObjectBehavior { @@ -120,8 +120,7 @@ private function createFailedHttpResponse(int $statusCode,int $errorCode, strin private function createHttpResponse(array $body, int $statusCode = 200) : Response { - $stream = new Stream('php://memory', 'rw'); - $stream->write(json_encode($body, JSON_FORCE_OBJECT)); + $stream = Psr7\stream_for(\json_encode($body, JSON_FORCE_OBJECT)); $stream->rewind(); $httpResponse = (new Response()) diff --git a/src/Client.php b/src/Client.php index ac39950..98d1b07 100644 --- a/src/Client.php +++ b/src/Client.php @@ -55,7 +55,7 @@ public function __construct(string $apiKey, Builder $builder = null, string $mod )); } - public function enableSignature() + public function enableSignature(): void { $encrypter = new RSA(); $this->builder->addPlugin(new SignaturePlugin($encrypter, $this->apiKey)); diff --git a/src/HttpClient/Builder.php b/src/HttpClient/Builder.php index d26f812..212c607 100644 --- a/src/HttpClient/Builder.php +++ b/src/HttpClient/Builder.php @@ -67,13 +67,13 @@ public function build() : HttpMethodsClient return $this->pluginClient; } - public function addPlugin(Plugin $plugin) + public function addPlugin(Plugin $plugin): void { $this->plugins[] = $plugin; $this->httpClientModified = true; } - public function removePlugin(string $fqcn) + public function removePlugin(string $fqcn): void { foreach ($this->plugins as $index => $plugin) { if ($plugin instanceof $fqcn) {