Skip to content

Commit f3013b9

Browse files
author
Walmir Silva
committed
fix(exception): make AbstractException factories return the concrete subclass
1 parent 30f4076 commit f3013b9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/AbstractException.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
namespace KaririCode\Exception;
66

77
use KaririCode\Exception\Contract\ErrorMessage;
8-
use KaririCode\Exception\Contract\Throwable;
98

10-
abstract class AbstractException extends \Exception implements Throwable
9+
abstract class AbstractException extends \Exception implements \Throwable
1110
{
1211
protected array $context = [];
1312
private string $errorCode;
@@ -29,15 +28,19 @@ public function getErrorCode(): string
2928
return $this->errorCode;
3029
}
3130

32-
protected function addContext(string $key, mixed $value): self
31+
protected function addContext(string $key, mixed $value): static
3332
{
3433
$this->context[$key] = $value;
3534

3635
return $this;
3736
}
3837

39-
protected static function createException(int $code, string $errorCode, string $message, ?\Throwable $previous = null): self
40-
{
38+
protected static function createException(
39+
int $code,
40+
string $errorCode,
41+
string $message,
42+
?\Throwable $previous = null
43+
): static {
4144
return new static(new ExceptionMessage($code, $errorCode, $message), $previous);
4245
}
4346
}

0 commit comments

Comments
 (0)