diff --git a/examples/public/auth_code.php b/examples/public/auth_code.php index 063bbdc0..e014f55a 100644 --- a/examples/public/auth_code.php +++ b/examples/public/auth_code.php @@ -7,9 +7,9 @@ * @link https://github.com/thephpleague/oauth2-server */ +use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\AuthCodeGrant; -use League\OAuth2\Server\AuthorizationServer; use OAuth2ServerExamples\Entities\UserEntity; use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\AuthCodeRepository; diff --git a/examples/public/client_credentials.php b/examples/public/client_credentials.php index e2547df3..0825b61a 100644 --- a/examples/public/client_credentials.php +++ b/examples/public/client_credentials.php @@ -62,12 +62,10 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI // Try to respond to the request return $server->respondToAccessTokenRequest($request, $response); - } catch (OAuthServerException $exception) { // All instances of OAuthServerException can be formatted into a HTTP response return $exception->generateHttpResponse($response); - } catch (\Exception $exception) { // Unknown exception @@ -75,7 +73,6 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI $body->write($exception->getMessage()); return $response->withStatus(500)->withBody($body); - } }); diff --git a/examples/public/implicit.php b/examples/public/implicit.php index cc365037..2a82097f 100644 --- a/examples/public/implicit.php +++ b/examples/public/implicit.php @@ -7,9 +7,9 @@ * @link https://github.com/thephpleague/oauth2-server */ +use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\ImplicitGrant; -use League\OAuth2\Server\AuthorizationServer; use OAuth2ServerExamples\Entities\UserEntity; use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\ClientRepository; diff --git a/examples/public/middleware_use.php b/examples/public/middleware_use.php index 5ae6f6e3..2dfe1834 100644 --- a/examples/public/middleware_use.php +++ b/examples/public/middleware_use.php @@ -7,11 +7,11 @@ * @link https://github.com/thephpleague/oauth2-server */ +use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Grant\AuthCodeGrant; use League\OAuth2\Server\Grant\RefreshTokenGrant; use League\OAuth2\Server\Middleware\AuthorizationServerMiddleware; use League\OAuth2\Server\Middleware\ResourceServerMiddleware; -use League\OAuth2\Server\AuthorizationServer; use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\AuthCodeRepository; use OAuth2ServerExamples\Repositories\ClientRepository; diff --git a/examples/public/password.php b/examples/public/password.php index 98d1f395..18eb6ddf 100644 --- a/examples/public/password.php +++ b/examples/public/password.php @@ -7,9 +7,9 @@ * @link https://github.com/thephpleague/oauth2-server */ +use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\PasswordGrant; -use League\OAuth2\Server\AuthorizationServer; use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\ClientRepository; use OAuth2ServerExamples\Repositories\RefreshTokenRepository; diff --git a/examples/public/refresh_token.php b/examples/public/refresh_token.php index 0cf83734..0649c117 100644 --- a/examples/public/refresh_token.php +++ b/examples/public/refresh_token.php @@ -7,9 +7,9 @@ * @link https://github.com/thephpleague/oauth2-server */ +use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\RefreshTokenGrant; -use League\OAuth2\Server\AuthorizationServer; use OAuth2ServerExamples\Repositories\AccessTokenRepository; use OAuth2ServerExamples\Repositories\ClientRepository; use OAuth2ServerExamples\Repositories\RefreshTokenRepository; diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index bd1c1490..b0ba7598 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -70,12 +70,12 @@ class AuthorizationServer implements EmitterAwareInterface /** * New server instance. * - * @param \League\OAuth2\Server\Repositories\ClientRepositoryInterface $clientRepository - * @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository - * @param \League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scopeRepository - * @param \League\OAuth2\Server\CryptKey|string $privateKey - * @param \League\OAuth2\Server\CryptKey|string $publicKey - * @param null|\League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType + * @param \League\OAuth2\Server\Repositories\ClientRepositoryInterface $clientRepository + * @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository + * @param \League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scopeRepository + * @param \League\OAuth2\Server\CryptKey|string $privateKey + * @param \League\OAuth2\Server\CryptKey|string $publicKey + * @param null|\League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType */ public function __construct( ClientRepositoryInterface $clientRepository, diff --git a/src/Middleware/AuthorizationServerMiddleware.php b/src/Middleware/AuthorizationServerMiddleware.php index 45a8348f..d33cbd31 100644 --- a/src/Middleware/AuthorizationServerMiddleware.php +++ b/src/Middleware/AuthorizationServerMiddleware.php @@ -9,8 +9,8 @@ namespace League\OAuth2\Server\Middleware; -use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\AuthorizationServer; +use League\OAuth2\Server\Exception\OAuthServerException; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; diff --git a/tests/AuthorizationServerTest.php b/tests/AuthorizationServerTest.php index 86eb24df..2303b713 100644 --- a/tests/AuthorizationServerTest.php +++ b/tests/AuthorizationServerTest.php @@ -2,6 +2,7 @@ namespace LeagueTests; +use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\CryptKey; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\AuthCodeGrant; @@ -13,7 +14,6 @@ use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface; use League\OAuth2\Server\Repositories\ScopeRepositoryInterface; use League\OAuth2\Server\RequestTypes\AuthorizationRequest; use League\OAuth2\Server\ResponseTypes\BearerTokenResponse; -use League\OAuth2\Server\AuthorizationServer; use LeagueTests\Stubs\AccessTokenEntity; use LeagueTests\Stubs\AuthCodeEntity; use LeagueTests\Stubs\ClientEntity; @@ -94,7 +94,7 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase $this->assertTrue($method->invoke($server) instanceof BearerTokenResponse); } - + public function testCompleteAuthorizationRequest() { $clientRepository = $this->getMock(ClientRepositoryInterface::class); diff --git a/tests/Middleware/AuthorizationServerMiddlewareTest.php b/tests/Middleware/AuthorizationServerMiddlewareTest.php index f04b7572..bb068179 100644 --- a/tests/Middleware/AuthorizationServerMiddlewareTest.php +++ b/tests/Middleware/AuthorizationServerMiddlewareTest.php @@ -2,13 +2,13 @@ namespace LeagueTests\Middleware; +use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\ClientCredentialsGrant; use League\OAuth2\Server\Middleware\AuthorizationServerMiddleware; use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use League\OAuth2\Server\Repositories\ClientRepositoryInterface; use League\OAuth2\Server\Repositories\ScopeRepositoryInterface; -use League\OAuth2\Server\AuthorizationServer; use LeagueTests\Stubs\AccessTokenEntity; use LeagueTests\Stubs\ClientEntity; use LeagueTests\Stubs\StubResponseType; diff --git a/tests/ResourceServerTest.php b/tests/ResourceServerTest.php index 12365c47..c1dafe27 100644 --- a/tests/ResourceServerTest.php +++ b/tests/ResourceServerTest.php @@ -3,7 +3,6 @@ namespace LeagueTests; - use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use League\OAuth2\Server\ResourceServer; @@ -24,5 +23,4 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase $this->assertEquals('Missing "Authorization" header', $e->getHint()); } } - }