Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Added ExceptionInterface as marker for package-specific exceptions #128

Merged
merged 1 commit into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/book/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ If you wish to use those types, you will need to decorate them in a
only operate on the response returned by `$next`, or produce a concrete
response yourself.

- `Zend\Stratigility\Exception\ExceptionInterface` - marker for
package-specific exceptions.

### Removed classes and exceptions

The following classes have been removed:
Expand Down
15 changes: 15 additions & 0 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* @see https://github.com/zendframework/zend-stratigility for the canonical source repository
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-stratigility/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Stratigility\Exception;

/**
* Marker interface for package-specific exceptions.
*/
interface ExceptionInterface
{
}
2 changes: 1 addition & 1 deletion src/Exception/InvalidMiddlewareException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Interop\Http\Server\MiddlewareInterface;
use InvalidArgumentException;

class InvalidMiddlewareException extends InvalidArgumentException
class InvalidMiddlewareException extends InvalidArgumentException implements ExceptionInterface
{
/**
* Create and return an InvalidArgumentException detailing the invalid middleware type.
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/MissingResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Exception thrown when the internal stack of Zend\Stratigility\Next is
* exhausted, but no response returned.
*/
class MissingResponseException extends OutOfBoundsException
class MissingResponseException extends OutOfBoundsException implements ExceptionInterface
{
public static function forCallableMiddleware(callable $middleware) : self
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/MissingResponsePrototypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Exception thrown by the DoublePassMiddlewareWrapper when no response
* prototype is provided, and Diactoros is not available to create a default.
*/
class MissingResponsePrototypeException extends UnexpectedValueException
class MissingResponsePrototypeException extends UnexpectedValueException implements ExceptionInterface
{
public static function create() : self
{
Expand Down
36 changes: 36 additions & 0 deletions test/Exception/ExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* @see https://github.com/zendframework/zend-stratigility for the canonical source repository
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-stratigility/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\Stratigility\Exception;

use Generator;
use PHPUnit\Framework\TestCase;
use Zend\Stratigility\Exception\ExceptionInterface;

class ExceptionTest extends TestCase
{
public function exception() : Generator
{
$namespace = substr(ExceptionInterface::class, 0, strrpos(ExceptionInterface::class, '\\') + 1);

$exceptions = glob(__DIR__ . '/../../src/Exception/*.php');
foreach ($exceptions as $exception) {
$class = substr(basename($exception), 0, -4);

yield $class => [$namespace . $class];
}
}

/**
* @dataProvider exception
*/
public function testExceptionIsInstanceOfExceptionInterface(string $exception) : void
{
self::assertContains('Exception', $exception);
self::assertTrue(is_a($exception, ExceptionInterface::class, true));
}
}