diff --git a/src/Authentication.php b/src/Authentication.php index dcbdfba..4658e11 100644 --- a/src/Authentication.php +++ b/src/Authentication.php @@ -34,16 +34,16 @@ class Authentication extends Configurable public const SESSION_KEY = 'authentication'; /** @var string 認証テーブル名 */ - public static $AUTHORIZE_TABLE_NAME = 'users'; + public static string $AUTHORIZE_TABLE_NAME = 'users'; /** @var string token生成アルゴリズム */ - public static $TOKEN_ALGO = 'sha256'; + public static string $TOKEN_ALGO = 'sha256'; /** @var int ログイン維持時間(秒) */ - public static $KEEP_SECOND = (60 * 60 * 24); + public static int $KEEP_SECOND = (60 * 60 * 24); - /** @var Protocol 認証タイプインスタンス */ - public $protocol = null; + /** @var Protocol|null 認証タイプインスタンス */ + public Protocol|null $protocol = null; @@ -65,8 +65,6 @@ public function loadConfigures(array $configures = []): Configurable return $this; } - - /** * 認証処理 * @@ -83,8 +81,6 @@ public function authorize(AuthItem $item): bool return $this->protocol->authorize($item); } - - /** * 認証解除処理 * @@ -100,8 +96,6 @@ public function deAuthorize(): bool return $this->protocol->deAuthorize(); } - - /** * 認証のチェック * 認証できていれば期間の延長 @@ -119,8 +113,6 @@ public function isAuthenticated(AuthItem|null $item = null): bool return $this->protocol->isAuthenticated($item); } - - /** * ログイントークンの生成 * @@ -144,14 +136,12 @@ public static function generateToken(string|null $key = null): string ); // tokenキー - $key = ($key ?? Session::$sessionId); + $key ??= Session::$sessionId; // token生成し返却 return hash(self::$TOKEN_ALGO, $key); } - - /** * ログイン維持制限時間の生成 * @@ -162,8 +152,6 @@ public static function generateKeepAt(): string return Dates::now()->addSecond(self::$KEEP_SECOND)->format('Y-m-d H:i:s'); } - - /** * {@inheritDoc} */ @@ -172,8 +160,6 @@ protected function configureKey(): string return 'authentication'; } - - /** * {@inheritDoc} */ @@ -184,8 +170,6 @@ protected function configureDefaults(): array ]; } - - /** * {@inheritDoc} */ diff --git a/src/Controller/ApiController.php b/src/Controller/ApiController.php index 18e55d4..b5dbdbe 100644 --- a/src/Controller/ApiController.php +++ b/src/Controller/ApiController.php @@ -38,7 +38,7 @@ class ApiController extends BaseController public function run(Router|null $router = null): void { // ルーター - $router = ($router ?? Router::sharedInstance()->factory()); + $router ??= Router::sharedInstance()->factory(); $this->router = $router; try @@ -64,8 +64,6 @@ public function run(Router|null $router = null): void Message::removeAll(); } - $response_json = json_encode($response); - // 出力 echo $response->toJson(); } diff --git a/src/Controller/AuthController.php b/src/Controller/AuthController.php index f39ac9f..c5653e0 100644 --- a/src/Controller/AuthController.php +++ b/src/Controller/AuthController.php @@ -50,8 +50,6 @@ public function signin(Request $request): Response return AuthResponse::withToken($item->token); } - - /** * ユーザー情報 * @@ -81,7 +79,6 @@ public function user(Request $request): Response return AuthResponse::withItem($item); } - /** * 認証チェック */ diff --git a/src/Controller/AuthResponse.php b/src/Controller/AuthResponse.php index 6e7c388..116e974 100644 --- a/src/Controller/AuthResponse.php +++ b/src/Controller/AuthResponse.php @@ -22,10 +22,10 @@ class AuthResponse extends Response use Binders; /** @var String 認証用トークン */ - public $token; + public string $token; /** @var array 認証用アイテム */ - public $user; + public array $user; @@ -48,8 +48,6 @@ public static function withToken(string $token): self return $self; } - - /** * user返却用レスポンスの生成 *