Skip to content

Commit 8e5d0d1

Browse files
committed
[PasswordHasher] Fix incompatibility with 6.0
1 parent 70d2795 commit 8e5d0d1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Hasher/UserPasswordHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function hashPassword($user, string $plainPassword): string
4848
if ($user instanceof LegacyPasswordAuthenticatedUserInterface) {
4949
$salt = $user->getSalt();
5050
} elseif ($user instanceof UserInterface) {
51-
$salt = $user->getSalt();
51+
$salt = method_exists($user, 'getSalt') ? $user->getSalt() : null;
5252

5353
if ($salt) {
5454
trigger_deprecation('symfony/password-hasher', '5.3', 'Returning a string from "getSalt()" without implementing the "%s" interface is deprecated, the "%s" class should implement it.', LegacyPasswordAuthenticatedUserInterface::class, get_debug_type($user));

Tests/Fixtures/TestLegacyPasswordAuthenticatedUser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ public function getPassword(): ?string
3030
return $this->password;
3131
}
3232

33-
public function getRoles()
33+
public function getRoles(): array
3434
{
3535
return $this->roles;
3636
}
3737

38-
public function eraseCredentials()
38+
public function eraseCredentials(): void
3939
{
4040
// Do nothing
4141
return;
4242
}
4343

44-
public function getUsername()
44+
public function getUsername(): string
4545
{
4646
return $this->username;
4747
}
4848

49-
public function getUserIdentifier()
49+
public function getUserIdentifier(): string
5050
{
5151
return $this->username;
5252
}

0 commit comments

Comments
 (0)