Skip to content

Commit 50de8b9

Browse files
committed
update phpDoc
1 parent c810030 commit 50de8b9

File tree

2 files changed

+44
-25
lines changed

2 files changed

+44
-25
lines changed

src/OAuth2Handler.php

+33-18
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace kamermans\OAuth2;
44

55
use GuzzleHttp\Exception\BadResponseException;
6-
use kamermans\OAuth2\GrantType\GrantTypeInterface;
7-
use kamermans\OAuth2\Utils\Helper;
86

97
/**
108
* OAuth2 plugin.
@@ -16,43 +14,43 @@ class OAuth2Handler
1614
/**
1715
* The grant type implementation used to acquire access tokens.
1816
*
19-
* @var GrantTypeInterface
17+
* @var GrantType\GrantTypeInterface
2018
*/
2119
protected $grantType;
2220

2321
/**
2422
* The grant type implementation used to refresh access tokens.
2523
*
26-
* @var GrantTypeInterface
24+
* @var GrantType\GrantTypeInterface
2725
*/
2826
protected $refreshTokenGrantType;
2927

3028
/**
3129
* The service in charge of including client credentials into requests.
3230
* to get an access token.
3331
*
34-
* @var AccessTokenSigner
32+
* @var Signer\ClientCredentials\SignerInterface
3533
*/
3634
protected $clientCredentialsSigner;
3735

3836
/**
3937
* The service in charge of including the access token into requests.
4038
*
41-
* @var AccessTokenSigner
39+
* @var Signer\AccessToken\SignerInterface
4240
*/
4341
protected $accessTokenSigner;
4442

4543
/**
4644
* The object including access token.
4745
*
48-
* @var TokenInterface
46+
* @var Token\TokenInterface
4947
*/
5048
protected $rawToken;
5149

5250
/**
5351
* The service in charge of persisting access token.
5452
*
55-
* @var TokenPersistenceInterface
53+
* @var Persistence\TokenPersistenceInterface
5654
*/
5755
protected $tokenPersistence;
5856

@@ -65,8 +63,17 @@ class OAuth2Handler
6563
protected $newTokenSupplier;
6664

6765
/**
68-
* @param GrantTypeInterface $grantType
69-
* @param GrantTypeInterface $refreshTokenGrantType
66+
* Factory responsible for parsing server token response
67+
*
68+
* @var callable
69+
*/
70+
protected $tokenFactory;
71+
72+
/**
73+
* @param GrantType\GrantTypeInterface $grantType
74+
* @param GrantType\GrantTypeInterface|null $refreshTokenGrantType
75+
* @param Signer\ClientCredentials\SignerInterface|null $clientCredentialsSigner
76+
* @param Signer\AccessToken\SignerInterface|null $accessTokenSigner
7077
*/
7178
public function __construct(
7279
GrantType\GrantTypeInterface $grantType,
@@ -94,6 +101,8 @@ public function __construct(
94101

95102
/**
96103
* @param Signer\ClientCredentials\SignerInterface $signer
104+
*
105+
* @return self
97106
*/
98107
public function setClientCredentialsSigner(Signer\ClientCredentials\SignerInterface $signer)
99108
{
@@ -103,7 +112,9 @@ public function setClientCredentialsSigner(Signer\ClientCredentials\SignerInterf
103112
}
104113

105114
/**
106-
* @param AccessToken\SignerInterface $signer
115+
* @param Signer\AccessToken\SignerInterface $signer
116+
*
117+
* @return self
107118
*/
108119
public function setAccessTokenSigner(Signer\AccessToken\SignerInterface $signer)
109120
{
@@ -114,6 +125,8 @@ public function setAccessTokenSigner(Signer\AccessToken\SignerInterface $signer)
114125

115126
/**
116127
* @param Persistence\TokenPersistenceInterface $tokenPersistence
128+
*
129+
* @return self
117130
*/
118131
public function setTokenPersistence(Persistence\TokenPersistenceInterface $tokenPersistence)
119132
{
@@ -124,6 +137,8 @@ public function setTokenPersistence(Persistence\TokenPersistenceInterface $token
124137

125138
/**
126139
* @param callable $tokenFactory
140+
*
141+
* @return self
127142
*/
128143
public function setTokenFactory(callable $tokenFactory)
129144
{
@@ -146,7 +161,9 @@ public function setNewTokenSupplier(callable $tokenSupplier) {
146161
/**
147162
* Manually set the access token.
148163
*
149-
* @param string|array|TokenInterface $token An array of token data, an access token string, or a TokenInterface object
164+
* @param string|array|Token\TokenInterface $token An array of token data, an access token string, or a TokenInterface object
165+
*
166+
* @return self
150167
*/
151168
public function setAccessToken($token)
152169
{
@@ -179,7 +196,7 @@ public function deleteAccessToken()
179196
*
180197
* @return string|null A valid access token or null if unable to get one
181198
*
182-
* @throws AccessTokenRequestException while trying to run `requestNewAccessToken` method
199+
* @throws Exception\AccessTokenRequestException while trying to run `requestNewAccessToken` method
183200
*/
184201
public function getAccessToken()
185202
{
@@ -207,7 +224,7 @@ public function getAccessToken()
207224
/**
208225
* Gets the current Token object
209226
*
210-
* @return Token\RawToken|null
227+
* @return Token\TokenInterface|null
211228
*/
212229
public function getRawToken()
213230
{
@@ -228,7 +245,7 @@ protected function signRequest($request)
228245
/**
229246
* Helper method for (callable)tokenFactory
230247
*
231-
* @return TokenInterface
248+
* @return Token\TokenInterface
232249
*/
233250
protected function tokenFactory()
234251
{
@@ -238,9 +255,7 @@ protected function tokenFactory()
238255
/**
239256
* Acquire a new access token from the server.
240257
*
241-
* @return TokenInterface|null
242-
*
243-
* @throws AccessTokenRequestException
258+
* @throws Exception\AccessTokenRequestException
244259
*/
245260
protected function requestNewAccessToken()
246261
{

src/OAuth2Middleware.php

+11-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ public function __invoke(callable $handler)
3737
}
3838

3939
/**
40-
* Request error event handler.
41-
*
42-
* Handles unauthorized errors by acquiring a new access token and
43-
* retrying the request.
44-
*
45-
* @param ErrorEvent $event Event received
46-
*/
40+
* Request error event handler.
41+
*
42+
* Handles unauthorized errors by acquiring a new access token and
43+
* retrying the request.
44+
*
45+
* @param \Psr\Http\Message\RequestInterface $request
46+
* @param array $options
47+
* @param callable $handler
48+
*
49+
* @return callable
50+
*/
4751
private function onFulfilled(RequestInterface $request, array $options, $handler)
4852
{
4953
return function ($response) use ($request, $options, $handler) {

0 commit comments

Comments
 (0)