From c874c59b9c1aef05fad35cc2fd4339f80aca0a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Unger?= Date: Sat, 9 Jul 2016 12:09:21 +0200 Subject: [PATCH] Explicitly compare to false when checking not instanceof --- src/AuthorizationServer.php | 8 ++++---- src/Grant/AbstractGrant.php | 4 ++-- src/Grant/AuthCodeGrant.php | 6 +++--- src/Grant/ImplicitGrant.php | 4 ++-- src/Grant/PasswordGrant.php | 2 +- src/Grant/RefreshTokenGrant.php | 2 +- src/ResourceServer.php | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index b46a574f..2cc48ab2 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -88,12 +88,12 @@ class AuthorizationServer implements EmitterAwareInterface $this->accessTokenRepository = $accessTokenRepository; $this->scopeRepository = $scopeRepository; - if (!$privateKey instanceof CryptKey) { + if ($privateKey instanceof CryptKey === false) { $privateKey = new CryptKey($privateKey); } $this->privateKey = $privateKey; - if (!$publicKey instanceof CryptKey) { + if ($publicKey instanceof CryptKey === false) { $publicKey = new CryptKey($publicKey); } $this->publicKey = $publicKey; @@ -109,7 +109,7 @@ class AuthorizationServer implements EmitterAwareInterface */ public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null) { - if (!$accessTokenTTL instanceof \DateInterval) { + if ($accessTokenTTL instanceof \DateInterval === false) { $accessTokenTTL = new \DateInterval('PT1H'); } @@ -202,7 +202,7 @@ class AuthorizationServer implements EmitterAwareInterface */ protected function getResponseType() { - if (!$this->responseType instanceof ResponseTypeInterface) { + if ($this->responseType instanceof ResponseTypeInterface === false) { $this->responseType = new BearerTokenResponse(); } diff --git a/src/Grant/AbstractGrant.php b/src/Grant/AbstractGrant.php index 2790e80f..e230c500 100644 --- a/src/Grant/AbstractGrant.php +++ b/src/Grant/AbstractGrant.php @@ -159,7 +159,7 @@ abstract class AbstractGrant implements GrantTypeInterface true ); - if (!$client instanceof ClientEntityInterface) { + if ($client instanceof ClientEntityInterface === false) { $this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request)); throw OAuthServerException::invalidClient(); } @@ -210,7 +210,7 @@ abstract class AbstractGrant implements GrantTypeInterface foreach ($scopesList as $scopeItem) { $scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeItem); - if (!$scope instanceof ScopeEntityInterface) { + if ($scope instanceof ScopeEntityInterface === false) { throw OAuthServerException::invalidScope($scopeItem, $redirectUri); } diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index babf3d56..df89400e 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -107,7 +107,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant foreach ($authCodePayload->scopes as $scopeId) { $scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId); - if (!$scope instanceof ScopeEntityInterface) { + if ($scope instanceof ScopeEntityInterface === false) { // @codeCoverageIgnoreStart throw OAuthServerException::invalidScope($scopeId); // @codeCoverageIgnoreEnd @@ -220,7 +220,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant false ); - if (!$client instanceof ClientEntityInterface) { + if ($client instanceof ClientEntityInterface === false) { $this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request)); throw OAuthServerException::invalidClient(); } @@ -284,7 +284,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant */ public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest) { - if (!$authorizationRequest->getUser() instanceof UserEntityInterface) { + if ($authorizationRequest->getUser() instanceof UserEntityInterface === false) { throw new \LogicException('An instance of UserEntityInterface should be set on the AuthorizationRequest'); } diff --git a/src/Grant/ImplicitGrant.php b/src/Grant/ImplicitGrant.php index 08585f15..a85b70d4 100644 --- a/src/Grant/ImplicitGrant.php +++ b/src/Grant/ImplicitGrant.php @@ -122,7 +122,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant false ); - if (!$client instanceof ClientEntityInterface) { + if ($client instanceof ClientEntityInterface === false) { $this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request)); throw OAuthServerException::invalidClient(); } @@ -168,7 +168,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant */ public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest) { - if (!$authorizationRequest->getUser() instanceof UserEntityInterface) { + if ($authorizationRequest->getUser() instanceof UserEntityInterface === false) { throw new \LogicException('An instance of UserEntityInterface should be set on the AuthorizationRequest'); } diff --git a/src/Grant/PasswordGrant.php b/src/Grant/PasswordGrant.php index 07eba5f1..31755613 100644 --- a/src/Grant/PasswordGrant.php +++ b/src/Grant/PasswordGrant.php @@ -92,7 +92,7 @@ class PasswordGrant extends AbstractGrant $this->getIdentifier(), $client ); - if (!$user instanceof UserEntityInterface) { + if ($user instanceof UserEntityInterface === false) { $this->getEmitter()->emit(new RequestEvent(RequestEvent::USER_AUTHENTICATION_FAILED, $request)); throw OAuthServerException::invalidCredentials(); diff --git a/src/Grant/RefreshTokenGrant.php b/src/Grant/RefreshTokenGrant.php index 600eae8f..17448a92 100644 --- a/src/Grant/RefreshTokenGrant.php +++ b/src/Grant/RefreshTokenGrant.php @@ -51,7 +51,7 @@ class RefreshTokenGrant extends AbstractGrant $scopes = array_map(function ($scopeId) use ($client) { $scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId); - if (!$scope instanceof ScopeEntityInterface) { + if ($scope instanceof ScopeEntityInterface === false) { // @codeCoverageIgnoreStart throw OAuthServerException::invalidScope($scopeId); // @codeCoverageIgnoreEnd diff --git a/src/ResourceServer.php b/src/ResourceServer.php index 0fb8fbee..5e9c13f3 100644 --- a/src/ResourceServer.php +++ b/src/ResourceServer.php @@ -46,7 +46,7 @@ class ResourceServer ) { $this->accessTokenRepository = $accessTokenRepository; - if (!$publicKey instanceof CryptKey) { + if ($publicKey instanceof CryptKey === false) { $publicKey = new CryptKey($publicKey); } $this->publicKey = $publicKey; @@ -59,7 +59,7 @@ class ResourceServer */ protected function getAuthorizationValidator() { - if (!$this->authorizationValidator instanceof AuthorizationValidatorInterface) { + if ($this->authorizationValidator instanceof AuthorizationValidatorInterface === false) { $this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository); }