From b139f21e7d974f6b8c4de20cbfb35b5153e9b8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gamez?= Date: Tue, 14 Jan 2020 17:10:54 +0100 Subject: [PATCH] Apply code style rules --- .../Auth/Token/Cache/InMemoryCache.php | 1 + src/Firebase/Auth/Token/Generator.php | 3 --- src/Firebase/Auth/Token/Handler.php | 5 ---- .../Action/VerifyIdToken/WithFirebaseJWT.php | 24 ++++--------------- .../VerifyIdToken/WithLcobucciV3JWT.php | 5 +--- src/JWT/Cache/InMemoryCache.php | 1 + src/JWT/Contract/ExpirableTrait.php | 1 - src/JWT/Contract/Keys.php | 3 --- src/JWT/Value/Duration.php | 2 -- tests/Firebase/Auth/Token/VerifierTest.php | 1 - 10 files changed, 8 insertions(+), 38 deletions(-) diff --git a/src/Firebase/Auth/Token/Cache/InMemoryCache.php b/src/Firebase/Auth/Token/Cache/InMemoryCache.php index 681edf0..abd18ae 100644 --- a/src/Firebase/Auth/Token/Cache/InMemoryCache.php +++ b/src/Firebase/Auth/Token/Cache/InMemoryCache.php @@ -50,6 +50,7 @@ public function set($key, $value, $ttl = null) if (!$expires) { $this->delete($key); + return true; } diff --git a/src/Firebase/Auth/Token/Generator.php b/src/Firebase/Auth/Token/Generator.php index 2b55bb2..3bff5d8 100644 --- a/src/Firebase/Auth/Token/Generator.php +++ b/src/Firebase/Auth/Token/Generator.php @@ -42,12 +42,9 @@ public function __construct( * Returns a token for the given user and claims. * * @param mixed $uid - * @param array $claims * @param \DateTimeInterface $expiresAt * * @throws \BadMethodCallException when a claim is invalid - * - * @return Token */ public function createCustomToken($uid, array $claims = [], \DateTimeInterface $expiresAt = null): Token { diff --git a/src/Firebase/Auth/Token/Handler.php b/src/Firebase/Auth/Token/Handler.php index cc14ec4..9ecbc4b 100644 --- a/src/Firebase/Auth/Token/Handler.php +++ b/src/Firebase/Auth/Token/Handler.php @@ -26,11 +26,6 @@ final class Handler implements Domain\Generator, Domain\Verifier /** * @deprecated 1.7.0 Use the Generator and Verifier directly instead - * - * @param string $projectId - * @param string $clientEmail - * @param string $privateKey - * @param KeyStore|null $keyStore */ public function __construct(string $projectId, string $clientEmail, string $privateKey, KeyStore $keyStore = null) { diff --git a/src/JWT/Action/VerifyIdToken/WithFirebaseJWT.php b/src/JWT/Action/VerifyIdToken/WithFirebaseJWT.php index 16c0a61..b41e750 100644 --- a/src/JWT/Action/VerifyIdToken/WithFirebaseJWT.php +++ b/src/JWT/Action/VerifyIdToken/WithFirebaseJWT.php @@ -55,29 +55,15 @@ public function handle(VerifyIdToken $action): Token // This will check kid, nbf, iat, exp and the signature $token = JWT::decode($tokenString, $this->keys->all(), ['RS256']); } catch (DomainException $e) { - throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, [ - 'The token could not be decoded.', - $e->getMessage(), - ]); + throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, ['The token could not be decoded.', $e->getMessage()]); } catch (BeforeValidException $e) { - throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, [ - 'The token has been issued for future use.', - $e->getMessage(), - ]); + throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, ['The token has been issued for future use.', $e->getMessage()]); } catch (ExpiredException $e) { - throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, [ - 'The token is expired.', - ]); + throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, ['The token is expired.']); } catch (UnexpectedValueException $e) { - throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, [ - 'The token is invalid.', - $e->getMessage(), - ]); + throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, ['The token is invalid.', $e->getMessage()]); } catch (Throwable $e) { - throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, [ - 'The token is invalid.', - $e->getMessage(), - ]); + throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, ['The token is invalid.', $e->getMessage()]); } finally { $this->restoreJWTStaticVariables($timestampBackup, $leewayBackup); } diff --git a/src/JWT/Action/VerifyIdToken/WithLcobucciV3JWT.php b/src/JWT/Action/VerifyIdToken/WithLcobucciV3JWT.php index b4d5323..9b18160 100644 --- a/src/JWT/Action/VerifyIdToken/WithLcobucciV3JWT.php +++ b/src/JWT/Action/VerifyIdToken/WithLcobucciV3JWT.php @@ -50,10 +50,7 @@ public function handle(VerifyIdToken $action): Token try { $token = (new Parser())->parse($tokenString); } catch (Throwable $e) { - throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, [ - 'The token is invalid', - $e->getMessage(), - ]); + throw IdTokenVerificationFailed::withTokenAndReasons($tokenString, ['The token is invalid', $e->getMessage()]); } $timestamp = $this->clock->now()->getTimestamp(); diff --git a/src/JWT/Cache/InMemoryCache.php b/src/JWT/Cache/InMemoryCache.php index b0d55ec..e728676 100644 --- a/src/JWT/Cache/InMemoryCache.php +++ b/src/JWT/Cache/InMemoryCache.php @@ -67,6 +67,7 @@ public function set($key, $value, $ttl = null): bool if (!$expires) { $this->delete($key); + return true; } diff --git a/src/JWT/Contract/ExpirableTrait.php b/src/JWT/Contract/ExpirableTrait.php index eb7fa8f..7d93028 100644 --- a/src/JWT/Contract/ExpirableTrait.php +++ b/src/JWT/Contract/ExpirableTrait.php @@ -6,7 +6,6 @@ use DateTimeImmutable; use DateTimeInterface; -use LogicException; trait ExpirableTrait { diff --git a/src/JWT/Contract/Keys.php b/src/JWT/Contract/Keys.php index 5043e2f..c57c090 100644 --- a/src/JWT/Contract/Keys.php +++ b/src/JWT/Contract/Keys.php @@ -6,8 +6,5 @@ interface Keys { - /** - * @return array - */ public function all(): array; } diff --git a/src/JWT/Value/Duration.php b/src/JWT/Value/Duration.php index 887625a..79fda97 100644 --- a/src/JWT/Value/Duration.php +++ b/src/JWT/Value/Duration.php @@ -57,8 +57,6 @@ public static function make($value): self } /** - * @param int $seconds - * * @throws InvalidArgumentException */ public static function inSeconds(int $seconds): self diff --git a/tests/Firebase/Auth/Token/VerifierTest.php b/tests/Firebase/Auth/Token/VerifierTest.php index 3bea121..1ba4ef1 100644 --- a/tests/Firebase/Auth/Token/VerifierTest.php +++ b/tests/Firebase/Auth/Token/VerifierTest.php @@ -103,7 +103,6 @@ public function testItVerifiesTheSignatureNoMatterWhat() } /** - * @param Token $token * @param string $exception * @dataProvider invalidTokenProvider */