Skip to content

Commit 7f8a2bc

Browse files
authored
Drop support for unmainted Symfony versions (#648)
* Remove support for Symfony version older than 4.4 * Fix deprecation for configuration tree builder * Remove legacy form types * Add changelog * Update return type-hint for commands * Remove DefinitionDecorator usage * Remove security.context * Drop ListenerInterface usage * Replace GetResponseEvent by RequestEvent * Replace getRoles() by getRoleNames() * Update travis configuration
1 parent 0c10f7f commit 7f8a2bc

File tree

19 files changed

+44
-350
lines changed

19 files changed

+44
-350
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ service:
1212
matrix:
1313
fast_finish: true
1414
include:
15-
- php: 7.1
16-
env: SYMFONY_VERSION=3.4.*
1715
- php: 7.2
18-
env: SYMFONY_VERSION=4.0.*
19-
- php: 7.2
20-
env: SYMFONY_VERSION=4.0.* DEPENDENCIES=beta
16+
env: DEPENDENCIES=beta
2117

2218
cache:
2319
directories:

CHANGELOG-2.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This changelog references the relevant changes done in 6.0 versions.
66
### 2.0.0-ALPHA1 (unreleased)
77

88
* Added `NL` translations [[#631](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/pull/631)]
9+
* Dropped support for Symfony versions anterior to `4.4` [[#648](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/pull/648)]
910
* Fixed form submission/validation [[#643](https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/pull/643)]
1011

1112
### 2.0.0-ALPHA0 (2018-05-01)

Command/CleanCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ protected function configure()
5959
/**
6060
* {@inheritdoc}
6161
*/
62-
protected function execute(InputInterface $input, OutputInterface $output)
62+
protected function execute(InputInterface $input, OutputInterface $output): int
6363
{
6464
foreach ([$this->accessTokenManager, $this->refreshTokenManager, $this->authCodeManager] as $service) {
6565
$result = $service->deleteExpired();
6666
$output->writeln(sprintf('Removed <info>%d</info> items from <comment>%s</comment> storage.', $result, get_class($service)));
6767
}
68+
69+
return 0;
6870
}
6971
}

Command/CreateClientCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function configure()
6868
/**
6969
* {@inheritdoc}
7070
*/
71-
protected function execute(InputInterface $input, OutputInterface $output)
71+
protected function execute(InputInterface $input, OutputInterface $output): int
7272
{
7373
$io = new SymfonyStyle($input, $output);
7474

DependencyInjection/Compiler/TokenStorageCompilerPass.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

DependencyInjection/Configuration.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ class Configuration implements ConfigurationInterface
2929
*/
3030
public function getConfigTreeBuilder()
3131
{
32-
$treeBuilder = new TreeBuilder();
33-
34-
/** @var ArrayNodeDefinition $rootNode */
35-
$rootNode = $treeBuilder->root('fos_oauth_server');
32+
$treeBuilder = new TreeBuilder('fos_oauth_server');
33+
$rootNode = $treeBuilder->getRootNode();
3634

3735
$supportedDrivers = ['orm', 'mongodb', 'propel', 'custom'];
3836

DependencyInjection/FOSOAuthServerExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace FOS\OAuthServerBundle\DependencyInjection;
1515

16-
use FOS\OAuthServerBundle\Util\LegacyFormHelper;
1716
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1817
use Symfony\Component\Config\Definition\Processor;
1918
use Symfony\Component\Config\FileLocator;
@@ -149,7 +148,7 @@ protected function loadAuthorize(array $config, ContainerBuilder $container, Xml
149148
$container->setAlias('fos_oauth_server.authorize.form.handler', $config['form']['handler']);
150149
unset($config['form']['handler']);
151150

152-
if (!LegacyFormHelper::isLegacy() && $config['form']['type'] === 'fos_oauth_server_authorize') {
151+
if ($config['form']['type'] === 'fos_oauth_server_authorize') {
153152
$authorizeFormTypeDefinition = $container->getDefinition('fos_oauth_server.authorize.form.type');
154153
$config['form']['type'] = $authorizeFormTypeDefinition->getClass();
155154
}

DependencyInjection/Security/Factory/OAuthFactory.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
1717
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
18+
use Symfony\Component\DependencyInjection\ChildDefinition;
1819
use Symfony\Component\DependencyInjection\ContainerBuilder;
1920
use Symfony\Component\DependencyInjection\Reference;
2021

@@ -30,22 +31,14 @@ class OAuthFactory implements SecurityFactoryInterface
3031
*/
3132
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
3233
{
33-
// NOTE: done like this to avoid PHPStan complaining about a missing class for both Symfony v3 and Symfony v4
34-
$definitionDecorator = 'Symfony\\Component\\DependencyInjection\\DefinitionDecorator';
35-
$childDefinition = 'Symfony\\Component\\DependencyInjection\\ChildDefinition';
36-
$definitionClass = $childDefinition;
37-
if (class_exists($definitionDecorator)) {
38-
$definitionClass = $definitionDecorator;
39-
}
40-
4134
$providerId = 'security.authentication.provider.fos_oauth_server.'.$id;
4235
$container
43-
->setDefinition($providerId, new $definitionClass('fos_oauth_server.security.authentication.provider'))
36+
->setDefinition($providerId, new ChildDefinition('fos_oauth_server.security.authentication.provider'))
4437
->replaceArgument(0, new Reference($userProvider))
4538
;
4639

4740
$listenerId = 'security.authentication.listener.fos_oauth_server.'.$id;
48-
$container->setDefinition($listenerId, new $definitionClass('fos_oauth_server.security.authentication.listener'));
41+
$container->setDefinition($listenerId, new ChildDefinition('fos_oauth_server.security.authentication.listener'));
4942

5043
return [$providerId, $listenerId, 'fos_oauth_server.security.entry_point'];
5144
}

FOSOAuthServerBundle.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use FOS\OAuthServerBundle\DependencyInjection\Compiler\GrantExtensionsCompilerPass;
1717
use FOS\OAuthServerBundle\DependencyInjection\Compiler\RequestStackCompilerPass;
18-
use FOS\OAuthServerBundle\DependencyInjection\Compiler\TokenStorageCompilerPass;
1918
use FOS\OAuthServerBundle\DependencyInjection\FOSOAuthServerExtension;
2019
use FOS\OAuthServerBundle\DependencyInjection\Security\Factory\OAuthFactory;
2120
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
@@ -38,7 +37,6 @@ public function build(ContainerBuilder $container)
3837
$extension->addSecurityListenerFactory(new OAuthFactory());
3938

4039
$container->addCompilerPass(new GrantExtensionsCompilerPass());
41-
$container->addCompilerPass(new TokenStorageCompilerPass());
4240
$container->addCompilerPass(new RequestStackCompilerPass());
4341
}
4442
}

Form/Type/AuthorizeFormType.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace FOS\OAuthServerBundle\Form\Type;
1515

16-
use FOS\OAuthServerBundle\Util\LegacyFormHelper;
1716
use Symfony\Component\Form\AbstractType;
17+
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
1818
use Symfony\Component\Form\FormBuilderInterface;
1919
use Symfony\Component\OptionsResolver\OptionsResolver;
2020

@@ -25,13 +25,11 @@ class AuthorizeFormType extends AbstractType
2525
{
2626
public function buildForm(FormBuilderInterface $builder, array $options)
2727
{
28-
$hiddenType = LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\HiddenType');
29-
30-
$builder->add('client_id', $hiddenType);
31-
$builder->add('response_type', $hiddenType);
32-
$builder->add('redirect_uri', $hiddenType);
33-
$builder->add('state', $hiddenType);
34-
$builder->add('scope', $hiddenType);
28+
$builder->add('client_id', HiddenType::class);
29+
$builder->add('response_type', HiddenType::class);
30+
$builder->add('redirect_uri', HiddenType::class);
31+
$builder->add('state', HiddenType::class);
32+
$builder->add('scope', HiddenType::class);
3533
}
3634

3735
/**

0 commit comments

Comments
 (0)