Skip to content

Commit 8098ab1

Browse files
Drop Symfony 4.4 and Twig 2 (#1632)
1 parent ecb9799 commit 8098ab1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+187
-535
lines changed

.github/workflows/test.yaml

-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ jobs:
4848
dependencies: lowest
4949
allowed-to-fail: false
5050
variant: normal
51-
- php-version: '8.2'
52-
dependencies: highest
53-
allowed-to-fail: false
54-
symfony-require: 4.4.*
55-
variant: symfony/symfony:"4.4.*"
5651
- php-version: '8.2'
5752
dependencies: highest
5853
allowed-to-fail: false

composer.json

+24-24
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@
2727
"sonata-project/doctrine-extensions": "^1.13 || ^2.0",
2828
"sonata-project/form-extensions": "^1.4",
2929
"sonata-project/twig-extensions": "^1.3 || ^2.0",
30-
"symfony/config": "^4.4.11 || ^5.4 || ^6.2",
31-
"symfony/console": "^4.4 || ^5.4 || ^6.2",
32-
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.2",
33-
"symfony/event-dispatcher": "^4.4 || ^5.4 || ^6.2",
34-
"symfony/form": "^4.4.20 || ^5.4 || ^6.2",
35-
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.2",
36-
"symfony/http-foundation": "^4.4 || ^5.4 || ^6.2",
37-
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.2",
38-
"symfony/mailer": "^4.4 || ^5.4 || ^6.2",
39-
"symfony/mime": "^4.4.10 || ^5.4 || ^6.2",
40-
"symfony/options-resolver": "^4.4 || ^5.4 || ^6.2",
41-
"symfony/routing": "^4.4 || ^5.4 || ^6.2",
30+
"symfony/config": "^5.4 || ^6.2",
31+
"symfony/console": "^5.4 || ^6.2",
32+
"symfony/dependency-injection": "^5.4 || ^6.2",
33+
"symfony/event-dispatcher": "^5.4 || ^6.2",
34+
"symfony/form": "^5.4 || ^6.2",
35+
"symfony/framework-bundle": "^5.4 || ^6.2",
36+
"symfony/http-foundation": "^5.4 || ^6.2",
37+
"symfony/http-kernel": "^5.4 || ^6.2",
38+
"symfony/mailer": "^5.4 || ^6.2",
39+
"symfony/mime": "^5.4 || ^6.2",
40+
"symfony/options-resolver": "^5.4 || ^6.2",
41+
"symfony/routing": "^5.4 || ^6.2",
4242
"symfony/security-acl": "^3.0",
43-
"symfony/security-core": "^4.4.23 || ^5.4 || ^6.2",
44-
"symfony/security-csrf": "^4.4 || ^5.4 || ^6.2",
45-
"symfony/translation": "^4.4 || ^5.4 || ^6.2",
46-
"symfony/translation-contracts": "^1.1 || ^2.5 || ^3.0",
47-
"symfony/validator": "^4.4 || ^5.4 || ^6.2",
48-
"twig/twig": "^2.14 || ^3.0"
43+
"symfony/security-core": "^5.4 || ^6.2",
44+
"symfony/security-csrf": "^5.4 || ^6.2",
45+
"symfony/translation": "^5.4 || ^6.2",
46+
"symfony/translation-contracts": "^2.5 || ^3.0",
47+
"symfony/validator": "^5.4 || ^6.2",
48+
"twig/twig": "^3.0"
4949
},
5050
"require-dev": {
5151
"dama/doctrine-test-bundle": "^7.0",
@@ -63,17 +63,17 @@
6363
"phpstan/phpstan-symfony": "^1.0",
6464
"phpunit/phpunit": "^9.5",
6565
"psalm/plugin-phpunit": "^0.18",
66-
"psalm/plugin-symfony": "^4.0 || ^5.0",
66+
"psalm/plugin-symfony": "^5.0",
6767
"rector/rector": "^0.15",
6868
"sonata-project/admin-bundle": "^4.20",
6969
"sonata-project/block-bundle": "^4.11",
7070
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
71-
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.2",
72-
"symfony/console": "^4.4 || ^5.4 || ^6.2",
73-
"symfony/filesystem": "^4.4 || ^5.4 || ^6.2",
74-
"symfony/intl": "^4.4 || ^5.4 || ^6.2",
71+
"symfony/browser-kit": "^5.4 || ^6.2",
72+
"symfony/console": "^5.4 || ^6.2",
73+
"symfony/filesystem": "^5.4 || ^6.2",
74+
"symfony/intl": "^5.4 || ^6.2",
7575
"symfony/phpunit-bridge": "^6.2",
76-
"vimeo/psalm": "^4.9.2 || ^5.0"
76+
"vimeo/psalm": "^5.0"
7777
},
7878
"conflict": {
7979
"sonata-project/admin-bundle": "<4.20",

psalm-baseline.xml

-13
This file was deleted.

psalm.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" findUnusedBaselineEntry="true" findUnusedCode="false" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml">
2+
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" findUnusedBaselineEntry="true" findUnusedCode="false" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
33
<projectFiles>
44
<directory name="src"/>
55
<directory name="tests"/>

src/Command/ActivateUserCommand.php

-8
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,14 @@
2626
#[AsCommand(name: 'sonata:user:activate', description: 'Activate a user')]
2727
final class ActivateUserCommand extends Command
2828
{
29-
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
30-
protected static $defaultName = 'sonata:user:activate';
31-
protected static $defaultDescription = 'Activate a user';
32-
3329
public function __construct(private UserManagerInterface $userManager)
3430
{
3531
parent::__construct();
3632
}
3733

3834
protected function configure(): void
3935
{
40-
\assert(null !== static::$defaultDescription);
41-
4236
$this
43-
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
44-
->setDescription(static::$defaultDescription)
4537
->setDefinition([
4638
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
4739
])

src/Command/ChangePasswordCommand.php

-8
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,14 @@
2626
#[AsCommand(name: 'sonata:user:change-password', description: 'Change the password of a user')]
2727
final class ChangePasswordCommand extends Command
2828
{
29-
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
30-
protected static $defaultName = 'sonata:user:change-password';
31-
protected static $defaultDescription = 'Change the password of a user';
32-
3329
public function __construct(private UserManagerInterface $userManager)
3430
{
3531
parent::__construct();
3632
}
3733

3834
protected function configure(): void
3935
{
40-
\assert(null !== static::$defaultDescription);
41-
4236
$this
43-
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
44-
->setDescription(static::$defaultDescription)
4537
->setDefinition([
4638
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
4739
new InputArgument('password', InputArgument::REQUIRED, 'The password'),

src/Command/CreateUserCommand.php

-8
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,14 @@
2727
#[AsCommand(name: 'sonata:user:create', description: 'Create a user')]
2828
final class CreateUserCommand extends Command
2929
{
30-
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
31-
protected static $defaultName = 'sonata:user:create';
32-
protected static $defaultDescription = 'Create a user';
33-
3430
public function __construct(private UserManagerInterface $userManager)
3531
{
3632
parent::__construct();
3733
}
3834

3935
protected function configure(): void
4036
{
41-
\assert(null !== static::$defaultDescription);
42-
4337
$this
44-
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
45-
->setDescription(static::$defaultDescription)
4638
->setDefinition([
4739
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
4840
new InputArgument('email', InputArgument::REQUIRED, 'The email'),

src/Command/DeactivateUserCommand.php

-8
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,14 @@
2626
#[AsCommand(name: 'sonata:user:deactivate', description: 'Deactivate a user')]
2727
final class DeactivateUserCommand extends Command
2828
{
29-
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
30-
protected static $defaultName = 'sonata:user:deactivate';
31-
protected static $defaultDescription = 'Deactivate a user';
32-
3329
public function __construct(private UserManagerInterface $userManager)
3430
{
3531
parent::__construct();
3632
}
3733

3834
protected function configure(): void
3935
{
40-
\assert(null !== static::$defaultDescription);
41-
4236
$this
43-
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
44-
->setDescription(static::$defaultDescription)
4537
->setDefinition([
4638
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
4739
])

src/Command/DemoteUserCommand.php

-8
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,14 @@
2727
#[AsCommand(name: 'sonata:user:demote', description: 'Demotes a user by removing a role')]
2828
final class DemoteUserCommand extends Command
2929
{
30-
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
31-
protected static $defaultName = 'sonata:user:demote';
32-
protected static $defaultDescription = 'Demotes a user by removing a role';
33-
3430
public function __construct(private UserManagerInterface $userManager)
3531
{
3632
parent::__construct();
3733
}
3834

3935
protected function configure(): void
4036
{
41-
\assert(null !== static::$defaultDescription);
42-
4337
$this
44-
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
45-
->setDescription(static::$defaultDescription)
4638
->setDefinition([
4739
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
4840
new InputArgument('role', InputArgument::OPTIONAL, 'The role'),

src/Command/PromoteUserCommand.php

-8
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,14 @@
2727
#[AsCommand(name: 'sonata:user:promote', description: 'Promotes a user by adding a role')]
2828
final class PromoteUserCommand extends Command
2929
{
30-
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
31-
protected static $defaultName = 'sonata:user:promote';
32-
protected static $defaultDescription = 'Promotes a user by adding a role';
33-
3430
public function __construct(private UserManagerInterface $userManager)
3531
{
3632
parent::__construct();
3733
}
3834

3935
protected function configure(): void
4036
{
41-
\assert(null !== static::$defaultDescription);
42-
4337
$this
44-
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
45-
->setDescription(static::$defaultDescription)
4638
->setDefinition([
4739
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
4840
new InputArgument('role', InputArgument::OPTIONAL, 'The role'),

src/DependencyInjection/SonataUserExtension.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ public function load(array $configs, ContainerBuilder $container): void
7878
$this->configureResetting($config['resetting'], $container);
7979
}
8080

81-
if ($this->isConfigEnabled($container, $config['impersonating'])) {
82-
$this->configureImpersonation($config['impersonating'], $container);
83-
}
81+
$this->configureImpersonation($config['impersonating'], $container);
8482
}
8583

8684
/**
@@ -186,7 +184,7 @@ private function configureImpersonation(array $config, ContainerBuilder $contain
186184
{
187185
$container->getDefinition('sonata.user.twig.global')
188186
->replaceArgument(2, $config['enabled'])
189-
->replaceArgument(3, $config['route'])
190-
->replaceArgument(4, $config['parameters']);
187+
->replaceArgument(3, $config['route'] ?? '')
188+
->replaceArgument(4, $config['parameters'] ?? []);
191189
}
192190
}

src/Document/UserManager.php

+2-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Sonata\UserBundle\Model\UserManagerInterface;
2020
use Sonata\UserBundle\Util\CanonicalFieldsUpdaterInterface;
2121
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
22-
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
2322

2423
/**
2524
* @author Hugo Briand <[email protected]>
@@ -29,25 +28,17 @@
2928
final class UserManager extends BaseDocumentManager implements UserManagerInterface
3029
{
3130
/**
32-
* TODO: Simplify this once support for Symfony 4.4 is dropped.
33-
*
34-
* @param UserPasswordEncoderInterface|UserPasswordHasherInterface $userPasswordHasher
35-
*
3631
* @phpstan-param class-string<UserInterface> $class
3732
*/
3833
public function __construct(
3934
string $class,
4035
ManagerRegistry $registry,
4136
private CanonicalFieldsUpdaterInterface $canonicalFieldsUpdater,
42-
// @phpstan-ignore-next-line
43-
private object $userPasswordHasher
37+
private UserPasswordHasherInterface $userPasswordHasher
4438
) {
4539
parent::__construct($class, $registry);
4640
}
4741

48-
/**
49-
* @psalm-suppress UndefinedDocblockClass
50-
*/
5142
public function updatePassword(UserInterface $user): void
5243
{
5344
$plainPassword = $user->getPlainPassword();
@@ -56,12 +47,7 @@ public function updatePassword(UserInterface $user): void
5647
return;
5748
}
5849

59-
if ($this->userPasswordHasher instanceof UserPasswordHasherInterface) {
60-
$password = $this->userPasswordHasher->hashPassword($user, $plainPassword);
61-
} else {
62-
// @phpstan-ignore-next-line
63-
$password = $this->userPasswordHasher->encodePassword($user, $plainPassword);
64-
}
50+
$password = $this->userPasswordHasher->hashPassword($user, $plainPassword);
6551

6652
$user->setPassword($password);
6753
$user->eraseCredentials();

src/Entity/UserManager.php

+2-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Sonata\UserBundle\Model\UserManagerInterface;
2020
use Sonata\UserBundle\Util\CanonicalFieldsUpdaterInterface;
2121
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
22-
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
2322

2423
/**
2524
* @author Hugo Briand <[email protected]>
@@ -29,25 +28,17 @@
2928
final class UserManager extends BaseEntityManager implements UserManagerInterface
3029
{
3130
/**
32-
* TODO: Simplify this once support for Symfony 4.4 is dropped.
33-
*
34-
* @param UserPasswordEncoderInterface|UserPasswordHasherInterface $userPasswordHasher
35-
*
3631
* @phpstan-param class-string<UserInterface> $class
3732
*/
3833
public function __construct(
3934
string $class,
4035
ManagerRegistry $registry,
4136
private CanonicalFieldsUpdaterInterface $canonicalFieldsUpdater,
42-
// @phpstan-ignore-next-line
43-
private object $userPasswordHasher
37+
private UserPasswordHasherInterface $userPasswordHasher
4438
) {
4539
parent::__construct($class, $registry);
4640
}
4741

48-
/**
49-
* @psalm-suppress UndefinedDocblockClass
50-
*/
5142
public function updatePassword(UserInterface $user): void
5243
{
5344
$plainPassword = $user->getPlainPassword();
@@ -56,12 +47,7 @@ public function updatePassword(UserInterface $user): void
5647
return;
5748
}
5849

59-
if ($this->userPasswordHasher instanceof UserPasswordHasherInterface) {
60-
$password = $this->userPasswordHasher->hashPassword($user, $plainPassword);
61-
} else {
62-
// @phpstan-ignore-next-line
63-
$password = $this->userPasswordHasher->encodePassword($user, $plainPassword);
64-
}
50+
$password = $this->userPasswordHasher->hashPassword($user, $plainPassword);
6551

6652
$user->setPassword($password);
6753
$user->eraseCredentials();

src/Model/BCPasswordAuthenticatedUserInterface.php

-29
This file was deleted.

0 commit comments

Comments
 (0)