Skip to content

Commit 49331d2

Browse files
committed
Again fix more Psalm errors
1 parent a0f32dc commit 49331d2

File tree

8 files changed

+28
-6
lines changed

8 files changed

+28
-6
lines changed

src/GrantType/PasswordGrantType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function __construct(
5555
*
5656
* @throws TransportExceptionInterface
5757
*/
58+
#[\Override]
5859
public function getTokens(): Tokens
5960
{
6061
$parameters = [

src/GrantType/RefreshTokenGrantType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* Implementation of the OAuth refresh token grant type.
1212
*/
13-
class RefreshTokenGrantType implements GrantTypeInterface
13+
final class RefreshTokenGrantType implements GrantTypeInterface
1414
{
1515
use TokensExtractor;
1616

@@ -50,6 +50,7 @@ public function __construct(
5050
*
5151
* @throws TransportExceptionInterface
5252
*/
53+
#[\Override]
5354
public function getTokens(): Tokens
5455
{
5556
$response = $this->client->request('POST', $this->tokenUrl, [

src/GrantType/Tokens.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Value object for an access token and a refresh token.
99
*/
10-
class Tokens
10+
final class Tokens
1111
{
1212
private string $accessToken;
1313

src/OAuthHttpClient.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,37 @@ public function __construct(
4040
$this->cache = new MemoryTokensCache();
4141
}
4242

43+
/**
44+
* @psalm-api
45+
*/
4346
public function setSigner(RequestSignerInterface $signer): self
4447
{
4548
$this->signer = $signer;
4649

4750
return $this;
4851
}
4952

53+
/**
54+
* @psalm-api
55+
*/
5056
public function setChecker(ResponseCheckerInterface $checker): self
5157
{
5258
$this->checker = $checker;
5359

5460
return $this;
5561
}
5662

63+
/**
64+
* @psalm-api
65+
*/
5766
public function setCache(TokensCacheInterface $cache): self
5867
{
5968
$this->cache = $cache;
6069

6170
return $this;
6271
}
6372

73+
#[\Override]
6474
public function request(string $method, string $url, array $options = []): ResponseInterface
6575
{
6676
$grant = $this->grant;
@@ -84,11 +94,13 @@ public function request(string $method, string $url, array $options = []): Respo
8494
throw new RuntimeException();
8595
}
8696

97+
#[\Override]
8798
public function stream($responses, ?float $timeout = null): ResponseStreamInterface
8899
{
89100
return $this->client->stream($responses, $timeout);
90101
}
91102

103+
#[\Override]
92104
public function withOptions(array $options): static
93105
{
94106
return new self($this->client->withOptions($options), $this->grant);

src/RequestSigner/BearerHeaderRequestSigner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace BenjaminFavre\OAuthHttpClient\RequestSigner;
66

7-
class BearerHeaderRequestSigner extends HeaderRequestSigner
7+
final class BearerHeaderRequestSigner extends HeaderRequestSigner
88
{
99
public function __construct()
1010
{

src/ResponseChecker/StatusCode401ResponseChecker.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
use Symfony\Contracts\HttpClient\ResponseInterface;
88

9-
class StatusCode401ResponseChecker implements ResponseCheckerInterface
9+
final class StatusCode401ResponseChecker implements ResponseCheckerInterface
1010
{
11+
#[\Override]
1112
public function hasAuthenticationFailed(ResponseInterface $response): bool
1213
{
1314
return $response->getStatusCode() === 401;

src/TokensCache/MemoryTokensCache.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
use BenjaminFavre\OAuthHttpClient\GrantType\GrantTypeInterface;
88
use BenjaminFavre\OAuthHttpClient\GrantType\Tokens;
99

10-
class MemoryTokensCache implements TokensCacheInterface
10+
final class MemoryTokensCache implements TokensCacheInterface
1111
{
1212
private ?Tokens $tokens = null;
1313

14+
#[\Override]
1415
public function get(GrantTypeInterface $grant): Tokens
1516
{
1617
if ($this->tokens === null) {
@@ -20,6 +21,7 @@ public function get(GrantTypeInterface $grant): Tokens
2021
return $this->tokens;
2122
}
2223

24+
#[\Override]
2325
public function clear(): void
2426
{
2527
$this->tokens = null;

src/TokensCache/SymfonyTokensCacheAdapter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
use RuntimeException;
1010
use Symfony\Contracts\Cache\CacheInterface;
1111

12-
class SymfonyTokensCacheAdapter implements TokensCacheInterface
12+
/**
13+
* @psalm-api
14+
*/
15+
final class SymfonyTokensCacheAdapter implements TokensCacheInterface
1316
{
1417
private CacheInterface $cache;
1518

@@ -21,6 +24,7 @@ public function __construct(CacheInterface $cache, string $cacheKey)
2124
$this->cacheKey = $cacheKey;
2225
}
2326

27+
#[\Override]
2428
public function get(GrantTypeInterface $grant): Tokens
2529
{
2630
$tokens = $this->cache->get($this->cacheKey, function () use ($grant) {
@@ -34,6 +38,7 @@ public function get(GrantTypeInterface $grant): Tokens
3438
return $tokens;
3539
}
3640

41+
#[\Override]
3742
public function clear(): void
3843
{
3944
$this->cache->delete($this->cacheKey);

0 commit comments

Comments
 (0)