Skip to content

Commit

Permalink
fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Klapaudius committed Jan 13, 2022
1 parent 1c4691c commit 571a174
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Model/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AuthCode extends Token implements AuthCodeInterface
/**
* @var string
*/
protected $redirectUri;
protected string $redirectUri;

/**
* {@inheritdoc}
Expand All @@ -34,7 +34,7 @@ public function setRedirectUri($redirectUri)
/**
* {@inheritdoc}
*/
public function getRedirectUri()
public function getRedirectUri(): string
{
return $this->redirectUri;
}
Expand Down
16 changes: 8 additions & 8 deletions Model/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ class Token implements TokenInterface
/**
* @var int
*/
protected $expiresAt;
protected int $expiresAt;

/**
* @var string
* @var string|null
*/
protected $scope;
protected ?string $scope = null;

/**
* @var UserInterface
*/
protected $user;
protected ?UserInterface $user = null;

public function getId()
{
Expand All @@ -63,7 +63,7 @@ public function getClientId(): string
/**
* {@inheritdoc}
*/
public function setExpiresAt($timestamp)
public function setExpiresAt( int $timestamp)
{
$this->expiresAt = $timestamp;
}
Expand Down Expand Up @@ -103,7 +103,7 @@ public function hasExpired(): bool
/**
* {@inheritdoc}
*/
public function setToken($token)
public function setToken(string $token)
{
$this->token = $token;
}
Expand All @@ -119,7 +119,7 @@ public function getToken(): string
/**
* {@inheritdoc}
*/
public function setScope($scope)
public function setScope(?string $scope)
{
$this->scope = $scope;
}
Expand All @@ -135,7 +135,7 @@ public function getScope(): ?string
/**
* {@inheritdoc}
*/
public function setUser(UserInterface $user)
public function setUser(?UserInterface $user)
{
$this->user = $user;
}
Expand Down
2 changes: 1 addition & 1 deletion Model/TokenInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

interface TokenInterface extends IOAuth2Token
{
public function setExpiresAt($timestamp);
public function setExpiresAt(int $timestamp);

public function getExpiresAt(): int;

Expand Down
2 changes: 1 addition & 1 deletion Security/EntryPoint/OAuthEntryPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(OAuth2 $serverService)
$this->serverService = $serverService;
}

public function start(Request $request, AuthenticationException $authException = null)
public function start(Request $request, AuthenticationException $authException = null): Response
{
$exception = new OAuth2AuthenticateException(
Response::HTTP_UNAUTHORIZED,
Expand Down
30 changes: 17 additions & 13 deletions Storage/OAuthStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,37 @@ class OAuthStorage implements IOAuth2RefreshTokens, IOAuth2GrantUser, IOAuth2Gra
/**
* @var ClientManagerInterface
*/
protected $clientManager;
protected ClientManagerInterface $clientManager;

/**
* @var AccessTokenManagerInterface
*/
protected $accessTokenManager;
protected AccessTokenManagerInterface $accessTokenManager;

/**
* @var RefreshTokenManagerInterface
*/
protected $refreshTokenManager;
protected RefreshTokenManagerInterface $refreshTokenManager;

/**
* @var AuthCodeManagerInterface;
*/
protected $authCodeManager;
protected AuthCodeManagerInterface $authCodeManager;

/**
* @var UserProviderInterface
*/
protected $userProvider;
protected UserProviderInterface $userProvider;

/**
* @var PasswordHasherFactoryInterface
*/
protected $passwordHasherFactory;
protected PasswordHasherFactoryInterface $passwordHasherFactory;

/**
* @var array [uri] => GrantExtensionInterface
*/
protected $grantExtensions;
protected array $grantExtensions = [];

public function __construct(
ClientManagerInterface $clientManager,
Expand All @@ -86,8 +86,6 @@ public function __construct(
$this->authCodeManager = $authCodeManager;
$this->userProvider = $userProvider;
$this->passwordHasherFactory = $passwordHasherFactory;

$this->grantExtensions = [];
}

/**
Expand All @@ -103,7 +101,7 @@ public function getClient($clientId): ?ClientInterface
return $this->clientManager->findClientByPublicId($clientId);
}

public function checkClientCredentials(IOAuth2Client $client, $client_secret = null)
public function checkClientCredentials(IOAuth2Client $client, $client_secret = null): bool
{
if (!$client instanceof ClientInterface) {
throw new \InvalidArgumentException('Client has to implement the ClientInterface');
Expand All @@ -112,7 +110,7 @@ public function checkClientCredentials(IOAuth2Client $client, $client_secret = n
return $client->checkSecret($client_secret);
}

public function checkClientCredentialsGrant(IOAuth2Client $client, $client_secret)
public function checkClientCredentialsGrant(IOAuth2Client $client, $client_secret): bool
{
return $this->checkClientCredentials($client, $client_secret);
}
Expand Down Expand Up @@ -143,7 +141,7 @@ public function createAccessToken($tokenString, IOAuth2Client $client, $data, $e
return $token;
}

public function checkRestrictedGrantType(IOAuth2Client $client, $grant_type)
public function checkRestrictedGrantType(IOAuth2Client $client, $grant_type): bool
{
if (!$client instanceof ClientInterface) {
throw new \InvalidArgumentException('Client has to implement the ClientInterface');
Expand All @@ -152,6 +150,12 @@ public function checkRestrictedGrantType(IOAuth2Client $client, $grant_type)
return in_array($grant_type, $client->getAllowedGrantTypes(), true);
}

/**
* @param IOAuth2Client $client
* @param $username
* @param $password
* @return array|false
*/
public function checkUserCredentials(IOAuth2Client $client, $username, $password)
{
if (!$client instanceof ClientInterface) {
Expand Down Expand Up @@ -250,7 +254,7 @@ public function unsetRefreshToken($tokenString)
/**
* {@inheritdoc}
*/
public function checkGrantExtension(IOAuth2Client $client, $uri, array $inputData, array $authHeaders)
public function checkGrantExtension(IOAuth2Client $client, $uri, array $inputData, array $authHeaders): bool
{
if (!isset($this->grantExtensions[$uri])) {
throw new OAuth2ServerException(Response::HTTP_BAD_REQUEST, OAuth2::ERROR_UNSUPPORTED_GRANT_TYPE);
Expand Down

0 comments on commit 571a174

Please sign in to comment.