Skip to content

Commit

Permalink
style: fix codebase with CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Jan 11, 2018
1 parent 3a4c378 commit 8630dc1
Show file tree
Hide file tree
Showing 104 changed files with 513 additions and 299 deletions.
14 changes: 8 additions & 6 deletions Command/CleanCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand All @@ -11,11 +13,11 @@

namespace FOS\OAuthServerBundle\Command;

use FOS\OAuthServerBundle\Model\AuthCodeManagerInterface;
use FOS\OAuthServerBundle\Model\TokenManagerInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use FOS\OAuthServerBundle\Model\TokenManagerInterface;
use FOS\OAuthServerBundle\Model\AuthCodeManagerInterface;

class CleanCommand extends ContainerAwareCommand
{
Expand All @@ -40,11 +42,11 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$services = array(
'fos_oauth_server.access_token_manager' => 'Access token',
$services = [
'fos_oauth_server.access_token_manager' => 'Access token',
'fos_oauth_server.refresh_token_manager' => 'Refresh token',
'fos_oauth_server.auth_code_manager' => 'Auth code',
);
'fos_oauth_server.auth_code_manager' => 'Auth code',
];

foreach ($services as $service => $name) {
/** @var $instance TokenManagerInterface */
Expand Down
42 changes: 22 additions & 20 deletions Controller/AuthorizeController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand All @@ -17,9 +19,9 @@
use FOS\OAuthServerBundle\Model\ClientManagerInterface;
use OAuth2\OAuth2;
use OAuth2\OAuth2ServerException;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -39,15 +41,14 @@
*/
class AuthorizeController implements ContainerAwareInterface
{
/**
* @var ClientInterface
*/
private $client;

/**
* @var ContainerInterface
*/
protected $container;
/**
* @var ClientInterface
*/
private $client;

/**
* @var SessionInterface
Expand Down Expand Up @@ -104,19 +105,10 @@ class AuthorizeController implements ContainerAwareInterface
*/
private $eventDispatcher;

/**
* Sets the container.
*
* @param ContainerInterface|null $container A ContainerInterface instance or null
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}

/**
* This controller had been made as a service due to support symfony 4 where all* services are private by default.
* Thus, there is considered a bad practice to fetch services directly from container.
*
* @todo This controller could be refactored to do not rely on so many dependencies
*
* @param RequestStack $requestStack
Expand Down Expand Up @@ -157,6 +149,16 @@ public function __construct(
$this->eventDispatcher = $eventDispatcher;
}

/**
* Sets the container.
*
* @param ContainerInterface|null $container A ContainerInterface instance or null
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}

/**
* Authorize.
*/
Expand Down Expand Up @@ -193,10 +195,10 @@ public function authorizeAction(Request $request)

return $this->templating->renderResponse(
'FOSOAuthServerBundle:Authorize:authorize.html.'.$this->templateEngineType,
array(
'form' => $form->createView(),
[
'form' => $form->createView(),
'client' => $this->getClient(),
)
]
);
}

Expand Down Expand Up @@ -256,7 +258,7 @@ protected function getClient()
if (null !== $request) {
if (null === $clientId = $request->get('client_id')) {
$form = $this->authorizeForm;
$formData = $request->get($form->getName(), array());
$formData = $request->get($form->getName(), []);
$clientId = isset($formData['client_id']) ? $formData['client_id'] : null;
}

Expand Down
4 changes: 3 additions & 1 deletion Controller/TokenController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand All @@ -11,9 +13,9 @@

namespace FOS\OAuthServerBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use OAuth2\OAuth2;
use OAuth2\OAuth2ServerException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class TokenController
Expand Down
6 changes: 4 additions & 2 deletions DependencyInjection/Compiler/GrantExtensionsCompilerPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand All @@ -13,8 +15,8 @@

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;

/**
* @author Adrien Brault <adrien.brault@gmail.com>
Expand All @@ -36,7 +38,7 @@ public function process(ContainerBuilder $container)
throw new InvalidArgumentException(sprintf('Service "%s" must define the "uri" attribute on "fos_oauth_server.grant_extension" tags.', $id));
}

$storageDefinition->addMethodCall('setGrantExtension', array($tag['uri'], new Reference($id)));
$storageDefinition->addMethodCall('setGrantExtension', [$tag['uri'], new Reference($id)]);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion DependencyInjection/Compiler/RequestStackCompilerPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand Down Expand Up @@ -32,6 +34,6 @@ public function process(ContainerBuilder $container)
}

$definition = $container->getDefinition('fos_oauth_server.authorize.form.handler.default');
$definition->addMethodCall('setContainer', array(new Reference('service_container')));
$definition->addMethodCall('setContainer', [new Reference('service_container')]);
}
}
2 changes: 2 additions & 0 deletions DependencyInjection/Compiler/TokenStorageCompilerPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand Down
8 changes: 5 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand Down Expand Up @@ -30,7 +32,7 @@ public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('fos_oauth_server');

$supportedDrivers = array('orm', 'mongodb', 'propel');
$supportedDrivers = ['orm', 'mongodb', 'propel'];

$rootNode
->children()
Expand Down Expand Up @@ -72,7 +74,7 @@ private function addAuthorizeSection(ArrayNodeDefinition $node)
->scalarNode('name')->defaultValue('fos_oauth_server_authorize_form')->cannotBeEmpty()->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(array('Authorize', 'Default'))
->defaultValue(['Authorize', 'Default'])
->end()
->end()
->end()
Expand All @@ -97,7 +99,7 @@ private function addServiceSection(ArrayNodeDefinition $node)
->scalarNode('auth_code_manager')->defaultValue('fos_oauth_server.auth_code_manager.default')->end()
->arrayNode('options')
->useAttributeAsKey('key')
->treatNullLike(array())
->treatNullLike([])
->prototype('scalar')->end()
->end()
->end()
Expand Down
38 changes: 20 additions & 18 deletions DependencyInjection/FOSOAuthServerExtension.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand All @@ -11,14 +13,14 @@

namespace FOS\OAuthServerBundle\DependencyInjection;

use FOS\OAuthServerBundle\Util\LegacyFormHelper;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\Config\FileLocator;
use FOS\OAuthServerBundle\Util\LegacyFormHelper;

class FOSOAuthServerExtension extends Extension
{
Expand All @@ -35,7 +37,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load(sprintf('%s.xml', $config['db_driver']));

foreach (array('oauth', 'security') as $basename) {
foreach (['oauth', 'security'] as $basename) {
$loader->load(sprintf('%s.xml', $basename));
}

Expand All @@ -51,16 +53,16 @@ public function load(array $configs, ContainerBuilder $container)

$container->setParameter('fos_oauth_server.server.options', $config['service']['options']);

$this->remapParametersNamespaces($config, $container, array(
'' => array(
'model_manager_name' => 'fos_oauth_server.model_manager_name',
'client_class' => 'fos_oauth_server.model.client.class',
'access_token_class' => 'fos_oauth_server.model.access_token.class',
$this->remapParametersNamespaces($config, $container, [
'' => [
'model_manager_name' => 'fos_oauth_server.model_manager_name',
'client_class' => 'fos_oauth_server.model.client.class',
'access_token_class' => 'fos_oauth_server.model.access_token.class',
'refresh_token_class' => 'fos_oauth_server.model.refresh_token.class',
'auth_code_class' => 'fos_oauth_server.model.auth_code.class',
),
'auth_code_class' => 'fos_oauth_server.model.auth_code.class',
],
'template' => 'fos_oauth_server.template.%s',
));
]);

// Handle the MongoDB document manager name in a specific way as it does not have a registry to make it easy
// TODO: change it when bumping the requirement to Symfony 2.1
Expand All @@ -81,7 +83,7 @@ public function load(array $configs, ContainerBuilder $container)
if ('orm' === $config['db_driver']) {
$ormEntityManagerDefinition = $container->getDefinition('fos_oauth_server.entity_manager');
if (method_exists($ormEntityManagerDefinition, 'setFactory')) {
$ormEntityManagerDefinition->setFactory(array(new Reference('doctrine'), 'getManager'));
$ormEntityManagerDefinition->setFactory([new Reference('doctrine'), 'getManager']);
} else {
$ormEntityManagerDefinition->setFactoryService('doctrine');
$ormEntityManagerDefinition->setFactoryMethod('getManager');
Expand All @@ -96,7 +98,7 @@ public function load(array $configs, ContainerBuilder $container)
// TODO: Go back to xml configuration when bumping the requirement to Symfony >=2.6
$authorizeFormDefinition = $container->getDefinition('fos_oauth_server.authorize.form');
if (method_exists($authorizeFormDefinition, 'setFactory')) {
$authorizeFormDefinition->setFactory(array(new Reference('form.factory'), 'createNamed'));
$authorizeFormDefinition->setFactory([new Reference('form.factory'), 'createNamed']);
} else {
$authorizeFormDefinition->setFactoryService('form.factory');
$authorizeFormDefinition->setFactoryMethod('createNamed');
Expand Down Expand Up @@ -154,8 +156,8 @@ protected function loadAuthorize(array $config, ContainerBuilder $container, Xml
$config['form']['type'] = $authorizeFormTypeDefinition->getClass();
}

$this->remapParametersNamespaces($config, $container, array(
$this->remapParametersNamespaces($config, $container, [
'form' => 'fos_oauth_server.authorize.form.%s',
));
]);
}
}
7 changes: 4 additions & 3 deletions DependencyInjection/Security/Factory/OAuthFactory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand Down Expand Up @@ -38,8 +40,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
}
$container
->setDefinition($providerId, $definition)
->replaceArgument(0, new Reference($userProvider))
;
->replaceArgument(0, new Reference($userProvider));

$listenerId = 'security.authentication.listener.fos_oauth_server.'.$id;

Expand All @@ -50,7 +51,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,
}
$container->setDefinition($listenerId, $definition);

return array($providerId, $listenerId, 'fos_oauth_server.security.entry_point');
return [$providerId, $listenerId, 'fos_oauth_server.security.entry_point'];
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Document/AccessToken.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand Down
2 changes: 2 additions & 0 deletions Document/AccessTokenManager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand Down
2 changes: 2 additions & 0 deletions Document/AuthCode.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand Down
Loading

0 comments on commit 8630dc1

Please sign in to comment.