Passed
Push — master ( a9d3e0...4db961 )
by Thomas Mauro
03:01
created
src/Token/IdTokenVerifier.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             ? $metadata->getUserinfoSignedResponseAlg()
84 84
             : $metadata->getIdTokenSignedResponseAlg();
85 85
 
86
-        if (! $expectedAlg) {
86
+        if (!$expectedAlg) {
87 87
             throw new RuntimeException('Unable to verify id_token without an alg value');
88 88
         }
89 89
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         $payload = \json_decode(base64url_decode(\explode('.', $idToken)[1] ?? '{}'), true);
97 97
 
98
-        if (! \is_array($payload)) {
98
+        if (!\is_array($payload)) {
99 99
             throw new InvalidArgumentException('Unable to decode token payload');
100 100
         }
101 101
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
         $requiredClaims = [];
122 122
 
123
-        if (! $fromUserInfo) {
123
+        if (!$fromUserInfo) {
124 124
             $requiredClaims = ['iss', 'sub', 'aud', 'exp', 'iat'];
125 125
         }
126 126
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         if (0 === \strpos($expectedAlg, 'HS')) {
147 147
             $clientSecret = $metadata->getClientSecret();
148 148
 
149
-            if (! $clientSecret) {
149
+            if (!$clientSecret) {
150 150
                 throw new RuntimeException('Unable to verify token without client_secret');
151 151
             }
152 152
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             $jwks = $client->getIssuer()->getJwks();
156 156
         }
157 157
 
158
-        if (! $jwsVerifier->verifyWithKeySet($jws, $jwks, 0)) {
158
+        if (!$jwsVerifier->verifyWithKeySet($jws, $jwks, 0)) {
159 159
             throw new InvalidArgumentException('Failed to validate JWT signature');
160 160
         }
161 161
 
Please login to merge, or discard this patch.
src/Token/TokenSet.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             'code_verifier' => $this->codeVerifier,
129 129
         ];
130 130
 
131
-        return \array_filter($data, static function ($value) {
131
+        return \array_filter($data, static function($value) {
132 132
             return null !== $value;
133 133
         });
134 134
     }
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public function claims(): array
140 140
     {
141
-        if (! $this->idToken) {
141
+        if (!$this->idToken) {
142 142
             throw new RuntimeException('Unable to retrieve claims without an id_token');
143 143
         }
144 144
 
145 145
         $data = \json_decode(base64url_decode(\explode('.', $this->idToken)[1] ?? ''), true);
146 146
 
147
-        if (! \is_array($data)) {
147
+        if (!\is_array($data)) {
148 148
             throw new RuntimeException('Unable to decode id_token payload');
149 149
         }
150 150
 
Please login to merge, or discard this patch.
src/Token/TokenSetVerifier.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     ): void {
46 46
         $idToken = $tokenSet->getIdToken();
47 47
 
48
-        if (! $idToken) {
48
+        if (!$idToken) {
49 49
             throw new InvalidArgumentException('No id_token in token set');
50 50
         }
51 51
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $header = \json_decode(base64url_decode(\explode('.', $idToken)[0] ?? '{}'), true);
57 57
         $payload = \json_decode(base64url_decode(\explode('.', $idToken)[1] ?? '{}'), true);
58 58
 
59
-        if (! \is_array($payload)) {
59
+        if (!\is_array($payload)) {
60 60
             throw new InvalidArgumentException('Unable to decode token payload');
61 61
         }
62 62
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             if (\array_key_exists('s_hash', $payload)) {
77 77
                 $state = $authSession ? $authSession->getState() : null;
78 78
 
79
-                if (! $state) {
79
+                if (!$state) {
80 80
                     throw new InvalidArgumentException('Cannot verify s_hash, "state" not provided');
81 81
                 }
82 82
 
Please login to merge, or discard this patch.
src/Token/ResponseTokenVerifier.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $metadata = $client->getMetadata();
56 56
         $expectedAlg = $metadata->getAuthorizationSignedResponseAlg();
57 57
 
58
-        if (! $expectedAlg) {
58
+        if (!$expectedAlg) {
59 59
             throw new RuntimeException('No authorization_signed_response_alg defined');
60 60
         }
61 61
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
         $payload = \json_decode(base64url_decode(\explode('.', $token)[1] ?? '{}'), true);
69 69
 
70
-        if (! \is_array($payload)) {
70
+        if (!\is_array($payload)) {
71 71
             throw new InvalidArgumentException('Unable to decode token payload');
72 72
         }
73 73
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         if (0 === \strpos($expectedAlg, 'HS')) {
103 103
             $clientSecret = $metadata->getClientSecret();
104 104
 
105
-            if (! $clientSecret) {
105
+            if (!$clientSecret) {
106 106
                 throw new RuntimeException('Unable to verify token without client_secret');
107 107
             }
108 108
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             $jwks = $client->getIssuer()->getJwks();
112 112
         }
113 113
 
114
-        if (! $jwsVerifier->verifyWithKeySet($jws, $jwks, 0)) {
114
+        if (!$jwsVerifier->verifyWithKeySet($jws, $jwks, 0)) {
115 115
             throw new InvalidArgumentException('Failed to validate JWT signature');
116 116
         }
117 117
 
Please login to merge, or discard this patch.
src/Middleware/SessionCookieMiddleware.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
36 36
     {
37
-        if (! \class_exists(Cookies::class)) {
37
+        if (!\class_exists(Cookies::class)) {
38 38
             throw new LogicException('To use the SessionCookieMiddleware you should install dflydev/fig-cookies package');
39 39
         }
40 40
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $cookieValue = $sessionCookie ? $sessionCookie->getValue() : null;
45 45
         $data = $cookieValue ? \json_decode($cookieValue, true) : [];
46 46
 
47
-        if (! \is_array($data)) {
47
+        if (!\is_array($data)) {
48 48
             $data = [];
49 49
         }
50 50
 
Please login to merge, or discard this patch.
src/Middleware/CallbackMiddleware.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@
 block discarded – undo
45 45
         $client = $this->client ?: $request->getAttribute(ClientInterface::class);
46 46
         $authSession = $request->getAttribute(AuthSessionInterface::class);
47 47
 
48
-        if (! $client instanceof ClientInterface) {
48
+        if (!$client instanceof ClientInterface) {
49 49
             throw new LogicException('No OpenID client provided');
50 50
         }
51 51
 
52
-        if ($authSession && ! $client instanceof AuthSessionInterface) {
52
+        if ($authSession && !$client instanceof AuthSessionInterface) {
53 53
             throw new LogicException('Invalid auth session provided in attribute ' . AuthSessionInterface::class);
54 54
         }
55 55
 
Please login to merge, or discard this patch.
src/Middleware/UserInfoMiddleware.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,17 +37,17 @@
 block discarded – undo
37 37
         $tokenSet = $request->getAttribute(TokenSetInterface::class);
38 38
         $client = $this->client ?: $request->getAttribute(ClientInterface::class);
39 39
 
40
-        if (! $client instanceof ClientInterface) {
40
+        if (!$client instanceof ClientInterface) {
41 41
             throw new LogicException('No OpenID client provided');
42 42
         }
43 43
 
44
-        if (! $tokenSet instanceof TokenSetInterface) {
44
+        if (!$tokenSet instanceof TokenSetInterface) {
45 45
             throw new RuntimeException('Unable to get token response attribute');
46 46
         }
47 47
 
48 48
         $accessToken = $tokenSet->getAccessToken();
49 49
 
50
-        if (! $accessToken) {
50
+        if (!$accessToken) {
51 51
             throw new RuntimeException(\sprintf(
52 52
                 'Unable to get access token from "%s" attribute',
53 53
                 TokenSetInterface::class
Please login to merge, or discard this patch.
src/functions/base64url_decode.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 {
11 11
     $decoded = \base64_decode(\str_pad(\strtr($data, '-_', '+/'), \strlen($data) % 4, '='));
12 12
 
13
-    if (! $decoded) {
13
+    if (!$decoded) {
14 14
         throw new RuntimeException('Unable to base64url_decode');
15 15
     }
16 16
 
Please login to merge, or discard this patch.
src/functions/check_server_response.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
  */
14 14
 function check_server_response(ResponseInterface $response, ?int $expectedCode = null): void
15 15
 {
16
-    if (! $expectedCode && $response->getStatusCode() >= 400) {
16
+    if (!$expectedCode && $response->getStatusCode() >= 400) {
17 17
         throw OAuth2Exception::fromResponse($response);
18 18
     }
19 19
 
Please login to merge, or discard this patch.