Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CI useful again and add type declarations #663

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
language: php

sudo: true
php:
- 7.2

service:
services:
- docker
- mongodb

matrix:
jobs:
fast_finish: true
include:
- php: 7.2
Expand Down
11 changes: 10 additions & 1 deletion Command/CleanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@

class CleanCommand extends Command
{
/**
* @var TokenManagerInterface
*/
private $accessTokenManager;
/**
* @var TokenManagerInterface
*/
private $refreshTokenManager;
/**
* @var AuthCodeManagerInterface
*/
private $authCodeManager;

public function __construct(
Expand All @@ -40,7 +49,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
parent::configure();

Expand Down
5 changes: 4 additions & 1 deletion Command/CreateClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

class CreateClientCommand extends Command
{
/**
* @var ClientManagerInterface
*/
private $clientManager;

public function __construct(ClientManagerInterface $clientManager)
Expand All @@ -34,7 +37,7 @@ public function __construct(ClientManagerInterface $clientManager)
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
parent::configure();

Expand Down
10 changes: 5 additions & 5 deletions Controller/AuthorizeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function __construct(
/**
* Authorize.
*/
public function authorizeAction(Request $request)
public function authorizeAction(Request $request): Response
{
$user = $this->tokenStorage->getToken()->getUser();

Expand Down Expand Up @@ -228,17 +228,17 @@ protected function getClient()
return $this->client;
}

/**
* @param array<mixed> $context
*/
protected function renderAuthorize(array $context): Response
{
return new Response(
$this->twig->render('@FOSOAuthServer/Authorize/authorize.html.twig', $context)
);
}

/**
* @return Request|null
*/
private function getCurrentRequest()
private function getCurrentRequest(): Request
{
$request = $this->requestStack->getCurrentRequest();
if (null === $request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class GrantExtensionsCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$storageDefinition = $container->findDefinition('fos_oauth_server.storage');
$className = $container->getParameterBag()->resolveValue($storageDefinition->getClass());
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/RequestStackCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class RequestStackCompilerPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if ($container->has('request_stack')) {
return;
Expand Down
6 changes: 4 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*
* @return TreeBuilder
*/
public function getConfigTreeBuilder()
{
Expand Down Expand Up @@ -83,7 +85,7 @@ public function getConfigTreeBuilder()
return $treeBuilder;
}

private function addAuthorizeSection(ArrayNodeDefinition $node)
private function addAuthorizeSection(ArrayNodeDefinition $node): void
{
$node
->children()
Expand All @@ -109,7 +111,7 @@ private function addAuthorizeSection(ArrayNodeDefinition $node)
;
}

private function addServiceSection(ArrayNodeDefinition $node)
private function addServiceSection(ArrayNodeDefinition $node): void
{
$node
->addDefaultsIfNotSet()
Expand Down
14 changes: 14 additions & 0 deletions DependencyInjection/FOSOAuthServerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class FOSOAuthServerExtension extends Extension
{
/**
* {@inheritdoc}
*
* @return void
*/
public function load(array $configs, ContainerBuilder $container)
{
Expand Down Expand Up @@ -109,6 +111,9 @@ public function getAlias()
return 'fos_oauth_server';
}

/**
* @return void
*/
protected function remapParameters(array $config, ContainerBuilder $container, array $map)
{
foreach ($map as $name => $paramName) {
Expand All @@ -118,6 +123,9 @@ protected function remapParameters(array $config, ContainerBuilder $container, a
}
}

/**
* @return void
*/
protected function remapParametersNamespaces(array $config, ContainerBuilder $container, array $namespaces)
{
foreach ($namespaces as $ns => $map) {
Expand All @@ -140,6 +148,9 @@ protected function remapParametersNamespaces(array $config, ContainerBuilder $co
}
}

/**
* @return void
*/
protected function loadAuthorize(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
$loader->load('authorize.xml');
Expand All @@ -157,6 +168,9 @@ protected function loadAuthorize(array $config, ContainerBuilder $container, Xml
]);
}

/**
* @return string
*/
private function computeArraySupportedScopes(array $supportedScopes)
{
foreach ($supportedScopes as $scope) {
Expand Down
6 changes: 6 additions & 0 deletions DependencyInjection/Security/Factory/OAuthFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class OAuthFactory implements SecurityFactoryInterface
{
/**
* {@inheritdoc}
*
* @param mixed $config
*
* @return array<string>
*/
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
{
Expand Down Expand Up @@ -62,6 +66,8 @@ public function getKey()

/**
* {@inheritdoc}
*
* @return void
*/
public function addConfiguration(NodeDefinition $node)
{
Expand Down
6 changes: 3 additions & 3 deletions Document/AuthCodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AuthCodeManager extends BaseAuthCodeManager
*/
protected $class;

public function __construct(DocumentManager $dm, $class)
public function __construct(DocumentManager $dm, string $class)
{
// NOTE: bug in Doctrine, hinting DocumentRepository|ObjectRepository when only DocumentRepository is expected
/** @var DocumentRepository $repository */
Expand Down Expand Up @@ -65,7 +65,7 @@ public function findAuthCodeBy(array $criteria)
/**
* {@inheritdoc}
*/
public function updateAuthCode(AuthCodeInterface $authCode)
public function updateAuthCode(AuthCodeInterface $authCode): void
{
$this->dm->persist($authCode);
$this->dm->flush();
Expand All @@ -74,7 +74,7 @@ public function updateAuthCode(AuthCodeInterface $authCode)
/**
* {@inheritdoc}
*/
public function deleteAuthCode(AuthCodeInterface $authCode)
public function deleteAuthCode(AuthCodeInterface $authCode): void
{
$this->dm->remove($authCode);
$this->dm->flush();
Expand Down
2 changes: 1 addition & 1 deletion Document/ClientManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ClientManager extends BaseClientManager
*/
protected $class;

public function __construct(DocumentManager $dm, $class)
public function __construct(DocumentManager $dm, string $class)
{
// NOTE: bug in Doctrine, hinting DocumentRepository|ObjectRepository when only DocumentRepository is expected
/** @var DocumentRepository $repository */
Expand Down
2 changes: 1 addition & 1 deletion Document/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TokenManager extends BaseTokenManager
*/
protected $class;

public function __construct(DocumentManager $dm, $class)
public function __construct(DocumentManager $dm, string $class)
{
// NOTE: bug in Doctrine, hinting DocumentRepository|ObjectRepository when only DocumentRepository is expected
/** @var DocumentRepository $repository */
Expand Down
4 changes: 2 additions & 2 deletions Entity/AuthCodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function findAuthCodeBy(array $criteria)
/**
* {@inheritdoc}
*/
public function updateAuthCode(AuthCodeInterface $authCode)
public function updateAuthCode(AuthCodeInterface $authCode): void
{
$this->em->persist($authCode);
$this->em->flush();
Expand All @@ -66,7 +66,7 @@ public function updateAuthCode(AuthCodeInterface $authCode)
/**
* {@inheritdoc}
*/
public function deleteAuthCode(AuthCodeInterface $authCode)
public function deleteAuthCode(AuthCodeInterface $authCode): void
{
$this->em->remove($authCode);
$this->em->flush();
Expand Down
2 changes: 1 addition & 1 deletion Entity/ClientManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ClientManager extends BaseClientManager
*/
protected $class;

public function __construct(EntityManagerInterface $em, $class)
public function __construct(EntityManagerInterface $em, string $class)
{
// NOTE: bug in Doctrine, hinting EntityRepository|ObjectRepository when only EntityRepository is expected
/** @var EntityRepository $repository */
Expand Down
2 changes: 1 addition & 1 deletion Entity/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TokenManager extends BaseTokenManager
*/
protected $class;

public function __construct(EntityManagerInterface $em, $class)
public function __construct(EntityManagerInterface $em, string $class)
{
// NOTE: bug in Doctrine, hinting EntityRepository|ObjectRepository when only EntityRepository is expected
/** @var EntityRepository $repository */
Expand Down
2 changes: 1 addition & 1 deletion Event/AbstractAuthorizationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getUser(): UserInterface
return $this->user;
}

public function setAuthorizedClient(bool $authorized)
public function setAuthorizedClient(bool $authorized): void
{
$this->isAuthorizedClient = $authorized;
}
Expand Down
2 changes: 1 addition & 1 deletion FOSOAuthServerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct()
$this->extension = new FOSOAuthServerExtension();
}

public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
parent::build($container);

Expand Down
13 changes: 11 additions & 2 deletions Form/Handler/AuthorizeFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,22 @@ public function __construct(FormInterface $form, $requestStack = null)
*
* @param ContainerInterface|null $container A ContainerInterface instance or null
*/
public function setContainer(ContainerInterface $container = null)
public function setContainer(ContainerInterface $container = null): void
{
$this->container = $container;
}

/**
* @return bool
*/
public function isAccepted()
{
return $this->form->getData()->accepted;
}

/**
* @return bool
*/
public function isRejected()
{
return !$this->form->getData()->accepted;
Expand Down Expand Up @@ -112,7 +118,7 @@ public function getScope()
* @todo finishClientAuthorization() is a bit odd since it accepts $data
* but then proceeds to ignore it and forces everything to be in $request->query
*/
protected function onSuccess()
protected function onSuccess(): void
{
$_GET = [
'client_id' => $this->form->getData()->client_id,
Expand All @@ -123,6 +129,9 @@ protected function onSuccess()
];
}

/**
* @return ?Request
*/
private function getCurrentRequest()
{
if (null === $this->requestStack) {
Expand Down
4 changes: 2 additions & 2 deletions Form/Type/AuthorizeFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class AuthorizeFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('client_id', HiddenType::class);
$builder->add('response_type', HiddenType::class);
Expand All @@ -35,7 +35,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => 'FOS\OAuthServerBundle\Form\Model\Authorize',
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ci: phpstan phpunit-coverage
lint: cs-full-check phpstan

phpstan:
sh -c "${QA_DOCKER_COMMAND} phpstan analyse --configuration phpstan.neon --level 6 ."
sh -c "${QA_DOCKER_COMMAND} phpstan analyse . || true"

cs:
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --diff"
Expand Down
2 changes: 1 addition & 1 deletion Model/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AuthCode extends Token implements AuthCodeInterface
/**
* {@inheritdoc}
*/
public function setRedirectUri($redirectUri)
public function setRedirectUri($redirectUri): void
{
$this->redirectUri = $redirectUri;
}
Expand Down
2 changes: 1 addition & 1 deletion Model/AuthCodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ interface AuthCodeInterface extends TokenInterface, IOAuth2AuthCode
/**
* @param string $redirectUri
*/
public function setRedirectUri($redirectUri);
public function setRedirectUri($redirectUri): void;
}