Skip to content

Commit 5c99d66

Browse files
committed
Upgrade to PHPStan 1.2.0
1 parent ffde5ec commit 5c99d66

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"require-dev": {
2424
"phpunit/phpunit": "^9.5",
25-
"phpstan/phpstan": "^0.12",
25+
"phpstan/phpstan": "^1.2.0",
2626
"squizlabs/php_codesniffer": "^3.6",
2727
"phpspec/prophecy-phpunit": "^2.0"
2828
}

src/Client.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,20 @@ public function verify(string $token): string
176176
throw new \Exception(sprintf('Token is missing claims: %s', implode(', ', $missing)));
177177
}
178178

179-
// Consume the nonce.
180179
$nonce = $claims->get('nonce');
181180
$email = $claims->get('email');
182181
$emailOriginal = $claims->get('email_original', $email);
182+
if (!is_string($nonce)) {
183+
throw new \Exception(sprintf('Token claim "nonce" is not a string'));
184+
}
185+
if (!is_string($email)) {
186+
throw new \Exception(sprintf('Token claim "email" is not a string'));
187+
}
188+
if (!is_string($emailOriginal)) {
189+
throw new \Exception(sprintf('Token claim "email_original" is not a string'));
190+
}
191+
192+
// Consume the nonce.
183193
$this->store->consumeNonce($nonce, $emailOriginal);
184194

185195
// Return the normalized email.

src/RedisStore.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public function fetchCached(string $cacheId, string $url): \stdClass
2929

3030
$data = $this->redis->get($key);
3131
if ($data) {
32-
return json_decode($data);
32+
$data = json_decode($data);
33+
assert($data instanceof \stdClass);
34+
35+
return $data;
3336
}
3437

3538
$res = $this->fetch($url);

0 commit comments

Comments
 (0)