Skip to content
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Security - in case of vulnerabilities.

_TBD_

## [0.1.0] 2018-12-08
## [1.0.0] 2018-12-23

Initial release.
2 changes: 1 addition & 1 deletion src/BadFunctionCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class BadFunctionCallException extends \BadFunctionCallException implements Throwable
class BadFunctionCallException extends \BadFunctionCallException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class BadMethodCallException extends \BadMethodCallException implements Throwable
class BadMethodCallException extends \BadMethodCallException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/DomainException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class DomainException extends \DomainException implements Throwable
class DomainException extends \DomainException implements InformativeException
{
use ThrowableContextTrait;
}
4 changes: 2 additions & 2 deletions src/Throwable.php → src/InformativeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Marker interface for exceptions with context information.
*/
interface Throwable extends \Throwable
interface InformativeException extends \Throwable
{
public function getContext() : array;
public function getContext(): array;
}
2 changes: 1 addition & 1 deletion src/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class InvalidArgumentException extends \InvalidArgumentException implements Throwable
class InvalidArgumentException extends \InvalidArgumentException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/LengthException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class LengthException extends \LengthException implements Throwable
class LengthException extends \LengthException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/LogicException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class LogicException extends \LogicException implements Throwable
class LogicException extends \LogicException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/OutOfBoundsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class OutOfBoundsException extends \OutOfBoundsException implements Throwable
class OutOfBoundsException extends \OutOfBoundsException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/OutOfRangeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class OutOfRangeException extends \OutOfRangeException implements Throwable
class OutOfRangeException extends \OutOfRangeException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/OverflowException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class OverflowException extends \OverflowException implements Throwable
class OverflowException extends \OverflowException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/RangeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class RangeException extends \RangeException implements Throwable
class RangeException extends \RangeException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class RuntimeException extends \RuntimeException implements Throwable
class RuntimeException extends \RuntimeException implements InformativeException
{
use ThrowableContextTrait;
}
4 changes: 2 additions & 2 deletions src/ThrowableContextTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ trait ThrowableContextTrait
{
private $context = [];

public function __construct(string $message = '', array $context = [], int $code = 0, Throwable $previous = null)
public function __construct(string $message = '', array $context = [], int $code = 0, \Throwable $previous = null)
{
parent::__construct($message, $code, $previous);

$this->context = $context;
}

public function getContext() : array
public function getContext(): array
{
return $this->context;
}
Expand Down
2 changes: 1 addition & 1 deletion src/UnderflowException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class UnderflowException extends \UnderflowException implements Throwable
class UnderflowException extends \UnderflowException implements InformativeException
{
use ThrowableContextTrait;
}
2 changes: 1 addition & 1 deletion src/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Zee\Exceptions;

class UnexpectedValueException extends \UnexpectedValueException implements Throwable
class UnexpectedValueException extends \UnexpectedValueException implements InformativeException
{
use ThrowableContextTrait;
}
6 changes: 4 additions & 2 deletions tests/ReadExceptionContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ public function exceptionObjectShouldContainContext(string $exceptionClass): voi
$message = 'Something went wrong';
$code = PHP_INT_MAX;
$context = ['foo' => 'bar'];
$previous = new \Exception('Something went wrong');

$exception = new $exceptionClass($message, $context, $code);
$exception = new $exceptionClass($message, $context, $code, $previous);

if ($exception instanceof Exceptions\Throwable) {
if ($exception instanceof Exceptions\InformativeException) {
self::assertSame($message, $exception->getMessage());
self::assertSame($context, $exception->getContext());
self::assertSame($code, $exception->getCode());
self::assertSame($previous, $exception->getPrevious());
} else {
self::fail('Invalid exception class');
}
Expand Down