Skip to content

Commit

Permalink
Merge 6f71285 into 20ac602
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Aug 6, 2020
2 parents 20ac602 + 6f71285 commit 74a5846
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Versions 0.3.0 and prior were released as "weierophinney/problem-details".

### Changed

- Nothing.
- [#5](https://github.com/mezzio/mezzio-problem-details/pull/5) updates the `ProblemDetailsExceptionInterface` to explicitly extend `Throwable`, forcing users to extend an `Exception` type in implementations. As using it outside that context was never intended, the maintainers do not consider this a BC break.

### Deprecated

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"phpspec/prophecy": "^1.8.0",
"phpunit/phpunit": "^7.0.1"
},
"autoload": {
Expand Down
3 changes: 2 additions & 1 deletion docs/book/exception.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ To facilitate this, we provide an interface, `ProblemDetailsExceptionInterface`:
namespace Mezzio\ProblemDetails\Exception;

use JsonSerializable;
use Throwable;

interface ProblemDetailsExceptionInterface extends JsonSerializable
interface ProblemDetailsExceptionInterface extends JsonSerializable, Throwable
{
public function getStatus() : int;

Expand Down
3 changes: 2 additions & 1 deletion src/Exception/ProblemDetailsExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
namespace Mezzio\ProblemDetails\Exception;

use JsonSerializable;
use Throwable;

/**
* Defines an exception type for generating Problem Details.
*/
interface ProblemDetailsExceptionInterface extends JsonSerializable
interface ProblemDetailsExceptionInterface extends JsonSerializable, Throwable
{
public function getStatus() : int;

Expand Down
3 changes: 2 additions & 1 deletion test/Exception/ProblemDetailsExceptionInterfaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace MezzioTest\ProblemDetails\Exception;

use Exception;
use Mezzio\ProblemDetails\Exception\CommonProblemDetailsExceptionTrait;
use Mezzio\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
use PHPUnit\Framework\TestCase;
Expand All @@ -35,7 +36,7 @@ protected function setUp() : void
$this->title,
$this->type,
$this->additional
) implements ProblemDetailsExceptionInterface {
) extends Exception implements ProblemDetailsExceptionInterface {
use CommonProblemDetailsExceptionTrait;

public function __construct(int $status, string $detail, string $title, string $type, array $additional)
Expand Down
4 changes: 2 additions & 2 deletions test/ProblemDetailsResponseFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function (array $payload) use ($expectedKeyNames) {

public function testCreateResponseFromThrowableWillPullDetailsFromProblemDetailsExceptionInterface() : void
{
$e = $this->prophesize(RuntimeException::class)->willImplement(ProblemDetailsExceptionInterface::class);
$e = $this->prophesize(ProblemDetailsExceptionInterface::class);
$e->getStatus()->willReturn(400);
$e->getDetail()->willReturn('Exception details');
$e->getTitle()->willReturn('Invalid client request');
Expand Down Expand Up @@ -443,7 +443,7 @@ function () {

public function testRenderWithMalformedUtf8Sequences(): void
{
$e = $this->prophesize(RuntimeException::class)->willImplement(ProblemDetailsExceptionInterface::class);
$e = $this->prophesize(ProblemDetailsExceptionInterface::class);
$e->getStatus()->willReturn(400);
$e->getDetail()->willReturn('Exception details');
$e->getTitle()->willReturn('Invalid client request');
Expand Down

0 comments on commit 74a5846

Please sign in to comment.