Explicitly compare to false when checking not instanceof

This commit is contained in:
Lukáš Unger
2016-07-09 12:09:21 +02:00
parent c3a4670c11
commit c874c59b9c
7 changed files with 15 additions and 15 deletions

View File

@@ -88,12 +88,12 @@ class AuthorizationServer implements EmitterAwareInterface
$this->accessTokenRepository = $accessTokenRepository; $this->accessTokenRepository = $accessTokenRepository;
$this->scopeRepository = $scopeRepository; $this->scopeRepository = $scopeRepository;
if (!$privateKey instanceof CryptKey) { if ($privateKey instanceof CryptKey === false) {
$privateKey = new CryptKey($privateKey); $privateKey = new CryptKey($privateKey);
} }
$this->privateKey = $privateKey; $this->privateKey = $privateKey;
if (!$publicKey instanceof CryptKey) { if ($publicKey instanceof CryptKey === false) {
$publicKey = new CryptKey($publicKey); $publicKey = new CryptKey($publicKey);
} }
$this->publicKey = $publicKey; $this->publicKey = $publicKey;
@@ -109,7 +109,7 @@ class AuthorizationServer implements EmitterAwareInterface
*/ */
public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null) public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null)
{ {
if (!$accessTokenTTL instanceof \DateInterval) { if ($accessTokenTTL instanceof \DateInterval === false) {
$accessTokenTTL = new \DateInterval('PT1H'); $accessTokenTTL = new \DateInterval('PT1H');
} }
@@ -202,7 +202,7 @@ class AuthorizationServer implements EmitterAwareInterface
*/ */
protected function getResponseType() protected function getResponseType()
{ {
if (!$this->responseType instanceof ResponseTypeInterface) { if ($this->responseType instanceof ResponseTypeInterface === false) {
$this->responseType = new BearerTokenResponse(); $this->responseType = new BearerTokenResponse();
} }

View File

@@ -159,7 +159,7 @@ abstract class AbstractGrant implements GrantTypeInterface
true true
); );
if (!$client instanceof ClientEntityInterface) { if ($client instanceof ClientEntityInterface === false) {
$this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request)); $this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request));
throw OAuthServerException::invalidClient(); throw OAuthServerException::invalidClient();
} }
@@ -210,7 +210,7 @@ abstract class AbstractGrant implements GrantTypeInterface
foreach ($scopesList as $scopeItem) { foreach ($scopesList as $scopeItem) {
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeItem); $scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeItem);
if (!$scope instanceof ScopeEntityInterface) { if ($scope instanceof ScopeEntityInterface === false) {
throw OAuthServerException::invalidScope($scopeItem, $redirectUri); throw OAuthServerException::invalidScope($scopeItem, $redirectUri);
} }

View File

@@ -107,7 +107,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
foreach ($authCodePayload->scopes as $scopeId) { foreach ($authCodePayload->scopes as $scopeId) {
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId); $scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId);
if (!$scope instanceof ScopeEntityInterface) { if ($scope instanceof ScopeEntityInterface === false) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
throw OAuthServerException::invalidScope($scopeId); throw OAuthServerException::invalidScope($scopeId);
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
@@ -220,7 +220,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
false false
); );
if (!$client instanceof ClientEntityInterface) { if ($client instanceof ClientEntityInterface === false) {
$this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request)); $this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request));
throw OAuthServerException::invalidClient(); throw OAuthServerException::invalidClient();
} }
@@ -284,7 +284,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
*/ */
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest) 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'); throw new \LogicException('An instance of UserEntityInterface should be set on the AuthorizationRequest');
} }

View File

@@ -122,7 +122,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant
false false
); );
if (!$client instanceof ClientEntityInterface) { if ($client instanceof ClientEntityInterface === false) {
$this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request)); $this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request));
throw OAuthServerException::invalidClient(); throw OAuthServerException::invalidClient();
} }
@@ -168,7 +168,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant
*/ */
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest) 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'); throw new \LogicException('An instance of UserEntityInterface should be set on the AuthorizationRequest');
} }

View File

@@ -92,7 +92,7 @@ class PasswordGrant extends AbstractGrant
$this->getIdentifier(), $this->getIdentifier(),
$client $client
); );
if (!$user instanceof UserEntityInterface) { if ($user instanceof UserEntityInterface === false) {
$this->getEmitter()->emit(new RequestEvent(RequestEvent::USER_AUTHENTICATION_FAILED, $request)); $this->getEmitter()->emit(new RequestEvent(RequestEvent::USER_AUTHENTICATION_FAILED, $request));
throw OAuthServerException::invalidCredentials(); throw OAuthServerException::invalidCredentials();

View File

@@ -51,7 +51,7 @@ class RefreshTokenGrant extends AbstractGrant
$scopes = array_map(function ($scopeId) use ($client) { $scopes = array_map(function ($scopeId) use ($client) {
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId); $scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId);
if (!$scope instanceof ScopeEntityInterface) { if ($scope instanceof ScopeEntityInterface === false) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
throw OAuthServerException::invalidScope($scopeId); throw OAuthServerException::invalidScope($scopeId);
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd

View File

@@ -46,7 +46,7 @@ class ResourceServer
) { ) {
$this->accessTokenRepository = $accessTokenRepository; $this->accessTokenRepository = $accessTokenRepository;
if (!$publicKey instanceof CryptKey) { if ($publicKey instanceof CryptKey === false) {
$publicKey = new CryptKey($publicKey); $publicKey = new CryptKey($publicKey);
} }
$this->publicKey = $publicKey; $this->publicKey = $publicKey;
@@ -59,7 +59,7 @@ class ResourceServer
*/ */
protected function getAuthorizationValidator() protected function getAuthorizationValidator()
{ {
if (!$this->authorizationValidator instanceof AuthorizationValidatorInterface) { if ($this->authorizationValidator instanceof AuthorizationValidatorInterface === false) {
$this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository); $this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository);
} }