From b82551c97dcb22e2b9e50b953929f65d7bbfffb0 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 3 May 2014 11:08:33 +0100 Subject: [PATCH] PHPCS fixes --- src/AuthorizationServer.php | 4 ++-- src/Exception/InvalidGrantException.php | 8 +++++++- src/Exception/InvalidRequestException.php | 8 +++++++- src/Exception/InvalidScopeException.php | 7 ++++++- src/Exception/ServerErrorException.php | 6 ++++-- src/Exception/UnsupportedGrantTypeException.php | 7 ++++++- src/Grant/AbstractGrant.php | 11 ++++++----- src/Grant/PasswordGrant.php | 1 - src/ResourceServer.php | 4 +++- src/Storage/ClientInterface.php | 2 +- 10 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index b04462c3..eddfe6f0 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -174,7 +174,7 @@ class AuthorizationServer extends AbstractServer $this->grantTypes[$identifier] = $grantType; - if ( ! is_null($grantType->getResponseType())) { + if (!is_null($grantType->getResponseType())) { $this->responseTypes[] = $grantType->getResponseType(); } @@ -316,7 +316,7 @@ class AuthorizationServer extends AbstractServer } // Ensure grant type is one that is recognised and is enabled - if ( ! in_array($grantType, array_keys($this->grantTypes))) { + if (!in_array($grantType, array_keys($this->grantTypes))) { throw new Exception\UnsupportedGrantTypeException($grantType); } diff --git a/src/Exception/InvalidGrantException.php b/src/Exception/InvalidGrantException.php index 1fde9dee..3b9f5d79 100644 --- a/src/Exception/InvalidGrantException.php +++ b/src/Exception/InvalidGrantException.php @@ -32,6 +32,12 @@ class InvalidGrantException extends OAuthException public function __construct($parameter) { - parent::__construct(sprintf('The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client. Check the "%s" parameter.', $parameter)); + parent::__construct( + sprintf( + 'The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used + in the authorization request, or was issued to another client. Check the "%s" parameter.', + $parameter + ) + ); } } diff --git a/src/Exception/InvalidRequestException.php b/src/Exception/InvalidRequestException.php index b42a90fa..d47d6fb4 100644 --- a/src/Exception/InvalidRequestException.php +++ b/src/Exception/InvalidRequestException.php @@ -32,6 +32,12 @@ class InvalidRequestException extends OAuthException public function __construct($parameter) { - parent::__construct(sprintf('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "%s" parameter.', $parameter)); + parent::__construct( + sprintf( + 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter + more than once, or is otherwise malformed. Check the "%s" parameter.', + $parameter + ) + ); } } diff --git a/src/Exception/InvalidScopeException.php b/src/Exception/InvalidScopeException.php index 613ed6c6..eb74213d 100644 --- a/src/Exception/InvalidScopeException.php +++ b/src/Exception/InvalidScopeException.php @@ -32,6 +32,11 @@ class InvalidScopeException extends OAuthException public function __construct($parameter) { - parent::__construct(sprintf('The requested scope is invalid, unknown, or malformed. Check the "%s" scope.', $parameter)); + parent::__construct( + sprintf( + 'The requested scope is invalid, unknown, or malformed. Check the "%s" scope.', + $parameter + ) + ); } } diff --git a/src/Exception/ServerErrorException.php b/src/Exception/ServerErrorException.php index 13a7cd63..e524c520 100644 --- a/src/Exception/ServerErrorException.php +++ b/src/Exception/ServerErrorException.php @@ -29,8 +29,10 @@ class ServerErrorException extends OAuthException /** * {@inheritdoc} */ - public function __construct($parameter = 'The authorization server encountered an unexpected condition which prevented it from fulfilling the request.') - { + public function __construct( + $parameter = 'The authorization server encountered an unexpected condition which prevented it from fulfilling' + . 'the request.' + ) { parent::__construct($parameter); } } diff --git a/src/Exception/UnsupportedGrantTypeException.php b/src/Exception/UnsupportedGrantTypeException.php index c79aa367..5a4f1d90 100644 --- a/src/Exception/UnsupportedGrantTypeException.php +++ b/src/Exception/UnsupportedGrantTypeException.php @@ -32,6 +32,11 @@ class UnsupportedGrantTypeException extends OAuthException public function __construct($parameter) { - parent::__construct(sprintf('The authorization grant type "%s" is not supported by the authorization server.', $parameter)); + parent::__construct( + sprintf( + 'The authorization grant type "%s" is not supported by the authorization server.', + $parameter + ) + ); } } diff --git a/src/Grant/AbstractGrant.php b/src/Grant/AbstractGrant.php index 089a54a9..10195c79 100644 --- a/src/Grant/AbstractGrant.php +++ b/src/Grant/AbstractGrant.php @@ -116,13 +116,15 @@ abstract class AbstractGrant implements GrantTypeInterface for ($i = 0; $i < count($scopesList); $i++) { $scopesList[$i] = trim($scopesList[$i]); - if ($scopesList[$i] === '') unset($scopesList[$i]); // Remove any junk scopes + if ($scopesList[$i] === '') { + unset($scopesList[$i]); // Remove any junk scopes + } } if ( - $this->server->scopeParamRequired() === true && - $this->server->getDefaultScope() === null && - count($scopesList) === 0 + $this->server->scopeParamRequired() === true + && $this->server->getDefaultScope() === null + && count($scopesList) === 0 ) { throw new Exception\InvalidRequestException('scope'); } elseif (count($scopesList) === 0 && $this->server->getDefaultScope() !== null) { @@ -185,5 +187,4 @@ abstract class AbstractGrant implements GrantTypeInterface * @return array An array of parameters to be passed back to the client */ abstract public function completeFlow(); - } diff --git a/src/Grant/PasswordGrant.php b/src/Grant/PasswordGrant.php index 99b80b9d..4a1215df 100644 --- a/src/Grant/PasswordGrant.php +++ b/src/Grant/PasswordGrant.php @@ -164,5 +164,4 @@ class PasswordGrant extends AbstractGrant return $response; } - } diff --git a/src/ResourceServer.php b/src/ResourceServer.php index d5b99837..49859205 100644 --- a/src/ResourceServer.php +++ b/src/ResourceServer.php @@ -173,7 +173,9 @@ class ResourceServer extends AbstractServer */ public function isValidRequest($headersOnly = true, $accessToken = null) { - $accessTokenString = ($accessToken !== null) ? $accessToken : $this->determineAccessToken($headersOnly, $accessToken); + $accessTokenString = ($accessToken !== null) + ? $accessToken + : $this->determineAccessToken($headersOnly, $accessToken); // Set the access token $this->accessToken = $this->storages['access_token']->get($accessTokenString); diff --git a/src/Storage/ClientInterface.php b/src/Storage/ClientInterface.php index b825c06c..202e4b02 100644 --- a/src/Storage/ClientInterface.php +++ b/src/Storage/ClientInterface.php @@ -23,7 +23,7 @@ interface ClientInterface * @param string $clientId The client's ID * @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 in the request (default = "null") + * @param string $grantType The grant type used (default = "null") * @return League\OAuth2\Server\Entity\ClientEntity */ public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null);