mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-08 13:42:25 +05:30
PHPStan level 7
This commit is contained in:
parent
456c6cfdd2
commit
143afc9561
@ -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
|
||||
|
@ -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,12 +12,12 @@ namespace League\OAuth2\Server\Entities;
|
||||
interface AuthCodeEntityInterface extends TokenInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRedirectUri();
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
* @param string|null $uri
|
||||
*/
|
||||
public function setRedirectUri($uri);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ trait AuthCodeTrait
|
||||
protected $redirectUri;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRedirectUri()
|
||||
{
|
||||
@ -25,7 +25,7 @@ trait AuthCodeTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
* @param string|null $uri
|
||||
*/
|
||||
public function setRedirectUri($uri)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
{
|
||||
@ -183,7 +183,7 @@ class AuthorizationRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $state
|
||||
* @param string|null $state
|
||||
*/
|
||||
public function setState($state)
|
||||
{
|
||||
|
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