Skip to content

Commit 390aae3

Browse files
authored
Merge pull request #3092 from stof/avoid_deprecation
Fix Symfony deprecations
2 parents 607a7fb + e6aa01a commit 390aae3

10 files changed

Lines changed: 17 additions & 18 deletions

src/Form/Type/ChangePasswordFormType.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ public function __construct($class)
3636

3737
public function buildForm(FormBuilderInterface $builder, array $options): void
3838
{
39-
$constraintsOptions = [
40-
'message' => 'fos_user.current_password.invalid',
41-
];
39+
$groups = null;
4240

4341
if (!empty($options['validation_groups'])) {
44-
$constraintsOptions['groups'] = [reset($options['validation_groups'])];
42+
$groups = [reset($options['validation_groups'])];
4543
}
4644

4745
$builder->add('current_password', PasswordType::class, [
@@ -50,7 +48,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5048
'mapped' => false,
5149
'constraints' => [
5250
new NotBlank(),
53-
new UserPassword($constraintsOptions),
51+
new UserPassword(message: 'fos_user.current_password.invalid', groups: $groups),
5452
],
5553
'attr' => [
5654
'autocomplete' => 'current-password',

src/Form/Type/ProfileFormType.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
3838
{
3939
$this->buildUserForm($builder, $options);
4040

41-
$constraintsOptions = [
42-
'message' => 'fos_user.current_password.invalid',
43-
];
41+
$groups = null;
4442

4543
if (!empty($options['validation_groups'])) {
46-
$constraintsOptions['groups'] = [reset($options['validation_groups'])];
44+
$groups = [reset($options['validation_groups'])];
4745
}
4846

4947
$builder->add('current_password', PasswordType::class, [
@@ -52,7 +50,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5250
'mapped' => false,
5351
'constraints' => [
5452
new NotBlank(),
55-
new UserPassword($constraintsOptions),
53+
new UserPassword(message: 'fos_user.current_password.invalid', groups: $groups),
5654
],
5755
'attr' => [
5856
'autocomplete' => 'current-password',

src/Security/UserChecker.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace FOS\UserBundle\Security;
1313

1414
use FOS\UserBundle\Model\UserInterface;
15+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1516
use Symfony\Component\Security\Core\Exception\DisabledException;
1617
use Symfony\Component\Security\Core\User\UserCheckerInterface;
1718
use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface;
@@ -20,6 +21,8 @@
2021
* UserChecker checks the user account flags.
2122
*
2223
* @author Julian Finkler (Devtronic) <julian@developer-heaven.de>
24+
*
25+
* @final
2326
*/
2427
class UserChecker implements UserCheckerInterface
2528
{
@@ -32,7 +35,7 @@ public function checkPreAuth(BaseUserInterface $user): void
3235
}
3336
}
3437

35-
public function checkPostAuth(BaseUserInterface $user): void
38+
public function checkPostAuth(BaseUserInterface $user, ?TokenInterface $token = null): void
3639
{
3740
}
3841
}

src/Util/HashingPasswordUpdater.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ public function hashPassword(UserInterface $user): void
5050
}
5151

5252
$user->setPassword($hashedPassword);
53-
$user->eraseCredentials();
53+
$user->setPlainPassword(null);
5454
}
5555
}

tests/Command/ActivateUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
6767

6868
$command = new ActivateUserCommand($manipulator);
6969

70-
$application->add($command);
70+
$application->addCommands([$command]);
7171

7272
return new CommandTester($application->find('fos:user:activate'));
7373
}

tests/Command/ChangePasswordCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function createCommandTester(UserManipulator $userManipulator, ?Applicat
6868

6969
$command = new ChangePasswordCommand($userManipulator);
7070

71-
$application->add($command);
71+
$application->addCommands([$command]);
7272

7373
return new CommandTester($application->find('fos:user:change-password'));
7474
}

tests/Command/CreateUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
7171

7272
$command = new CreateUserCommand($manipulator);
7373

74-
$application->add($command);
74+
$application->addCommands([$command]);
7575

7676
return new CommandTester($application->find('fos:user:create'));
7777
}

tests/Command/DeactivateUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
6767

6868
$command = new DeactivateUserCommand($manipulator);
6969

70-
$application->add($command);
70+
$application->addCommands([$command]);
7171

7272
return new CommandTester($application->find('fos:user:deactivate'));
7373
}

tests/Command/DemoteUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
6868

6969
$command = new DemoteUserCommand($manipulator);
7070

71-
$application->add($command);
71+
$application->addCommands([$command]);
7272

7373
return new CommandTester($application->find('fos:user:demote'));
7474
}

tests/Command/PromoteUserCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private function createCommandTester(UserManipulator $manipulator, ?Application
6868

6969
$command = new PromoteUserCommand($manipulator);
7070

71-
$application->add($command);
71+
$application->addCommands([$command]);
7272

7373
return new CommandTester($application->find('fos:user:promote'));
7474
}

0 commit comments

Comments
 (0)