Skip to content

Commit

Permalink
add (return) type hints to overriden methods (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertMe authored Nov 27, 2023
1 parent a90e4ba commit ea20f8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/Grant/AuthCodeGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ public function __construct(
}
}

public function getIdentifier()
public function getIdentifier(): string
{
return 'authorization_code_oidc';
}

/**
* {@inheritdoc}
*/
public function canRespondToAuthorizationRequest(ServerRequestInterface $request)
public function canRespondToAuthorizationRequest(ServerRequestInterface $request): bool
{
$result = parent::canRespondToAuthorizationRequest($request);

Expand All @@ -84,7 +84,7 @@ public function canRespondToAuthorizationRequest(ServerRequestInterface $request
return $result;
}

public function canRespondToAccessTokenRequest(ServerRequestInterface $request)
public function canRespondToAccessTokenRequest(ServerRequestInterface $request): bool
{
$requestParameters = (array) $request->getParsedBody();

Expand Down Expand Up @@ -112,7 +112,7 @@ public function canRespondToAccessTokenRequest(ServerRequestInterface $request)
/**
* {@inheritdoc}
*/
public function validateAuthorizationRequest(ServerRequestInterface $request)
public function validateAuthorizationRequest(ServerRequestInterface $request): AuthorizationRequest
{
$result = parent::validateAuthorizationRequest($request);

Expand Down Expand Up @@ -172,7 +172,7 @@ public function respondToAccessTokenRequest(
ServerRequestInterface $request,
ResponseTypeInterface $responseType,
\DateInterval $accessTokenTTL
) {
): ResponseTypeInterface {
/**
* @var BearerTokenResponse $result
*/
Expand Down Expand Up @@ -238,7 +238,7 @@ protected function makeIdTokenInstance()
/**
* {@inheritdoc}
*/
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest)
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest): ResponseTypeInterface
{
if (!($authorizationRequest instanceof AuthenticationRequest)) {
throw OAuthServerException::invalidRequest('not possible');
Expand Down
9 changes: 5 additions & 4 deletions src/Grant/ImplicitGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
use League\OAuth2\Server\ResponseTypes\RedirectResponse;
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface;
use Psr\Http\Message\ServerRequestInterface;

class ImplicitGrant extends \League\OAuth2\Server\Grant\ImplicitGrant
Expand Down Expand Up @@ -64,12 +65,12 @@ public function __construct(
$this->queryDelimiter = $queryDelimiter;
}

public function getIdentifier()
public function getIdentifier(): string
{
return 'implicit_oidc';
}

public function canRespondToAuthorizationRequest(ServerRequestInterface $request)
public function canRespondToAuthorizationRequest(ServerRequestInterface $request): bool
{
$result = (isset($request->getQueryParams()['response_type'])
&& (
Expand All @@ -85,7 +86,7 @@ public function canRespondToAuthorizationRequest(ServerRequestInterface $request
return $result && ($scopes && in_array('openid', explode(' ', $scopes)));
}

public function validateAuthorizationRequest(ServerRequestInterface $request)
public function validateAuthorizationRequest(ServerRequestInterface $request): AuthorizationRequest
{
$result = parent::validateAuthorizationRequest($request);

Expand Down Expand Up @@ -142,7 +143,7 @@ public function validateAuthorizationRequest(ServerRequestInterface $request)
return $result;
}

public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest)
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest): ResponseTypeInterface
{
if (!($authorizationRequest instanceof AuthenticationRequest)) {
throw OAuthServerException::invalidRequest('not possible');
Expand Down
2 changes: 1 addition & 1 deletion src/ResponseTypes/BearerTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getAccessToken()
return $this->accessToken;
}

protected function getExtraParams(AccessTokenEntityInterface $accessToken)
protected function getExtraParams(AccessTokenEntityInterface $accessToken): array
{
/*
The Claims requested by the profile, email, address, and phone scope values
Expand Down

0 comments on commit ea20f8f

Please sign in to comment.