From f876565976e81661ece1acd4f1fbe2755434fe50 Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 15 Mar 2018 11:53:38 +0000 Subject: [PATCH 1/2] Import internal PHP functions --- src/CryptKeyTrait.php | 3 +++ src/Entity/ClientEntity.php | 2 ++ src/Entity/TimestampableTrait.php | 2 ++ src/OAuth2Middleware.php | 2 ++ src/OAuth2MiddlewareFactory.php | 2 ++ src/Repository/Pdo/AbstractRepository.php | 3 +++ src/Repository/Pdo/AccessTokenRepository.php | 4 ++++ src/Repository/Pdo/ClientRepository.php | 2 ++ src/Repository/Pdo/UserRepository.php | 2 ++ test/AuthorizationServerFactoryTest.php | 4 ++++ test/Pdo/OAuth2PdoMiddlewareTest.php | 12 ++++++++++++ test/Repository/Pdo/AccessTokenRepositoryTest.php | 2 ++ test/Repository/Pdo/AuthCodeRepositoryTest.php | 2 ++ test/Repository/Pdo/RefreshTokenRepositoryTest.php | 2 ++ 14 files changed, 44 insertions(+) diff --git a/src/CryptKeyTrait.php b/src/CryptKeyTrait.php index 02602a6..81f7555 100644 --- a/src/CryptKeyTrait.php +++ b/src/CryptKeyTrait.php @@ -10,6 +10,9 @@ use League\OAuth2\Server\CryptKey; +use function is_string; +use function sprintf; + trait CryptKeyTrait { protected function getCryptKey($keyConfig, string $configPath) : CryptKey diff --git a/src/Entity/ClientEntity.php b/src/Entity/ClientEntity.php index 360dc7f..5d63d41 100644 --- a/src/Entity/ClientEntity.php +++ b/src/Entity/ClientEntity.php @@ -14,6 +14,8 @@ use League\OAuth2\Server\Entities\Traits\ClientTrait; use League\OAuth2\Server\Entities\Traits\EntityTrait; +use function explode; + class ClientEntity implements ClientEntityInterface { use ClientTrait, EntityTrait, RevokableTrait, TimestampableTrait; diff --git a/src/Entity/TimestampableTrait.php b/src/Entity/TimestampableTrait.php index 328f138..4f710ba 100644 --- a/src/Entity/TimestampableTrait.php +++ b/src/Entity/TimestampableTrait.php @@ -13,6 +13,8 @@ use DateTime; use DateTimeZone; +use function method_exists; + trait TimestampableTrait { /** diff --git a/src/OAuth2Middleware.php b/src/OAuth2Middleware.php index e2219a6..e3d1acd 100644 --- a/src/OAuth2Middleware.php +++ b/src/OAuth2Middleware.php @@ -18,6 +18,8 @@ use Psr\Http\Server\RequestHandlerInterface; use Zend\Expressive\Authentication\OAuth2\Entity\UserEntity; +use function strtoupper; + class OAuth2Middleware implements MiddlewareInterface { /** diff --git a/src/OAuth2MiddlewareFactory.php b/src/OAuth2MiddlewareFactory.php index 0a980ae..4a71861 100644 --- a/src/OAuth2MiddlewareFactory.php +++ b/src/OAuth2MiddlewareFactory.php @@ -14,6 +14,8 @@ use Psr\Container\ContainerInterface; use Psr\Http\Message\ResponseInterface; +use function sprintf; + class OAuth2MiddlewareFactory { public function __invoke(ContainerInterface $container) : OAuth2Middleware diff --git a/src/Repository/Pdo/AbstractRepository.php b/src/Repository/Pdo/AbstractRepository.php index 880414f..7cce630 100644 --- a/src/Repository/Pdo/AbstractRepository.php +++ b/src/Repository/Pdo/AbstractRepository.php @@ -10,6 +10,9 @@ namespace Zend\Expressive\Authentication\OAuth2\Repository\Pdo; +use function array_reduce; +use function trim; + class AbstractRepository { /** diff --git a/src/Repository/Pdo/AccessTokenRepository.php b/src/Repository/Pdo/AccessTokenRepository.php index 9d00093..d0d9240 100644 --- a/src/Repository/Pdo/AccessTokenRepository.php +++ b/src/Repository/Pdo/AccessTokenRepository.php @@ -16,6 +16,10 @@ use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use Zend\Expressive\Authentication\OAuth2\Entity\AccessTokenEntity; +use function array_key_exists; +use function implode; +use function sprintf; + class AccessTokenRepository extends AbstractRepository implements AccessTokenRepositoryInterface { /** diff --git a/src/Repository/Pdo/ClientRepository.php b/src/Repository/Pdo/ClientRepository.php index 51a4b53..6260f80 100644 --- a/src/Repository/Pdo/ClientRepository.php +++ b/src/Repository/Pdo/ClientRepository.php @@ -13,6 +13,8 @@ use League\OAuth2\Server\Repositories\ClientRepositoryInterface; use Zend\Expressive\Authentication\OAuth2\Entity\ClientEntity; +use function password_verify; + class ClientRepository extends AbstractRepository implements ClientRepositoryInterface { /** diff --git a/src/Repository/Pdo/UserRepository.php b/src/Repository/Pdo/UserRepository.php index 7dcc6b3..edef0a2 100644 --- a/src/Repository/Pdo/UserRepository.php +++ b/src/Repository/Pdo/UserRepository.php @@ -14,6 +14,8 @@ use League\OAuth2\Server\Repositories\UserRepositoryInterface; use Zend\Expressive\Authentication\OAuth2\Entity\UserEntity; +use function password_verify; + class UserRepository extends AbstractRepository implements UserRepositoryInterface { public function getUserEntityByUserCredentials( diff --git a/test/AuthorizationServerFactoryTest.php b/test/AuthorizationServerFactoryTest.php index e050a36..9a78118 100644 --- a/test/AuthorizationServerFactoryTest.php +++ b/test/AuthorizationServerFactoryTest.php @@ -22,6 +22,10 @@ use Zend\Expressive\Authentication\OAuth2\AuthorizationServerFactory; use Zend\Expressive\Authentication\OAuth2\Exception\InvalidConfigException; +use function array_merge; +use function array_slice; +use function in_array; + class AuthorizationServerFactoryTest extends TestCase { const REPOSITORY_CLASSES = [ diff --git a/test/Pdo/OAuth2PdoMiddlewareTest.php b/test/Pdo/OAuth2PdoMiddlewareTest.php index 344c78b..dfec773 100644 --- a/test/Pdo/OAuth2PdoMiddlewareTest.php +++ b/test/Pdo/OAuth2PdoMiddlewareTest.php @@ -33,6 +33,18 @@ use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\ScopeRepository; use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\UserRepository; +use function bin2hex; +use function explode; +use function file_exists; +use function file_get_contents; +use function http_build_query; +use function json_decode; +use function parse_str; +use function random_bytes; +use function sprintf; +use function strtolower; +use function unlink; + class OAuth2PdoMiddlewareTest extends TestCase { const DB_FILE = __DIR__ . '/TestAsset/test_oauth2.sq3'; diff --git a/test/Repository/Pdo/AccessTokenRepositoryTest.php b/test/Repository/Pdo/AccessTokenRepositoryTest.php index c96ad3a..aec5c81 100644 --- a/test/Repository/Pdo/AccessTokenRepositoryTest.php +++ b/test/Repository/Pdo/AccessTokenRepositoryTest.php @@ -21,6 +21,8 @@ use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\AccessTokenRepository; use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\PdoService; +use function time; + class AccessTokenRepositoryTest extends TestCase { public function setUp() diff --git a/test/Repository/Pdo/AuthCodeRepositoryTest.php b/test/Repository/Pdo/AuthCodeRepositoryTest.php index 2884cfc..c3bd2f1 100644 --- a/test/Repository/Pdo/AuthCodeRepositoryTest.php +++ b/test/Repository/Pdo/AuthCodeRepositoryTest.php @@ -21,6 +21,8 @@ use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\AuthCodeRepository; use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\PdoService; +use function time; + class AuthCodeRepositoryTest extends TestCase { public function setUp() diff --git a/test/Repository/Pdo/RefreshTokenRepositoryTest.php b/test/Repository/Pdo/RefreshTokenRepositoryTest.php index 6b95e26..ffc1bab 100644 --- a/test/Repository/Pdo/RefreshTokenRepositoryTest.php +++ b/test/Repository/Pdo/RefreshTokenRepositoryTest.php @@ -20,6 +20,8 @@ use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\PdoService; use Zend\Expressive\Authentication\OAuth2\Repository\Pdo\RefreshTokenRepository; +use function time; + class RefreshTokenRepositoryTest extends TestCase { public function setUp() From 61d44461a3bd071512bcfc42d74e1f73e0aea7cf Mon Sep 17 00:00:00 2001 From: webimpress Date: Thu, 15 Mar 2018 11:53:50 +0000 Subject: [PATCH 2/2] Removed redundant imports --- src/OAuth2AdapterFactory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OAuth2AdapterFactory.php b/src/OAuth2AdapterFactory.php index 733cb4d..d35e52e 100644 --- a/src/OAuth2AdapterFactory.php +++ b/src/OAuth2AdapterFactory.php @@ -13,7 +13,6 @@ use League\OAuth2\Server\ResourceServer; use Psr\Container\ContainerInterface; use Psr\Http\Message\ResponseInterface; -use Zend\Expressive\Authentication\OAuth2\Exception; class OAuth2AdapterFactory {