From b2c0933ee672e1b86aea5be5455f4faa30c8db74 Mon Sep 17 00:00:00 2001 From: Brooke Bryan Date: Wed, 12 Nov 2014 18:10:29 +0000 Subject: [PATCH] Docbloc improvements --- src/AbstractServer.php | 4 ++-- src/AuthorizationServer.php | 11 ++++++---- src/Entity/AbstractTokenEntity.php | 2 +- src/Entity/AccessTokenEntity.php | 2 +- src/Entity/AuthCodeEntity.php | 2 +- src/Entity/EntityTrait.php | 1 + src/Entity/RefreshTokenEntity.php | 6 +++--- src/Entity/SessionEntity.php | 2 +- src/Event/ClientAuthenticationFailedEvent.php | 2 +- src/Event/UserAuthenticationFailedEvent.php | 2 +- src/Exception/OAuthException.php | 1 + src/Grant/AbstractGrant.php | 1 + src/Grant/AuthCodeGrant.php | 8 +++++--- src/Grant/ClientCredentialsGrant.php | 3 ++- src/Grant/PasswordGrant.php | 2 ++ src/Grant/RefreshTokenGrant.php | 1 - src/ResourceServer.php | 20 +++++++++++-------- src/Storage/AbstractStorage.php | 1 + src/Storage/AccessTokenInterface.php | 2 +- src/Storage/ClientInterface.php | 2 +- src/Storage/SessionInterface.php | 2 +- src/TokenType/AbstractTokenType.php | 2 ++ 22 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/AbstractServer.php b/src/AbstractServer.php index 220fffc4..d3b7e661 100644 --- a/src/AbstractServer.php +++ b/src/AbstractServer.php @@ -188,7 +188,7 @@ abstract class AbstractServer /** * Set the refresh token storage - * @param \League\OAuth2\Server\Storage\RefreshTokenInteface $storage + * @param \League\OAuth2\Server\Storage\RefreshTokenInterface $storage * @return self */ public function setRefreshTokenStorage(RefreshTokenInterface $storage) @@ -201,7 +201,7 @@ abstract class AbstractServer /** * Set the auth code storage - * @param \League\OAuth2\Server\Storage\AuthCodeInterface $authCode + * @param \League\OAuth2\Server\Storage\AuthCodeInterface $storage * @return self */ public function setAuthCodeStorage(AuthCodeInterface $storage) diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index 645df543..a7a1dd7d 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -144,7 +144,7 @@ class AuthorizationServer extends AbstractServer /** * Default scope to be used if none is provided and requireScopeParam() is false * @param string $default Name of the default scope - * @param self + * @return self */ public function setDefaultScope($default = null) { @@ -164,8 +164,7 @@ class AuthorizationServer extends AbstractServer /** * Require the "state" paremter in checkAuthoriseParams() - * @param boolean $require - * @return void + * @return bool */ public function stateParamRequired() { @@ -175,7 +174,7 @@ class AuthorizationServer extends AbstractServer /** * Require the "state" paremter in checkAuthoriseParams() * @param boolean $require - * @return void + * @return self */ public function requireStateParam($require = true) { @@ -196,6 +195,7 @@ class AuthorizationServer extends AbstractServer /** * Set the scope delimiter * @param string $scopeDelimeter + * @return self */ public function setScopeDelimeter($scopeDelimeter = ' ') { @@ -216,6 +216,7 @@ class AuthorizationServer extends AbstractServer /** * Set the TTL for an access token * @param int $accessTokenTTL The new TTL + * @return self */ public function setAccessTokenTTL($accessTokenTTL = 3600) { @@ -227,6 +228,7 @@ class AuthorizationServer extends AbstractServer /** * Issue an access token * @return array Authorise request parameters + * @throws */ public function issueAccessToken() { @@ -248,6 +250,7 @@ class AuthorizationServer extends AbstractServer * Return a grant type class * @param string $grantType The grant type identifer * @return Grant\GrantTypeInterface + * @throws */ public function getGrantType($grantType) { diff --git a/src/Entity/AbstractTokenEntity.php b/src/Entity/AbstractTokenEntity.php index 37ed0951..95405707 100644 --- a/src/Entity/AbstractTokenEntity.php +++ b/src/Entity/AbstractTokenEntity.php @@ -105,7 +105,7 @@ abstract class AbstractTokenEntity /** * Set token ID - * @param string $token Token ID + * @param string $id Token ID * @return self */ public function setId($id = null) diff --git a/src/Entity/AccessTokenEntity.php b/src/Entity/AccessTokenEntity.php index 512a3f84..12208687 100644 --- a/src/Entity/AccessTokenEntity.php +++ b/src/Entity/AccessTokenEntity.php @@ -47,7 +47,7 @@ class AccessTokenEntity extends AbstractTokenEntity /** * Return all scopes associated with the access token - * @return \League\OAuth2\Server\Entity\Scope[] + * @return \League\OAuth2\Server\Entity\ScopeEntity[] */ public function getScopes() { diff --git a/src/Entity/AuthCodeEntity.php b/src/Entity/AuthCodeEntity.php index 52f87316..954e22ff 100644 --- a/src/Entity/AuthCodeEntity.php +++ b/src/Entity/AuthCodeEntity.php @@ -77,7 +77,7 @@ class AuthCodeEntity extends AbstractTokenEntity /** * Return all scopes associated with the session - * @return \League\OAuth2\Server\Entity\Scope[] + * @return \League\OAuth2\Server\Entity\ScopeEntity[] */ public function getScopes() { diff --git a/src/Entity/EntityTrait.php b/src/Entity/EntityTrait.php index a71f3bc5..354745ff 100644 --- a/src/Entity/EntityTrait.php +++ b/src/Entity/EntityTrait.php @@ -16,6 +16,7 @@ trait EntityTrait /** * Hydrate an entity with properites * @param array $properties + * @return self */ public function hydrate(array $properties) { diff --git a/src/Entity/RefreshTokenEntity.php b/src/Entity/RefreshTokenEntity.php index 2f53d254..143c93c5 100644 --- a/src/Entity/RefreshTokenEntity.php +++ b/src/Entity/RefreshTokenEntity.php @@ -30,7 +30,7 @@ class RefreshTokenEntity extends AbstractTokenEntity /** * Set the ID of the associated access token - * @param string $accessToken + * @param string $accessTokenId * @return self */ public function setAccessTokenId($accessTokenId) @@ -42,7 +42,7 @@ class RefreshTokenEntity extends AbstractTokenEntity /** * Associate an access token - * @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken + * @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessTokenEntity * @return self */ public function setAccessToken(AccessTokenEntity $accessTokenEntity) @@ -54,7 +54,7 @@ class RefreshTokenEntity extends AbstractTokenEntity /** * Return access token - * @return AccessToken + * @return AccessTokenEntity */ public function getAccessToken() { diff --git a/src/Entity/SessionEntity.php b/src/Entity/SessionEntity.php index f745223b..e16e6ba3 100644 --- a/src/Entity/SessionEntity.php +++ b/src/Entity/SessionEntity.php @@ -137,7 +137,7 @@ class SessionEntity /** * Return all scopes associated with the session - * @return \League\OAuth2\Server\Entity\Scope[] + * @return \League\OAuth2\Server\Entity\ScopeEntity[] */ public function getScopes() { diff --git a/src/Event/ClientAuthenticationFailedEvent.php b/src/Event/ClientAuthenticationFailedEvent.php index d6605370..917dd68d 100644 --- a/src/Event/ClientAuthenticationFailedEvent.php +++ b/src/Event/ClientAuthenticationFailedEvent.php @@ -24,7 +24,7 @@ class ClientAuthenticationFailedEvent extends AbstractEvent /** * Init the event with a request - * @param \Symfony\Component\HttpFoundation\Requesty $request + * @param \Symfony\Component\HttpFoundation\Request $request */ public function __construct(Request $request) { diff --git a/src/Event/UserAuthenticationFailedEvent.php b/src/Event/UserAuthenticationFailedEvent.php index 0b2cb365..ae011411 100644 --- a/src/Event/UserAuthenticationFailedEvent.php +++ b/src/Event/UserAuthenticationFailedEvent.php @@ -24,7 +24,7 @@ class UserAuthenticationFailedEvent extends AbstractEvent /** * Init the event with a request - * @param \Symfony\Component\HttpFoundation\Requesty $request + * @param \Symfony\Component\HttpFoundation\Request $request */ public function __construct(Request $request) { diff --git a/src/Exception/OAuthException.php b/src/Exception/OAuthException.php index 229ac1ab..84a534db 100644 --- a/src/Exception/OAuthException.php +++ b/src/Exception/OAuthException.php @@ -36,6 +36,7 @@ class OAuthException extends \Exception /** * Throw a new exception + * @param string $msg Exception Message */ public function __construct($msg = 'An error occured') { diff --git a/src/Grant/AbstractGrant.php b/src/Grant/AbstractGrant.php index 4ec2b6ed..522115b2 100644 --- a/src/Grant/AbstractGrant.php +++ b/src/Grant/AbstractGrant.php @@ -125,6 +125,7 @@ abstract class AbstractGrant implements GrantTypeInterface * @param string|null $redirectUri The redirect URI to return the user to * @return \League\OAuth2\Server\Entity\ScopeEntity[] * @throws \League\OAuth2\Server\Exception\InvalidScopeException If scope is invalid, or no scopes passed when required + * @throws */ public function validateScopes($scopeParam = '', ClientEntity $client, $redirectUri = null) { diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index 48ea6a41..60582d2b 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -18,7 +18,6 @@ use League\OAuth2\Server\Entity\RefreshTokenEntity; use League\OAuth2\Server\Entity\SessionEntity; use League\OAuth2\Server\Event; use League\OAuth2\Server\Exception; -use League\OAuth2\Server\Request; use League\OAuth2\Server\Util\SecureKey; /** @@ -40,7 +39,7 @@ class AuthCodeGrant extends AbstractGrant /** * AuthServer instance - * @var AuthServer + * @var \League\OAuth2\Server\AuthorizationServer */ protected $server = null; @@ -70,6 +69,8 @@ class AuthCodeGrant extends AbstractGrant * Check authorize parameters * * @return array Authorize request parameters + * + * @throws */ public function checkAuthorizeParams() { @@ -160,6 +161,7 @@ class AuthCodeGrant extends AbstractGrant /** * Complete the auth code grant * @return array + * @throws */ public function completeFlow() { @@ -257,7 +259,7 @@ class AuthCodeGrant extends AbstractGrant $accessToken->setSession($session); $accessToken->save(); - if ($this->server->hasGrantType('refresh_token')) { + if ($refreshToken && $this->server->hasGrantType('refresh_token')) { $refreshToken->setAccessToken($accessToken); $refreshToken->save(); } diff --git a/src/Grant/ClientCredentialsGrant.php b/src/Grant/ClientCredentialsGrant.php index 40f6f051..6e937103 100644 --- a/src/Grant/ClientCredentialsGrant.php +++ b/src/Grant/ClientCredentialsGrant.php @@ -37,7 +37,7 @@ class ClientCredentialsGrant extends AbstractGrant /** * AuthServer instance - * @var AuthServer + * @var \League\OAuth2\Server\AuthorizationServer */ protected $server = null; @@ -50,6 +50,7 @@ class ClientCredentialsGrant extends AbstractGrant /** * Complete the client credentials grant * @return array + * @throws */ public function completeFlow() { diff --git a/src/Grant/PasswordGrant.php b/src/Grant/PasswordGrant.php index db222dfb..496d3ace 100644 --- a/src/Grant/PasswordGrant.php +++ b/src/Grant/PasswordGrant.php @@ -61,6 +61,7 @@ class PasswordGrant extends AbstractGrant /** * Return the callback function * @return callable + * @throws */ protected function getVerifyCredentialsCallback() { @@ -74,6 +75,7 @@ class PasswordGrant extends AbstractGrant /** * Complete the password grant * @return array + * @throws */ public function completeFlow() { diff --git a/src/Grant/RefreshTokenGrant.php b/src/Grant/RefreshTokenGrant.php index 1c5a0e5f..a5e23385 100644 --- a/src/Grant/RefreshTokenGrant.php +++ b/src/Grant/RefreshTokenGrant.php @@ -16,7 +16,6 @@ use League\OAuth2\Server\Entity\ClientEntity; use League\OAuth2\Server\Entity\RefreshTokenEntity; use League\OAuth2\Server\Event; use League\OAuth2\Server\Exception; -use League\OAuth2\Server\Request; use League\OAuth2\Server\Util\SecureKey; /** diff --git a/src/ResourceServer.php b/src/ResourceServer.php index 5bc1eaea..c24c2e7e 100644 --- a/src/ResourceServer.php +++ b/src/ResourceServer.php @@ -38,10 +38,10 @@ class ResourceServer extends AbstractServer /** * Initialise the resource server - * @param SessionInterface $sessionStorage - * @param AccessTokenInteface $accessTokenStorage - * @param ClientInterface $clientStorage - * @param ScopeInterface $scopeStorage + * @param SessionInterface $sessionStorage + * @param AccessTokenInterface $accessTokenStorage + * @param ClientInterface $clientStorage + * @param ScopeInterface $scopeStorage * @return self */ public function __construct( @@ -65,7 +65,7 @@ class ResourceServer extends AbstractServer /** * Sets the query string key for the access token. - * @param $key The new query string key + * @param string $key The new query string key * @return self */ public function setIdKey($key) @@ -86,8 +86,12 @@ class ResourceServer extends AbstractServer /** * Checks if the access token is valid or not - * @param $headersOnly Limit Access Token to Authorization header only + * @param bool $headersOnly Limit Access Token to Authorization header only + * @param AccessTokenEntity|null $accessToken Access Token + * * @return bool + * + * @throws */ public function isValidRequest($headersOnly = true, $accessToken = null) { @@ -114,8 +118,8 @@ class ResourceServer extends AbstractServer /** * Reads in the access token from the headers - * @param $headersOnly Limit Access Token to Authorization header only - * @throws Exception\MissingAccessTokenException Thrown if there is no access token presented + * @param bool $headersOnly Limit Access Token to Authorization header only + * @throws Exception\InvalidRequestException Thrown if there is no access token presented * @return string */ public function determineAccessToken($headersOnly = false) diff --git a/src/Storage/AbstractStorage.php b/src/Storage/AbstractStorage.php index b932e5a0..41dc88a6 100644 --- a/src/Storage/AbstractStorage.php +++ b/src/Storage/AbstractStorage.php @@ -27,6 +27,7 @@ abstract class AbstractStorage implements StorageInterface /** * Set the server * @param \League\OAuth2\Server\AbstractServer $server + * @return self */ public function setServer(AbstractServer $server) { diff --git a/src/Storage/AccessTokenInterface.php b/src/Storage/AccessTokenInterface.php index ca172abe..dc98b6d6 100644 --- a/src/Storage/AccessTokenInterface.php +++ b/src/Storage/AccessTokenInterface.php @@ -39,7 +39,7 @@ interface AccessTokenInterface extends StorageInterface * @param string $token The access token * @param integer $expireTime The expire time expressed as a unix timestamp * @param string|integer $sessionId The session ID - * @return \League\OAuth2\Server\Entity\AccessToken + * @return \League\OAuth2\Server\Entity\AccessTokenEntity */ public function create($token, $expireTime, $sessionId); diff --git a/src/Storage/ClientInterface.php b/src/Storage/ClientInterface.php index 44f7b11a..4da715dc 100644 --- a/src/Storage/ClientInterface.php +++ b/src/Storage/ClientInterface.php @@ -24,7 +24,7 @@ interface ClientInterface extends StorageInterface * @param string $clientSecret The client's secret (default = "null") * @param string $redirectUri The client's redirect URI (default = "null") * @param string $grantType The grant type used (default = "null") - * @return League\OAuth2\Server\Entity\ClientEntity + * @return \League\OAuth2\Server\Entity\ClientEntity */ public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null); diff --git a/src/Storage/SessionInterface.php b/src/Storage/SessionInterface.php index a4ae0437..130a3ce4 100644 --- a/src/Storage/SessionInterface.php +++ b/src/Storage/SessionInterface.php @@ -54,7 +54,7 @@ interface SessionInterface extends StorageInterface /** * Associate a scope with a session - * @param \League\OAuth2\Server\Entity\SessionEntity $scope The scope + * @param \League\OAuth2\Server\Entity\SessionEntity $session The session * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope * @return void */ diff --git a/src/TokenType/AbstractTokenType.php b/src/TokenType/AbstractTokenType.php index e530b445..7a0e0f5a 100644 --- a/src/TokenType/AbstractTokenType.php +++ b/src/TokenType/AbstractTokenType.php @@ -38,6 +38,7 @@ abstract class AbstractTokenType /** * Set the server * @param \League\OAuth2\Server\AbstractServer $server + * @return self */ public function setServer(AbstractServer $server) { @@ -49,6 +50,7 @@ abstract class AbstractTokenType /** * Set the session entity * @param \League\OAuth2\Server\Entity\SessionEntity $session + * @return self */ public function setSession(SessionEntity $session) {