Skip to content

Commit dadd7b3

Browse files
authored
Merge pull request #286 from kenjis/fix-exception-structure
fix: Exception structure
2 parents 794275f + d8342dd commit dadd7b3

File tree

12 files changed

+29
-20
lines changed

12 files changed

+29
-20
lines changed

src/Authentication/AuthenticationException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace CodeIgniter\Shield\Authentication;
44

55
use CodeIgniter\HTTP\Exceptions\HTTPException;
6-
use Exception;
6+
use CodeIgniter\Shield\Exceptions\RuntimeException;
77

8-
class AuthenticationException extends Exception
8+
class AuthenticationException extends RuntimeException
99
{
1010
protected $code = 403;
1111

src/Authentication/Authenticators/AccessTokens.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
use CodeIgniter\Shield\Authentication\AuthenticationException;
88
use CodeIgniter\Shield\Authentication\AuthenticatorInterface;
99
use CodeIgniter\Shield\Entities\User;
10+
use CodeIgniter\Shield\Exceptions\InvalidArgumentException;
1011
use CodeIgniter\Shield\Models\TokenLoginModel;
1112
use CodeIgniter\Shield\Models\UserIdentityModel;
1213
use CodeIgniter\Shield\Models\UserModel;
1314
use CodeIgniter\Shield\Result;
14-
use InvalidArgumentException;
1515

1616
class AccessTokens implements AuthenticatorInterface
1717
{

src/Authentication/Authenticators/Session.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
use CodeIgniter\Shield\Authentication\Passwords;
1414
use CodeIgniter\Shield\Entities\User;
1515
use CodeIgniter\Shield\Entities\UserIdentity;
16+
use CodeIgniter\Shield\Exceptions\InvalidArgumentException;
1617
use CodeIgniter\Shield\Exceptions\LogicException;
1718
use CodeIgniter\Shield\Models\LoginModel;
1819
use CodeIgniter\Shield\Models\RememberModel;
1920
use CodeIgniter\Shield\Models\UserIdentityModel;
2021
use CodeIgniter\Shield\Models\UserModel;
2122
use CodeIgniter\Shield\Result;
22-
use Exception;
23-
use InvalidArgumentException;
2423
use stdClass;
2524

2625
class Session implements AuthenticatorInterface
@@ -812,8 +811,6 @@ public function recordActiveDate(): void
812811
* and stores the necessary info in the db and a cookie.
813812
*
814813
* @see https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence
815-
*
816-
* @throws Exception
817814
*/
818815
protected function rememberUser(User $user): void
819816
{

src/Authorization/AuthorizationException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace CodeIgniter\Shield\Authorization;
44

5-
use Exception;
5+
use CodeIgniter\Shield\Exceptions\RuntimeException;
66

7-
class AuthorizationException extends Exception
7+
class AuthorizationException extends RuntimeException
88
{
99
protected $code = 401;
1010

src/Authorization/Groups.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace CodeIgniter\Shield\Authorization;
44

55
use CodeIgniter\Shield\Entities\Group;
6-
use RuntimeException;
6+
use CodeIgniter\Shield\Exceptions\RuntimeException;
77

88
/**
99
* Provides utility feature for working with

src/Exceptions/BaseException.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace CodeIgniter\Shield\Exceptions;
4+
5+
use Throwable;
6+
7+
/**
8+
* Base Exception Interface for Shield
9+
*/
10+
interface BaseException extends Throwable
11+
{
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace CodeIgniter\Shield\Exceptions;
4+
5+
class InvalidArgumentException extends LogicException implements BaseException
6+
{
7+
}

src/Exceptions/LogicException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
namespace CodeIgniter\Shield\Exceptions;
44

5-
class LogicException extends \LogicException
5+
class LogicException extends \LogicException implements BaseException
66
{
77
}

src/Exceptions/RuntimeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
namespace CodeIgniter\Shield\Exceptions;
44

5-
class RuntimeException extends \RuntimeException
5+
class RuntimeException extends \RuntimeException implements BaseException
66
{
77
}

src/Models/LoginModel.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use CodeIgniter\Shield\Authentication\Authenticators\Session;
88
use CodeIgniter\Shield\Entities\Login;
99
use CodeIgniter\Shield\Entities\User;
10-
use Exception;
1110
use Faker\Generator;
1211

1312
class LoginModel extends Model
@@ -81,8 +80,6 @@ public function lastLogin(User $user): ?Login
8180

8281
/**
8382
* Generate a fake login for testing
84-
*
85-
* @throws Exception
8683
*/
8784
public function fake(Generator &$faker): Login
8885
{

0 commit comments

Comments
 (0)