From 3f6d430499101484be1d7f47b271f008fb678482 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sun, 30 Dec 2018 09:22:05 +0100 Subject: [PATCH] Start version 2 --- CHANGELOG.md | 6 ++++++ composer.json | 2 +- spec/ClientSpec.php | 4 ++-- src/Client.php | 10 +++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3666463..6f1ebdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 2.0.0 - unreleased + +### Changed + +- Client::getLastRequest returns `null` instead of `false` when on requests have been recorded yet. + ## 1.5.0 - 2021-08-25 ### Changed diff --git a/composer.json b/composer.json index a0279c9..4291cce 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { diff --git a/spec/ClientSpec.php b/spec/ClientSpec.php index af02159..de85947 100644 --- a/spec/ClientSpec.php +++ b/spec/ClientSpec.php @@ -82,9 +82,9 @@ function it_returns_the_last_request(RequestInterface $request, ResponseInterfac $this->getLastRequest()->shouldReturn($request); } - function it_returns_false_when_there_is_no_last_request() + function it_returns_null_when_there_is_no_last_request() { - $this->getLastRequest()->shouldReturn(false); + $this->getLastRequest()->shouldReturn(null); } function it_reset( diff --git a/src/Client.php b/src/Client.php index e10890a..27bc831 100644 --- a/src/Client.php +++ b/src/Client.php @@ -188,7 +188,7 @@ public function addException(\Exception $exception) * * If both a default exception and a default response are set, the exception will be thrown. */ - public function setDefaultException(\Exception $defaultException = null) + public function setDefaultException(?\Exception $defaultException) { if (null !== $defaultException && !$defaultException instanceof Exception) { @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED); @@ -207,7 +207,7 @@ public function addResponse(ResponseInterface $response) /** * Sets the default response to be returned when the list of added exceptions and responses is exhausted. */ - public function setDefaultResponse(ResponseInterface $defaultResponse = null) + public function setDefaultResponse(?ResponseInterface $defaultResponse) { $this->defaultResponse = $defaultResponse; } @@ -217,14 +217,14 @@ public function setDefaultResponse(ResponseInterface $defaultResponse = null) * * @return RequestInterface[] */ - public function getRequests() + public function getRequests(): array { return $this->requests; } - public function getLastRequest() + public function getLastRequest(): ?RequestInterface { - return end($this->requests); + return end($this->requests) ?: null; } public function reset()