mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-25 14:40:00 +05:30
commit
2375b8c7f3
@ -21,7 +21,7 @@ install:
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit --coverage-clover=coverage.clover
|
||||
- vendor/bin/phpstan analyse -l 6 -c phpstan.neon src tests
|
||||
- vendor/bin/phpstan analyse -l 7 -c phpstan.neon src tests
|
||||
|
||||
after_script:
|
||||
- wget https://scrutinizer-ci.com/ocular.phar
|
||||
|
@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
- Upgrade PHPStan checks to level 7 (PR #856)
|
||||
|
||||
### Added
|
||||
- Added event emitters for issued access and refresh tokens (PR #860)
|
||||
- Can now use Defuse\Crypto\Key for encryption/decryption of keys which is faster than the Cryto class (PR #812)
|
||||
|
@ -54,7 +54,7 @@ The library uses [PHPUnit](https://phpunit.de/) for unit tests and [PHPStan](htt
|
||||
|
||||
```
|
||||
vendor/bin/phpunit
|
||||
vendor/bin/phpstan analyse -l 6 -c phpstan.neon src tests
|
||||
vendor/bin/phpstan analyse -l 7 -c phpstan.neon src tests
|
||||
```
|
||||
|
||||
## Continous Integration
|
||||
|
@ -3,3 +3,8 @@ includes:
|
||||
- vendor/phpstan/phpstan-phpunit/rules.neon
|
||||
- vendor/phpstan/phpstan-phpunit/strictRules.neon
|
||||
- vendor/phpstan/phpstan-strict-rules/rules.neon
|
||||
services:
|
||||
-
|
||||
class: LeagueTests\PHPStan\AbstractGrantExtension
|
||||
tags:
|
||||
- phpstan.broker.dynamicMethodReturnTypeExtension
|
||||
|
@ -12,7 +12,7 @@ namespace League\OAuth2\Server\Entities;
|
||||
interface AuthCodeEntityInterface extends TokenInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRedirectUri();
|
||||
|
||||
|
@ -17,7 +17,7 @@ trait AuthCodeTrait
|
||||
protected $redirectUri;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRedirectUri()
|
||||
{
|
||||
|
@ -386,7 +386,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
||||
* @param \DateInterval $authCodeTTL
|
||||
* @param ClientEntityInterface $client
|
||||
* @param string $userIdentifier
|
||||
* @param string $redirectUri
|
||||
* @param string|null $redirectUri
|
||||
* @param ScopeEntityInterface[] $scopes
|
||||
*
|
||||
* @throws OAuthServerException
|
||||
@ -407,7 +407,10 @@ abstract class AbstractGrant implements GrantTypeInterface
|
||||
$authCode->setExpiryDateTime((new \DateTime())->add($authCodeTTL));
|
||||
$authCode->setClient($client);
|
||||
$authCode->setUserIdentifier($userIdentifier);
|
||||
$authCode->setRedirectUri($redirectUri);
|
||||
|
||||
if ($redirectUri !== null) {
|
||||
$authCode->setRedirectUri($redirectUri);
|
||||
}
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
$authCode->addScope($scope);
|
||||
|
@ -276,7 +276,11 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
||||
$authorizationRequest->setGrantTypeId($this->getIdentifier());
|
||||
$authorizationRequest->setClient($client);
|
||||
$authorizationRequest->setRedirectUri($redirectUri);
|
||||
$authorizationRequest->setState($stateParameter);
|
||||
|
||||
if ($stateParameter !== null) {
|
||||
$authorizationRequest->setState($stateParameter);
|
||||
}
|
||||
|
||||
$authorizationRequest->setScopes($scopes);
|
||||
|
||||
if ($this->enableCodeExchangeProof === true) {
|
||||
|
@ -177,7 +177,11 @@ class ImplicitGrant extends AbstractAuthorizeGrant
|
||||
$authorizationRequest->setGrantTypeId($this->getIdentifier());
|
||||
$authorizationRequest->setClient($client);
|
||||
$authorizationRequest->setRedirectUri($redirectUri);
|
||||
$authorizationRequest->setState($stateParameter);
|
||||
|
||||
if ($stateParameter !== null) {
|
||||
$authorizationRequest->setState($stateParameter);
|
||||
}
|
||||
|
||||
$authorizationRequest->setScopes($finalizedScopes);
|
||||
|
||||
return $authorizationRequest;
|
||||
|
@ -60,7 +60,7 @@ class AuthorizationRequest
|
||||
/**
|
||||
* The state parameter on the authorization request
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
@ -175,7 +175,7 @@ class AuthorizationRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
|
39
tests/PHPStan/AbstractGrantExtension.php
Normal file
39
tests/PHPStan/AbstractGrantExtension.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace LeagueTests\PHPStan;
|
||||
|
||||
use League\OAuth2\Server\Grant\AbstractGrant;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
use PHPStan\Type\DynamicMethodReturnTypeExtension;
|
||||
use PHPStan\Type\NullType;
|
||||
use PHPStan\Type\StringType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeCombinator;
|
||||
|
||||
final class AbstractGrantExtension implements DynamicMethodReturnTypeExtension
|
||||
{
|
||||
public function getClass(): string
|
||||
{
|
||||
return AbstractGrant::class;
|
||||
}
|
||||
|
||||
public function isMethodSupported(MethodReflection $methodReflection): bool
|
||||
{
|
||||
return in_array($methodReflection->getName(), [
|
||||
'getRequestParameter',
|
||||
'getQueryStringParameter',
|
||||
'getCookieParameter',
|
||||
], true);
|
||||
}
|
||||
|
||||
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
|
||||
{
|
||||
return TypeCombinator::union(...[
|
||||
new StringType(),
|
||||
isset($methodCall->args[2]) ? $scope->getType($methodCall->args[2]->value) : new NullType(),
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user