Skip to content

Commit

Permalink
Merge pull request #64 from trikoder/various-improvements
Browse files Browse the repository at this point in the history
Various improvements
  • Loading branch information
X-Coder264 authored Jun 6, 2019
2 parents 91b3d75 + 49169cd commit 5fb4c7e
Show file tree
Hide file tree
Showing 22 changed files with 214 additions and 156 deletions.
7 changes: 5 additions & 2 deletions Command/CreateClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ final class CreateClientCommand extends Command
{
protected static $defaultName = 'trikoder:oauth2:create-client';

/**
* @var ClientManagerInterface
*/
private $clientManager;

public function __construct(ClientManagerInterface $clientManager)
Expand All @@ -29,7 +32,7 @@ public function __construct(ClientManagerInterface $clientManager)
$this->clientManager = $clientManager;
}

protected function configure()
protected function configure(): void
{
$this
->setDescription('Creates a new oAuth2 client')
Expand Down Expand Up @@ -67,7 +70,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$client = $this->buildClientFromInput($input);
Expand Down
5 changes: 5 additions & 0 deletions Command/DeleteClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
final class DeleteClientCommand extends Command
{
protected static $defaultName = 'trikoder:oauth2:delete-client';

/**
* @var ClientManagerInterface
*/
private $clientManager;

public function __construct(ClientManagerInterface $clientManager)
{
parent::__construct();

$this->clientManager = $clientManager;
}

Expand Down
10 changes: 6 additions & 4 deletions Command/ListClientsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@

final class ListClientsCommand extends Command
{
public const ALLOWED_COLUMNS = ['identifier', 'secret', 'scope', 'redirect uri', 'grant type'];
private const ALLOWED_COLUMNS = ['identifier', 'secret', 'scope', 'redirect uri', 'grant type'];

protected static $defaultName = 'trikoder:oauth2:list-clients';

/**
* @var ClientManagerInterface
*/
private $clientManager;

public function __construct(ClientManagerInterface $clientManager)
Expand Down Expand Up @@ -117,13 +121,11 @@ private function getRows(array $clients, array $columns): array

private function getColumns(InputInterface $input): array
{
$allowedColumns = self::ALLOWED_COLUMNS;

$requestedColumns = $input->getOption('columns');
$requestedColumns = array_map(function (string $column): string {
return strtolower(trim($column));
}, $requestedColumns);

return array_intersect($requestedColumns, $allowedColumns);
return array_intersect($requestedColumns, self::ALLOWED_COLUMNS);
}
}
3 changes: 3 additions & 0 deletions Command/UpdateClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ final class UpdateClientCommand extends Command
{
protected static $defaultName = 'trikoder:oauth2:update-client';

/**
* @var ClientManagerInterface
*/
private $clientManager;

public function __construct(ClientManagerInterface $clientManager)
Expand Down
8 changes: 6 additions & 2 deletions Controller/AuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ final class AuthorizationController
*/
private $userConverter;

public function __construct(AuthorizationServer $server, EventDispatcherInterface $eventDispatcher, AuthorizationRequestResolveEventFactory $eventFactory, UserConverter $userConverter)
{
public function __construct(
AuthorizationServer $server,
EventDispatcherInterface $eventDispatcher,
AuthorizationRequestResolveEventFactory $eventFactory,
UserConverter $userConverter
) {
$this->server = $server;
$this->eventDispatcher = $eventDispatcher;
$this->eventFactory = $eventFactory;
Expand Down
2 changes: 1 addition & 1 deletion Converter/UserConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

final class UserConverter
{
public function toLeague(UserInterface $user = null): UserEntityInterface
public function toLeague(?UserInterface $user): UserEntityInterface
{
$userEntity = new User();
if ($user instanceof UserInterface) {
Expand Down
3 changes: 3 additions & 0 deletions DBAL/Type/ImplodedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla
return parent::getSQLDeclaration($fieldDeclaration, $platform);
}

/**
* {@inheritdoc}
*/
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/TrikoderOAuth2Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private function configureGrants(ContainerBuilder $container, array $config): vo
;
}

private function configurePersistence(LoaderInterface $loader, ContainerBuilder $container, array $config)
private function configurePersistence(LoaderInterface $loader, ContainerBuilder $container, array $config): void
{
if (\count($config) > 1) {
throw new LogicException('Only one persistence method can be configured at a time.');
Expand Down
9 changes: 2 additions & 7 deletions EventListener/AuthorizationRequestUserResolvingListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@
use Trikoder\Bundle\OAuth2Bundle\Event\AuthorizationRequestResolveEvent;

/**
* Class AuthorizationRequestUserResolvingListener
*
* Listener sets currently authenticated user to authorization request context
*/
class AuthorizationRequestUserResolvingListener
final class AuthorizationRequestUserResolvingListener
{
/**
* @var Security
*/
private $security;

/**
* AuthorizationRequestUserResolvingListener constructor.
*/
public function __construct(Security $security)
{
$this->security = $security;
}

public function onAuthorizationRequest(AuthorizationRequestResolveEvent $event)
public function onAuthorizationRequest(AuthorizationRequestResolveEvent $event): void
{
$user = $this->security->getUser();
if ($user instanceof UserInterface) {
Expand Down
2 changes: 1 addition & 1 deletion EventListener/ConvertExceptionToResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
final class ConvertExceptionToResponseListener
{
public function onKernelException(GetResponseForExceptionEvent $event)
public function onKernelException(GetResponseForExceptionEvent $event): void
{
$exception = $event->getException();
if ($exception instanceof InsufficientScopesException || $exception instanceof Oauth2AuthenticationFailedException) {
Expand Down
2 changes: 1 addition & 1 deletion League/Entity/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getName()
/**
* @param string[] $redirectUri
*/
public function setRedirectUri(array $redirectUri)
public function setRedirectUri(array $redirectUri): void
{
$this->redirectUri = $redirectUri;
}
Expand Down
8 changes: 5 additions & 3 deletions Manager/ClientFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
final class ClientFilter
{
/**
* @var array
* @var Grant[]
*/
private $grants = [];

/**
* @var array
* @var RedirectUri[]
*/
private $redirectUris = [];

/**
* @var array
* @var Scope[]
*/
private $scopes = [];

Expand Down
Loading

0 comments on commit 5fb4c7e

Please sign in to comment.